fixed pointer arithmetic error in glCopyPixels
[mesa.git] / src / mesa / main / rastpos.c
1 /* $Id: rastpos.c,v 1.35 2002/02/15 16:26:08 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 4.1
6 *
7 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27
28 #ifdef PC_HEADER
29 #include "all.h"
30 #else
31 #include "glheader.h"
32 #include "clip.h"
33 #include "colormac.h"
34 #include "context.h"
35 #include "feedback.h"
36 #include "light.h"
37 #include "macros.h"
38 #include "mmath.h"
39 #include "rastpos.h"
40 #include "state.h"
41 #include "simple_list.h"
42 #include "mtypes.h"
43
44 #include "math/m_matrix.h"
45 #include "math/m_xform.h"
46 #endif
47
48
49 /*
50 * Clip a point against the view volume.
51 * Input: v - vertex-vector describing the point to clip
52 * Return: 0 = outside view volume
53 * 1 = inside view volume
54 */
55 static GLuint
56 viewclip_point( const GLfloat v[] )
57 {
58 if ( v[0] > v[3] || v[0] < -v[3]
59 || v[1] > v[3] || v[1] < -v[3]
60 || v[2] > v[3] || v[2] < -v[3] ) {
61 return 0;
62 }
63 else {
64 return 1;
65 }
66 }
67
68
69 /* As above, but only clip test against far/near Z planes */
70 static GLuint
71 viewclip_point_z( const GLfloat v[] )
72 {
73 if (v[2] > v[3] || v[2] < -v[3] ) {
74 return 0;
75 }
76 else {
77 return 1;
78 }
79 }
80
81
82
83 /*
84 * Clip a point against the user clipping planes.
85 * Input: v - vertex-vector describing the point to clip.
86 * Return: 0 = point was clipped
87 * 1 = point not clipped
88 */
89 static GLuint
90 userclip_point( GLcontext* ctx, const GLfloat v[] )
91 {
92 GLuint p;
93
94 for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
95 if (ctx->Transform.ClipEnabled[p]) {
96 GLfloat dot = v[0] * ctx->Transform._ClipUserPlane[p][0]
97 + v[1] * ctx->Transform._ClipUserPlane[p][1]
98 + v[2] * ctx->Transform._ClipUserPlane[p][2]
99 + v[3] * ctx->Transform._ClipUserPlane[p][3];
100 if (dot < 0.0F) {
101 return 0;
102 }
103 }
104 }
105
106 return 1;
107 }
108
109
110 /* This has been split off to allow the normal shade routines to
111 * get a little closer to the vertex buffer, and to use the
112 * GLvector objects directly.
113 * Input: ctx - the context
114 * vertex - vertex location
115 * normal - normal vector
116 * Output: Rcolor - returned color
117 * Rspec - returned specular color (if separate specular enabled)
118 * Rindex - returned color index
119 */
120 static void
121 shade_rastpos(GLcontext *ctx,
122 const GLfloat vertex[4],
123 const GLfloat normal[3],
124 GLfloat Rcolor[4],
125 GLfloat Rspec[4],
126 GLuint *Rindex)
127 {
128 GLfloat (*base)[3] = ctx->Light._BaseColor;
129 struct gl_light *light;
130 GLfloat diffuseColor[4], specularColor[4];
131 GLfloat diffuse = 0, specular = 0;
132
133 if (!ctx->_ShineTable[0] || !ctx->_ShineTable[1])
134 _mesa_validate_all_lighting_tables( ctx );
135
136 COPY_3V(diffuseColor, base[0]);
137 diffuseColor[3] = CLAMP( ctx->Light.Material[0].Diffuse[3], 0.0F, 1.0F );
138 ASSIGN_4V(specularColor, 0.0, 0.0, 0.0, 0.0);
139
140 foreach (light, &ctx->Light.EnabledList) {
141 GLfloat n_dot_h;
142 GLfloat attenuation = 1.0;
143 GLfloat VP[3];
144 GLfloat n_dot_VP;
145 GLfloat *h;
146 GLfloat diffuseContrib[3], specularContrib[3];
147 GLboolean normalized;
148
149 if (!(light->_Flags & LIGHT_POSITIONAL)) {
150 COPY_3V(VP, light->_VP_inf_norm);
151 attenuation = light->_VP_inf_spot_attenuation;
152 }
153 else {
154 GLfloat d;
155
156 SUB_3V(VP, light->_Position, vertex);
157 d = (GLfloat) LEN_3FV( VP );
158
159 if ( d > 1e-6) {
160 GLfloat invd = 1.0F / d;
161 SELF_SCALE_SCALAR_3V(VP, invd);
162 }
163 attenuation = 1.0F / (light->ConstantAttenuation + d *
164 (light->LinearAttenuation + d *
165 light->QuadraticAttenuation));
166
167 if (light->_Flags & LIGHT_SPOT) {
168 GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
169
170 if (PV_dot_dir<light->_CosCutoff) {
171 continue;
172 }
173 else {
174 double x = PV_dot_dir * (EXP_TABLE_SIZE-1);
175 int k = (int) x;
176 GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
177 + (x-k)*light->_SpotExpTable[k][1]);
178 attenuation *= spot;
179 }
180 }
181 }
182
183 if (attenuation < 1e-3)
184 continue;
185
186 n_dot_VP = DOT3( normal, VP );
187
188 if (n_dot_VP < 0.0F) {
189 ACC_SCALE_SCALAR_3V(diffuseColor, attenuation, light->_MatAmbient[0]);
190 continue;
191 }
192
193 COPY_3V(diffuseContrib, light->_MatAmbient[0]);
194 ACC_SCALE_SCALAR_3V(diffuseContrib, n_dot_VP, light->_MatDiffuse[0]);
195 diffuse += n_dot_VP * light->_dli * attenuation;
196 ASSIGN_3V(specularContrib, 0.0, 0.0, 0.0);
197
198 {
199 if (ctx->Light.Model.LocalViewer) {
200 GLfloat v[3];
201 COPY_3V(v, vertex);
202 NORMALIZE_3FV(v);
203 SUB_3V(VP, VP, v);
204 h = VP;
205 normalized = 0;
206 }
207 else if (light->_Flags & LIGHT_POSITIONAL) {
208 h = VP;
209 ACC_3V(h, ctx->_EyeZDir);
210 normalized = 0;
211 }
212 else {
213 h = light->_h_inf_norm;
214 normalized = 1;
215 }
216
217 n_dot_h = DOT3(normal, h);
218
219 if (n_dot_h > 0.0F) {
220 const struct gl_material *mat = &ctx->Light.Material[0];
221 GLfloat spec_coef;
222 GLfloat shininess = mat->Shininess;
223
224 if (!normalized) {
225 n_dot_h *= n_dot_h;
226 n_dot_h /= LEN_SQUARED_3FV( h );
227 shininess *= .5;
228 }
229
230 GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec_coef );
231
232 if (spec_coef > 1.0e-10) {
233 if (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) {
234 ACC_SCALE_SCALAR_3V( specularContrib, spec_coef,
235 light->_MatSpecular[0]);
236 }
237 else {
238 ACC_SCALE_SCALAR_3V( diffuseContrib, spec_coef,
239 light->_MatSpecular[0]);
240 }
241 specular += spec_coef * light->_sli * attenuation;
242 }
243 }
244 }
245
246 ACC_SCALE_SCALAR_3V( diffuseColor, attenuation, diffuseContrib );
247 ACC_SCALE_SCALAR_3V( specularColor, attenuation, specularContrib );
248 }
249
250 if (ctx->Visual.rgbMode) {
251 Rcolor[0] = CLAMP(diffuseColor[0], 0.0F, 1.0F);
252 Rcolor[1] = CLAMP(diffuseColor[1], 0.0F, 1.0F);
253 Rcolor[2] = CLAMP(diffuseColor[2], 0.0F, 1.0F);
254 Rcolor[3] = CLAMP(diffuseColor[3], 0.0F, 1.0F);
255 Rspec[0] = CLAMP(specularColor[0], 0.0F, 1.0F);
256 Rspec[1] = CLAMP(specularColor[1], 0.0F, 1.0F);
257 Rspec[2] = CLAMP(specularColor[2], 0.0F, 1.0F);
258 Rspec[3] = CLAMP(specularColor[3], 0.0F, 1.0F);
259 }
260 else {
261 struct gl_material *mat = &ctx->Light.Material[0];
262 GLfloat d_a = mat->DiffuseIndex - mat->AmbientIndex;
263 GLfloat s_a = mat->SpecularIndex - mat->AmbientIndex;
264 GLfloat ind = mat->AmbientIndex
265 + diffuse * (1.0F-specular) * d_a
266 + specular * s_a;
267 if (ind > mat->SpecularIndex) {
268 ind = mat->SpecularIndex;
269 }
270 *Rindex = (GLuint) (GLint) ind;
271 }
272
273 }
274
275 /*
276 * Caller: context->API.RasterPos4f
277 */
278 static void
279 raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
280 {
281 GLfloat v[4], eye[4], clip[4], ndc[3], d;
282 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
283 FLUSH_CURRENT(ctx, 0);
284
285 if (ctx->NewState)
286 _mesa_update_state( ctx );
287
288 ASSIGN_4V( v, x, y, z, w );
289 TRANSFORM_POINT( eye, ctx->ModelviewMatrixStack.Top->m, v );
290
291 /* raster color */
292 if (ctx->Light.Enabled) {
293 GLfloat *norm, eyenorm[3];
294 GLfloat *objnorm = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
295
296 if (ctx->_NeedEyeCoords) {
297 GLfloat *inv = ctx->ModelviewMatrixStack.Top->inv;
298 TRANSFORM_NORMAL( eyenorm, objnorm, inv );
299 norm = eyenorm;
300 }
301 else {
302 norm = objnorm;
303 }
304
305 shade_rastpos( ctx, v, norm,
306 ctx->Current.RasterColor,
307 ctx->Current.RasterSecondaryColor,
308 &ctx->Current.RasterIndex );
309
310 }
311 else {
312 /* use current color or index */
313 if (ctx->Visual.rgbMode) {
314 COPY_4FV(ctx->Current.RasterColor,
315 ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
316 COPY_4FV(ctx->Current.RasterSecondaryColor,
317 ctx->Current.Attrib[VERT_ATTRIB_COLOR1]);
318 }
319 else {
320 ctx->Current.RasterIndex = ctx->Current.Index;
321 }
322 }
323
324 /* compute raster distance */
325 if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
326 ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0];
327 else
328 ctx->Current.RasterDistance = (GLfloat)
329 GL_SQRT( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] );
330
331 /* apply projection matrix: clip = Proj * eye */
332 TRANSFORM_POINT( clip, ctx->ProjectionMatrixStack.Top->m, eye );
333
334 /* clip to view volume */
335 if (ctx->Transform.RasterPositionUnclipped) {
336 /* GL_IBM_rasterpos_clip: only clip against Z */
337 if (viewclip_point_z(clip) == 0)
338 ctx->Current.RasterPosValid = GL_FALSE;
339 }
340 else if (viewclip_point(clip) == 0) {
341 /* Normal OpenGL behaviour */
342 ctx->Current.RasterPosValid = GL_FALSE;
343 return;
344 }
345
346 /* clip to user clipping planes */
347 if (ctx->Transform._AnyClip &&
348 userclip_point(ctx, clip) == 0) {
349 ctx->Current.RasterPosValid = GL_FALSE;
350 return;
351 }
352
353 /* ndc = clip / W */
354 ASSERT( clip[3]!=0.0 );
355 d = 1.0F / clip[3];
356 ndc[0] = clip[0] * d;
357 ndc[1] = clip[1] * d;
358 ndc[2] = clip[2] * d;
359
360 ctx->Current.RasterPos[0] = (ndc[0] * ctx->Viewport._WindowMap.m[MAT_SX] +
361 ctx->Viewport._WindowMap.m[MAT_TX]);
362 ctx->Current.RasterPos[1] = (ndc[1] * ctx->Viewport._WindowMap.m[MAT_SY] +
363 ctx->Viewport._WindowMap.m[MAT_TY]);
364 ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport._WindowMap.m[MAT_SZ] +
365 ctx->Viewport._WindowMap.m[MAT_TZ]) / ctx->DepthMaxF;
366 ctx->Current.RasterPos[3] = clip[3];
367 ctx->Current.RasterPosValid = GL_TRUE;
368
369 {
370 GLuint texSet;
371 for (texSet = 0; texSet < ctx->Const.MaxTextureUnits; texSet++) {
372 COPY_4FV( ctx->Current.RasterMultiTexCoord[texSet],
373 ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] );
374 }
375 }
376
377 if (ctx->RenderMode==GL_SELECT) {
378 _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] );
379 }
380
381 }
382
383
384 void
385 _mesa_RasterPos2d(GLdouble x, GLdouble y)
386 {
387 _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
388 }
389
390 void
391 _mesa_RasterPos2f(GLfloat x, GLfloat y)
392 {
393 _mesa_RasterPos4f(x, y, 0.0F, 1.0F);
394 }
395
396 void
397 _mesa_RasterPos2i(GLint x, GLint y)
398 {
399 _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
400 }
401
402 void
403 _mesa_RasterPos2s(GLshort x, GLshort y)
404 {
405 _mesa_RasterPos4f(x, y, 0.0F, 1.0F);
406 }
407
408 void
409 _mesa_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
410 {
411 _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
412 }
413
414 void
415 _mesa_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
416 {
417 _mesa_RasterPos4f(x, y, z, 1.0F);
418 }
419
420 void
421 _mesa_RasterPos3i(GLint x, GLint y, GLint z)
422 {
423 _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
424 }
425
426 void
427 _mesa_RasterPos3s(GLshort x, GLshort y, GLshort z)
428 {
429 _mesa_RasterPos4f(x, y, z, 1.0F);
430 }
431
432 void
433 _mesa_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
434 {
435 _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
436 }
437
438 void
439 _mesa_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
440 {
441 GET_CURRENT_CONTEXT(ctx);
442 raster_pos4f(ctx, x, y, z, w);
443 }
444
445 void
446 _mesa_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
447 {
448 _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
449 }
450
451 void
452 _mesa_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
453 {
454 _mesa_RasterPos4f(x, y, z, w);
455 }
456
457 void
458 _mesa_RasterPos2dv(const GLdouble *v)
459 {
460 _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
461 }
462
463 void
464 _mesa_RasterPos2fv(const GLfloat *v)
465 {
466 _mesa_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
467 }
468
469 void
470 _mesa_RasterPos2iv(const GLint *v)
471 {
472 _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
473 }
474
475 void
476 _mesa_RasterPos2sv(const GLshort *v)
477 {
478 _mesa_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
479 }
480
481 void
482 _mesa_RasterPos3dv(const GLdouble *v)
483 {
484 _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
485 }
486
487 void
488 _mesa_RasterPos3fv(const GLfloat *v)
489 {
490 _mesa_RasterPos4f(v[0], v[1], v[2], 1.0F);
491 }
492
493 void
494 _mesa_RasterPos3iv(const GLint *v)
495 {
496 _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
497 }
498
499 void
500 _mesa_RasterPos3sv(const GLshort *v)
501 {
502 _mesa_RasterPos4f(v[0], v[1], v[2], 1.0F);
503 }
504
505 void
506 _mesa_RasterPos4dv(const GLdouble *v)
507 {
508 _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
509 (GLfloat) v[2], (GLfloat) v[3]);
510 }
511
512 void
513 _mesa_RasterPos4fv(const GLfloat *v)
514 {
515 _mesa_RasterPos4f(v[0], v[1], v[2], v[3]);
516 }
517
518 void
519 _mesa_RasterPos4iv(const GLint *v)
520 {
521 _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
522 (GLfloat) v[2], (GLfloat) v[3]);
523 }
524
525 void
526 _mesa_RasterPos4sv(const GLshort *v)
527 {
528 _mesa_RasterPos4f(v[0], v[1], v[2], v[3]);
529 }
530
531
532 /**********************************************************************/
533 /*** GL_ARB_window_pos / GL_MESA_window_pos ***/
534 /**********************************************************************/
535
536 static void
537 window_pos3f(GLfloat x, GLfloat y, GLfloat z)
538 {
539 GET_CURRENT_CONTEXT(ctx);
540 GLfloat z2;
541
542 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
543 FLUSH_CURRENT(ctx, 0);
544
545 z2 = CLAMP(z, 0.0F, 1.0F) * (ctx->Viewport.Far - ctx->Viewport.Near)
546 + ctx->Viewport.Near;
547
548 /* set raster position */
549 ctx->Current.RasterPos[0] = x;
550 ctx->Current.RasterPos[1] = y;
551 ctx->Current.RasterPos[2] = z2;
552 ctx->Current.RasterPos[3] = 1.0F;
553
554 ctx->Current.RasterPosValid = GL_TRUE;
555
556 if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
557 ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0];
558 else
559 ctx->Current.RasterDistance = 0.0;
560
561 /* raster color = current color or index */
562 if (ctx->Visual.rgbMode) {
563 ctx->Current.RasterColor[0]
564 = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0], 0.0F, 1.0F);
565 ctx->Current.RasterColor[1]
566 = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1], 0.0F, 1.0F);
567 ctx->Current.RasterColor[2]
568 = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2], 0.0F, 1.0F);
569 ctx->Current.RasterColor[3]
570 = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3], 0.0F, 1.0F);
571 ctx->Current.RasterSecondaryColor[0]
572 = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0], 0.0F, 1.0F);
573 ctx->Current.RasterSecondaryColor[1]
574 = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1], 0.0F, 1.0F);
575 ctx->Current.RasterSecondaryColor[2]
576 = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2], 0.0F, 1.0F);
577 ctx->Current.RasterSecondaryColor[3]
578 = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3], 0.0F, 1.0F);
579 }
580 else {
581 ctx->Current.RasterIndex = ctx->Current.Index;
582 }
583
584 /* raster texcoord = current texcoord */
585 {
586 GLuint texSet;
587 for (texSet = 0; texSet < ctx->Const.MaxTextureUnits; texSet++) {
588 COPY_4FV( ctx->Current.RasterMultiTexCoord[texSet],
589 ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] );
590 }
591 }
592
593 if (ctx->RenderMode==GL_SELECT) {
594 _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] );
595 }
596 }
597
598
599 /* This is just to support the GL_MESA_window_pos version */
600 static void
601 window_pos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
602 {
603 GET_CURRENT_CONTEXT(ctx);
604 window_pos3f(x, y, z);
605 ctx->Current.RasterPos[3] = w;
606 }
607
608
609 void
610 _mesa_WindowPos2dMESA(GLdouble x, GLdouble y)
611 {
612 window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
613 }
614
615 void
616 _mesa_WindowPos2fMESA(GLfloat x, GLfloat y)
617 {
618 window_pos4f(x, y, 0.0F, 1.0F);
619 }
620
621 void
622 _mesa_WindowPos2iMESA(GLint x, GLint y)
623 {
624 window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
625 }
626
627 void
628 _mesa_WindowPos2sMESA(GLshort x, GLshort y)
629 {
630 window_pos4f(x, y, 0.0F, 1.0F);
631 }
632
633 void
634 _mesa_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
635 {
636 window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
637 }
638
639 void
640 _mesa_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
641 {
642 window_pos4f(x, y, z, 1.0F);
643 }
644
645 void
646 _mesa_WindowPos3iMESA(GLint x, GLint y, GLint z)
647 {
648 window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
649 }
650
651 void
652 _mesa_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
653 {
654 window_pos4f(x, y, z, 1.0F);
655 }
656
657 void
658 _mesa_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
659 {
660 window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
661 }
662
663 void
664 _mesa_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
665 {
666 window_pos4f(x, y, z, w);
667 }
668
669 void
670 _mesa_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
671 {
672 window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
673 }
674
675 void
676 _mesa_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
677 {
678 window_pos4f(x, y, z, w);
679 }
680
681 void
682 _mesa_WindowPos2dvMESA(const GLdouble *v)
683 {
684 window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
685 }
686
687 void
688 _mesa_WindowPos2fvMESA(const GLfloat *v)
689 {
690 window_pos4f(v[0], v[1], 0.0F, 1.0F);
691 }
692
693 void
694 _mesa_WindowPos2ivMESA(const GLint *v)
695 {
696 window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
697 }
698
699 void
700 _mesa_WindowPos2svMESA(const GLshort *v)
701 {
702 window_pos4f(v[0], v[1], 0.0F, 1.0F);
703 }
704
705 void
706 _mesa_WindowPos3dvMESA(const GLdouble *v)
707 {
708 window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
709 }
710
711 void
712 _mesa_WindowPos3fvMESA(const GLfloat *v)
713 {
714 window_pos4f(v[0], v[1], v[2], 1.0);
715 }
716
717 void
718 _mesa_WindowPos3ivMESA(const GLint *v)
719 {
720 window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
721 }
722
723 void
724 _mesa_WindowPos3svMESA(const GLshort *v)
725 {
726 window_pos4f(v[0], v[1], v[2], 1.0F);
727 }
728
729 void
730 _mesa_WindowPos4dvMESA(const GLdouble *v)
731 {
732 window_pos4f((GLfloat) v[0], (GLfloat) v[1],
733 (GLfloat) v[2], (GLfloat) v[3]);
734 }
735
736 void
737 _mesa_WindowPos4fvMESA(const GLfloat *v)
738 {
739 window_pos4f(v[0], v[1], v[2], v[3]);
740 }
741
742 void
743 _mesa_WindowPos4ivMESA(const GLint *v)
744 {
745 window_pos4f((GLfloat) v[0], (GLfloat) v[1],
746 (GLfloat) v[2], (GLfloat) v[3]);
747 }
748
749 void
750 _mesa_WindowPos4svMESA(const GLshort *v)
751 {
752 window_pos4f(v[0], v[1], v[2], v[3]);
753 }
754
755
756
757 #if 0
758
759 /*
760 * OpenGL implementation of glWindowPos*MESA()
761 */
762 void glWindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
763 {
764 GLfloat fx, fy;
765
766 /* Push current matrix mode and viewport attributes */
767 glPushAttrib( GL_TRANSFORM_BIT | GL_VIEWPORT_BIT );
768
769 /* Setup projection parameters */
770 glMatrixMode( GL_PROJECTION );
771 glPushMatrix();
772 glLoadIdentity();
773 glMatrixMode( GL_MODELVIEW );
774 glPushMatrix();
775 glLoadIdentity();
776
777 glDepthRange( z, z );
778 glViewport( (int) x - 1, (int) y - 1, 2, 2 );
779
780 /* set the raster (window) position */
781 fx = x - (int) x;
782 fy = y - (int) y;
783 glRasterPos4f( fx, fy, 0.0, w );
784
785 /* restore matrices, viewport and matrix mode */
786 glPopMatrix();
787 glMatrixMode( GL_PROJECTION );
788 glPopMatrix();
789
790 glPopAttrib();
791 }
792
793 #endif
794
795 void _mesa_WindowPos2dARB(GLdouble x, GLdouble y)
796 {
797 window_pos3f((GLfloat) x, (GLfloat) y, 0.0F);
798 }
799
800 void _mesa_WindowPos2fARB(GLfloat x, GLfloat y)
801 {
802 window_pos3f(x, y, 0.0F);
803 }
804
805 void _mesa_WindowPos2iARB(GLint x, GLint y)
806 {
807 window_pos3f((GLfloat) x, (GLfloat) y, 0.0F);
808 }
809
810 void _mesa_WindowPos2sARB(GLshort x, GLshort y)
811 {
812 window_pos3f((GLfloat) x, (GLfloat) y, 0.0F);
813 }
814
815 void _mesa_WindowPos2dvARB(const GLdouble *p)
816 {
817 window_pos3f((GLfloat) p[0], (GLfloat) p[1], 0.0F);
818 }
819
820 void _mesa_WindowPos2fvARB(const GLfloat *p)
821 {
822 window_pos3f((GLfloat) p[0], (GLfloat) p[1], 0.0F);
823 }
824
825 void _mesa_WindowPos2ivARB(const GLint *p)
826 {
827 window_pos3f((GLfloat) p[0], (GLfloat) p[1], 0.0F);
828 }
829
830 void _mesa_WindowPos2svARB(const GLshort *p)
831 {
832 window_pos3f((GLfloat) p[0], (GLfloat) p[1], 0.0F);
833 }
834
835 void _mesa_WindowPos3dARB(GLdouble x, GLdouble y, GLdouble z)
836 {
837 window_pos3f((GLfloat) x, (GLfloat) y, (GLfloat) z);
838 }
839
840 void _mesa_WindowPos3fARB(GLfloat x, GLfloat y, GLfloat z)
841 {
842 window_pos3f(x, y, z);
843 }
844
845 void _mesa_WindowPos3iARB(GLint x, GLint y, GLint z)
846 {
847 window_pos3f((GLfloat) x, (GLfloat) y, (GLfloat) z);
848 }
849
850 void _mesa_WindowPos3sARB(GLshort x, GLshort y, GLshort z)
851 {
852 window_pos3f((GLfloat) x, (GLfloat) y, (GLfloat) z);
853 }
854
855 void _mesa_WindowPos3dvARB(const GLdouble *p)
856 {
857 window_pos3f((GLfloat) p[0], (GLfloat) p[1], (GLfloat) p[2]);
858 }
859
860 void _mesa_WindowPos3fvARB(const GLfloat *p)
861 {
862 window_pos3f(p[0], p[1], p[2]);
863 }
864
865 void _mesa_WindowPos3ivARB(const GLint *p)
866 {
867 window_pos3f((GLfloat) p[0], (GLfloat) p[1], (GLfloat) p[2]);
868 }
869
870 void _mesa_WindowPos3svARB(const GLshort *p)
871 {
872 window_pos3f((GLfloat) p[0], (GLfloat) p[1], (GLfloat) p[2]);
873 }
874