1 /* $Id: rastpos.c,v 1.39 2002/10/24 23:57:21 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
38 #include "simple_list.h"
41 #include "math/m_matrix.h"
42 #include "math/m_xform.h"
46 * Clip a point against the view volume.
47 * Input: v - vertex-vector describing the point to clip
48 * Return: 0 = outside view volume
49 * 1 = inside view volume
52 viewclip_point( const GLfloat v
[] )
54 if ( v
[0] > v
[3] || v
[0] < -v
[3]
55 || v
[1] > v
[3] || v
[1] < -v
[3]
56 || v
[2] > v
[3] || v
[2] < -v
[3] ) {
65 /* As above, but only clip test against far/near Z planes */
67 viewclip_point_z( const GLfloat v
[] )
69 if (v
[2] > v
[3] || v
[2] < -v
[3] ) {
80 * Clip a point against the user clipping planes.
81 * Input: v - vertex-vector describing the point to clip.
82 * Return: 0 = point was clipped
83 * 1 = point not clipped
86 userclip_point( GLcontext
* ctx
, const GLfloat v
[] )
90 for (p
= 0; p
< ctx
->Const
.MaxClipPlanes
; p
++) {
91 if (ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) {
92 GLfloat dot
= v
[0] * ctx
->Transform
._ClipUserPlane
[p
][0]
93 + v
[1] * ctx
->Transform
._ClipUserPlane
[p
][1]
94 + v
[2] * ctx
->Transform
._ClipUserPlane
[p
][2]
95 + v
[3] * ctx
->Transform
._ClipUserPlane
[p
][3];
106 /* This has been split off to allow the normal shade routines to
107 * get a little closer to the vertex buffer, and to use the
108 * GLvector objects directly.
109 * Input: ctx - the context
110 * vertex - vertex location
111 * normal - normal vector
112 * Output: Rcolor - returned color
113 * Rspec - returned specular color (if separate specular enabled)
114 * Rindex - returned color index
117 shade_rastpos(GLcontext
*ctx
,
118 const GLfloat vertex
[4],
119 const GLfloat normal
[3],
124 GLfloat (*base
)[3] = ctx
->Light
._BaseColor
;
125 struct gl_light
*light
;
126 GLfloat diffuseColor
[4], specularColor
[4];
127 GLfloat diffuse
= 0, specular
= 0;
129 if (!ctx
->_ShineTable
[0] || !ctx
->_ShineTable
[1])
130 _mesa_validate_all_lighting_tables( ctx
);
132 COPY_3V(diffuseColor
, base
[0]);
133 diffuseColor
[3] = CLAMP( ctx
->Light
.Material
[0].Diffuse
[3], 0.0F
, 1.0F
);
134 ASSIGN_4V(specularColor
, 0.0, 0.0, 0.0, 0.0);
136 foreach (light
, &ctx
->Light
.EnabledList
) {
138 GLfloat attenuation
= 1.0;
142 GLfloat diffuseContrib
[3], specularContrib
[3];
143 GLboolean normalized
;
145 if (!(light
->_Flags
& LIGHT_POSITIONAL
)) {
146 COPY_3V(VP
, light
->_VP_inf_norm
);
147 attenuation
= light
->_VP_inf_spot_attenuation
;
152 SUB_3V(VP
, light
->_Position
, vertex
);
153 d
= (GLfloat
) LEN_3FV( VP
);
156 GLfloat invd
= 1.0F
/ d
;
157 SELF_SCALE_SCALAR_3V(VP
, invd
);
159 attenuation
= 1.0F
/ (light
->ConstantAttenuation
+ d
*
160 (light
->LinearAttenuation
+ d
*
161 light
->QuadraticAttenuation
));
163 if (light
->_Flags
& LIGHT_SPOT
) {
164 GLfloat PV_dot_dir
= - DOT3(VP
, light
->_NormDirection
);
166 if (PV_dot_dir
<light
->_CosCutoff
) {
170 double x
= PV_dot_dir
* (EXP_TABLE_SIZE
-1);
172 GLfloat spot
= (GLfloat
) (light
->_SpotExpTable
[k
][0]
173 + (x
-k
)*light
->_SpotExpTable
[k
][1]);
179 if (attenuation
< 1e-3)
182 n_dot_VP
= DOT3( normal
, VP
);
184 if (n_dot_VP
< 0.0F
) {
185 ACC_SCALE_SCALAR_3V(diffuseColor
, attenuation
, light
->_MatAmbient
[0]);
189 COPY_3V(diffuseContrib
, light
->_MatAmbient
[0]);
190 ACC_SCALE_SCALAR_3V(diffuseContrib
, n_dot_VP
, light
->_MatDiffuse
[0]);
191 diffuse
+= n_dot_VP
* light
->_dli
* attenuation
;
192 ASSIGN_3V(specularContrib
, 0.0, 0.0, 0.0);
195 if (ctx
->Light
.Model
.LocalViewer
) {
203 else if (light
->_Flags
& LIGHT_POSITIONAL
) {
205 ACC_3V(h
, ctx
->_EyeZDir
);
209 h
= light
->_h_inf_norm
;
213 n_dot_h
= DOT3(normal
, h
);
215 if (n_dot_h
> 0.0F
) {
216 const struct gl_material
*mat
= &ctx
->Light
.Material
[0];
218 GLfloat shininess
= mat
->Shininess
;
222 n_dot_h
/= LEN_SQUARED_3FV( h
);
226 GET_SHINE_TAB_ENTRY( ctx
->_ShineTable
[0], n_dot_h
, spec_coef
);
228 if (spec_coef
> 1.0e-10) {
229 if (ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
) {
230 ACC_SCALE_SCALAR_3V( specularContrib
, spec_coef
,
231 light
->_MatSpecular
[0]);
234 ACC_SCALE_SCALAR_3V( diffuseContrib
, spec_coef
,
235 light
->_MatSpecular
[0]);
237 specular
+= spec_coef
* light
->_sli
* attenuation
;
242 ACC_SCALE_SCALAR_3V( diffuseColor
, attenuation
, diffuseContrib
);
243 ACC_SCALE_SCALAR_3V( specularColor
, attenuation
, specularContrib
);
246 if (ctx
->Visual
.rgbMode
) {
247 Rcolor
[0] = CLAMP(diffuseColor
[0], 0.0F
, 1.0F
);
248 Rcolor
[1] = CLAMP(diffuseColor
[1], 0.0F
, 1.0F
);
249 Rcolor
[2] = CLAMP(diffuseColor
[2], 0.0F
, 1.0F
);
250 Rcolor
[3] = CLAMP(diffuseColor
[3], 0.0F
, 1.0F
);
251 Rspec
[0] = CLAMP(specularColor
[0], 0.0F
, 1.0F
);
252 Rspec
[1] = CLAMP(specularColor
[1], 0.0F
, 1.0F
);
253 Rspec
[2] = CLAMP(specularColor
[2], 0.0F
, 1.0F
);
254 Rspec
[3] = CLAMP(specularColor
[3], 0.0F
, 1.0F
);
257 struct gl_material
*mat
= &ctx
->Light
.Material
[0];
258 GLfloat d_a
= mat
->DiffuseIndex
- mat
->AmbientIndex
;
259 GLfloat s_a
= mat
->SpecularIndex
- mat
->AmbientIndex
;
260 GLfloat ind
= mat
->AmbientIndex
261 + diffuse
* (1.0F
-specular
) * d_a
263 if (ind
> mat
->SpecularIndex
) {
264 ind
= mat
->SpecularIndex
;
266 *Rindex
= (GLuint
) (GLint
) ind
;
272 * Caller: context->API.RasterPos4f
275 raster_pos4f(GLcontext
*ctx
, GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
277 GLfloat v
[4], eye
[4], clip
[4], ndc
[3], d
;
278 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
279 FLUSH_CURRENT(ctx
, 0);
282 _mesa_update_state( ctx
);
284 ASSIGN_4V( v
, x
, y
, z
, w
);
285 TRANSFORM_POINT( eye
, ctx
->ModelviewMatrixStack
.Top
->m
, v
);
288 if (ctx
->Light
.Enabled
) {
289 GLfloat
*norm
, eyenorm
[3];
290 GLfloat
*objnorm
= ctx
->Current
.Attrib
[VERT_ATTRIB_NORMAL
];
292 if (ctx
->_NeedEyeCoords
) {
293 GLfloat
*inv
= ctx
->ModelviewMatrixStack
.Top
->inv
;
294 TRANSFORM_NORMAL( eyenorm
, objnorm
, inv
);
301 shade_rastpos( ctx
, v
, norm
,
302 ctx
->Current
.RasterColor
,
303 ctx
->Current
.RasterSecondaryColor
,
304 &ctx
->Current
.RasterIndex
);
308 /* use current color or index */
309 if (ctx
->Visual
.rgbMode
) {
310 COPY_4FV(ctx
->Current
.RasterColor
,
311 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
]);
312 COPY_4FV(ctx
->Current
.RasterSecondaryColor
,
313 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
]);
316 ctx
->Current
.RasterIndex
= ctx
->Current
.Index
;
320 /* compute raster distance */
321 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
)
322 ctx
->Current
.RasterDistance
= ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0];
324 ctx
->Current
.RasterDistance
= (GLfloat
)
325 GL_SQRT( eye
[0]*eye
[0] + eye
[1]*eye
[1] + eye
[2]*eye
[2] );
327 /* apply projection matrix: clip = Proj * eye */
328 TRANSFORM_POINT( clip
, ctx
->ProjectionMatrixStack
.Top
->m
, eye
);
330 /* clip to view volume */
331 if (ctx
->Transform
.RasterPositionUnclipped
) {
332 /* GL_IBM_rasterpos_clip: only clip against Z */
333 if (viewclip_point_z(clip
) == 0)
334 ctx
->Current
.RasterPosValid
= GL_FALSE
;
336 else if (viewclip_point(clip
) == 0) {
337 /* Normal OpenGL behaviour */
338 ctx
->Current
.RasterPosValid
= GL_FALSE
;
342 /* clip to user clipping planes */
343 if (ctx
->Transform
.ClipPlanesEnabled
&& !userclip_point(ctx
, clip
)) {
344 ctx
->Current
.RasterPosValid
= GL_FALSE
;
349 ASSERT( clip
[3]!=0.0 );
351 ndc
[0] = clip
[0] * d
;
352 ndc
[1] = clip
[1] * d
;
353 ndc
[2] = clip
[2] * d
;
355 ctx
->Current
.RasterPos
[0] = (ndc
[0] * ctx
->Viewport
._WindowMap
.m
[MAT_SX
] +
356 ctx
->Viewport
._WindowMap
.m
[MAT_TX
]);
357 ctx
->Current
.RasterPos
[1] = (ndc
[1] * ctx
->Viewport
._WindowMap
.m
[MAT_SY
] +
358 ctx
->Viewport
._WindowMap
.m
[MAT_TY
]);
359 ctx
->Current
.RasterPos
[2] = (ndc
[2] * ctx
->Viewport
._WindowMap
.m
[MAT_SZ
] +
360 ctx
->Viewport
._WindowMap
.m
[MAT_TZ
]) / ctx
->DepthMaxF
;
361 ctx
->Current
.RasterPos
[3] = clip
[3];
362 ctx
->Current
.RasterPosValid
= GL_TRUE
;
366 for (texSet
= 0; texSet
< ctx
->Const
.MaxTextureUnits
; texSet
++) {
367 COPY_4FV( ctx
->Current
.RasterTexCoords
[texSet
],
368 ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ texSet
] );
372 if (ctx
->RenderMode
==GL_SELECT
) {
373 _mesa_update_hitflag( ctx
, ctx
->Current
.RasterPos
[2] );
380 _mesa_RasterPos2d(GLdouble x
, GLdouble y
)
382 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
386 _mesa_RasterPos2f(GLfloat x
, GLfloat y
)
388 _mesa_RasterPos4f(x
, y
, 0.0F
, 1.0F
);
392 _mesa_RasterPos2i(GLint x
, GLint y
)
394 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
398 _mesa_RasterPos2s(GLshort x
, GLshort y
)
400 _mesa_RasterPos4f(x
, y
, 0.0F
, 1.0F
);
404 _mesa_RasterPos3d(GLdouble x
, GLdouble y
, GLdouble z
)
406 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
410 _mesa_RasterPos3f(GLfloat x
, GLfloat y
, GLfloat z
)
412 _mesa_RasterPos4f(x
, y
, z
, 1.0F
);
416 _mesa_RasterPos3i(GLint x
, GLint y
, GLint z
)
418 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
422 _mesa_RasterPos3s(GLshort x
, GLshort y
, GLshort z
)
424 _mesa_RasterPos4f(x
, y
, z
, 1.0F
);
428 _mesa_RasterPos4d(GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
430 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
434 _mesa_RasterPos4f(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
436 GET_CURRENT_CONTEXT(ctx
);
437 raster_pos4f(ctx
, x
, y
, z
, w
);
441 _mesa_RasterPos4i(GLint x
, GLint y
, GLint z
, GLint w
)
443 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
447 _mesa_RasterPos4s(GLshort x
, GLshort y
, GLshort z
, GLshort w
)
449 _mesa_RasterPos4f(x
, y
, z
, w
);
453 _mesa_RasterPos2dv(const GLdouble
*v
)
455 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
459 _mesa_RasterPos2fv(const GLfloat
*v
)
461 _mesa_RasterPos4f(v
[0], v
[1], 0.0F
, 1.0F
);
465 _mesa_RasterPos2iv(const GLint
*v
)
467 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
471 _mesa_RasterPos2sv(const GLshort
*v
)
473 _mesa_RasterPos4f(v
[0], v
[1], 0.0F
, 1.0F
);
477 _mesa_RasterPos3dv(const GLdouble
*v
)
479 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
483 _mesa_RasterPos3fv(const GLfloat
*v
)
485 _mesa_RasterPos4f(v
[0], v
[1], v
[2], 1.0F
);
489 _mesa_RasterPos3iv(const GLint
*v
)
491 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
495 _mesa_RasterPos3sv(const GLshort
*v
)
497 _mesa_RasterPos4f(v
[0], v
[1], v
[2], 1.0F
);
501 _mesa_RasterPos4dv(const GLdouble
*v
)
503 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
504 (GLfloat
) v
[2], (GLfloat
) v
[3]);
508 _mesa_RasterPos4fv(const GLfloat
*v
)
510 _mesa_RasterPos4f(v
[0], v
[1], v
[2], v
[3]);
514 _mesa_RasterPos4iv(const GLint
*v
)
516 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
517 (GLfloat
) v
[2], (GLfloat
) v
[3]);
521 _mesa_RasterPos4sv(const GLshort
*v
)
523 _mesa_RasterPos4f(v
[0], v
[1], v
[2], v
[3]);
527 /**********************************************************************/
528 /*** GL_ARB_window_pos / GL_MESA_window_pos ***/
529 /**********************************************************************/
532 window_pos3f(GLfloat x
, GLfloat y
, GLfloat z
)
534 GET_CURRENT_CONTEXT(ctx
);
537 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
538 FLUSH_CURRENT(ctx
, 0);
540 z2
= CLAMP(z
, 0.0F
, 1.0F
) * (ctx
->Viewport
.Far
- ctx
->Viewport
.Near
)
541 + ctx
->Viewport
.Near
;
543 /* set raster position */
544 ctx
->Current
.RasterPos
[0] = x
;
545 ctx
->Current
.RasterPos
[1] = y
;
546 ctx
->Current
.RasterPos
[2] = z2
;
547 ctx
->Current
.RasterPos
[3] = 1.0F
;
549 ctx
->Current
.RasterPosValid
= GL_TRUE
;
551 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
)
552 ctx
->Current
.RasterDistance
= ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0];
554 ctx
->Current
.RasterDistance
= 0.0;
556 /* raster color = current color or index */
557 if (ctx
->Visual
.rgbMode
) {
558 ctx
->Current
.RasterColor
[0]
559 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][0], 0.0F
, 1.0F
);
560 ctx
->Current
.RasterColor
[1]
561 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][1], 0.0F
, 1.0F
);
562 ctx
->Current
.RasterColor
[2]
563 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][2], 0.0F
, 1.0F
);
564 ctx
->Current
.RasterColor
[3]
565 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][3], 0.0F
, 1.0F
);
566 ctx
->Current
.RasterSecondaryColor
[0]
567 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][0], 0.0F
, 1.0F
);
568 ctx
->Current
.RasterSecondaryColor
[1]
569 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][1], 0.0F
, 1.0F
);
570 ctx
->Current
.RasterSecondaryColor
[2]
571 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][2], 0.0F
, 1.0F
);
572 ctx
->Current
.RasterSecondaryColor
[3]
573 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][3], 0.0F
, 1.0F
);
576 ctx
->Current
.RasterIndex
= ctx
->Current
.Index
;
579 /* raster texcoord = current texcoord */
582 for (texSet
= 0; texSet
< ctx
->Const
.MaxTextureUnits
; texSet
++) {
583 COPY_4FV( ctx
->Current
.RasterTexCoords
[texSet
],
584 ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ texSet
] );
588 if (ctx
->RenderMode
==GL_SELECT
) {
589 _mesa_update_hitflag( ctx
, ctx
->Current
.RasterPos
[2] );
594 /* This is just to support the GL_MESA_window_pos version */
596 window_pos4f(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
598 GET_CURRENT_CONTEXT(ctx
);
599 window_pos3f(x
, y
, z
);
600 ctx
->Current
.RasterPos
[3] = w
;
605 _mesa_WindowPos2dMESA(GLdouble x
, GLdouble y
)
607 window_pos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
611 _mesa_WindowPos2fMESA(GLfloat x
, GLfloat y
)
613 window_pos4f(x
, y
, 0.0F
, 1.0F
);
617 _mesa_WindowPos2iMESA(GLint x
, GLint y
)
619 window_pos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
623 _mesa_WindowPos2sMESA(GLshort x
, GLshort y
)
625 window_pos4f(x
, y
, 0.0F
, 1.0F
);
629 _mesa_WindowPos3dMESA(GLdouble x
, GLdouble y
, GLdouble z
)
631 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
635 _mesa_WindowPos3fMESA(GLfloat x
, GLfloat y
, GLfloat z
)
637 window_pos4f(x
, y
, z
, 1.0F
);
641 _mesa_WindowPos3iMESA(GLint x
, GLint y
, GLint z
)
643 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
647 _mesa_WindowPos3sMESA(GLshort x
, GLshort y
, GLshort z
)
649 window_pos4f(x
, y
, z
, 1.0F
);
653 _mesa_WindowPos4dMESA(GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
655 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
659 _mesa_WindowPos4fMESA(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
661 window_pos4f(x
, y
, z
, w
);
665 _mesa_WindowPos4iMESA(GLint x
, GLint y
, GLint z
, GLint w
)
667 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
671 _mesa_WindowPos4sMESA(GLshort x
, GLshort y
, GLshort z
, GLshort w
)
673 window_pos4f(x
, y
, z
, w
);
677 _mesa_WindowPos2dvMESA(const GLdouble
*v
)
679 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
683 _mesa_WindowPos2fvMESA(const GLfloat
*v
)
685 window_pos4f(v
[0], v
[1], 0.0F
, 1.0F
);
689 _mesa_WindowPos2ivMESA(const GLint
*v
)
691 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
695 _mesa_WindowPos2svMESA(const GLshort
*v
)
697 window_pos4f(v
[0], v
[1], 0.0F
, 1.0F
);
701 _mesa_WindowPos3dvMESA(const GLdouble
*v
)
703 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
707 _mesa_WindowPos3fvMESA(const GLfloat
*v
)
709 window_pos4f(v
[0], v
[1], v
[2], 1.0);
713 _mesa_WindowPos3ivMESA(const GLint
*v
)
715 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
719 _mesa_WindowPos3svMESA(const GLshort
*v
)
721 window_pos4f(v
[0], v
[1], v
[2], 1.0F
);
725 _mesa_WindowPos4dvMESA(const GLdouble
*v
)
727 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
728 (GLfloat
) v
[2], (GLfloat
) v
[3]);
732 _mesa_WindowPos4fvMESA(const GLfloat
*v
)
734 window_pos4f(v
[0], v
[1], v
[2], v
[3]);
738 _mesa_WindowPos4ivMESA(const GLint
*v
)
740 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
741 (GLfloat
) v
[2], (GLfloat
) v
[3]);
745 _mesa_WindowPos4svMESA(const GLshort
*v
)
747 window_pos4f(v
[0], v
[1], v
[2], v
[3]);
755 * OpenGL implementation of glWindowPos*MESA()
757 void glWindowPos4fMESA( GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
761 /* Push current matrix mode and viewport attributes */
762 glPushAttrib( GL_TRANSFORM_BIT
| GL_VIEWPORT_BIT
);
764 /* Setup projection parameters */
765 glMatrixMode( GL_PROJECTION
);
768 glMatrixMode( GL_MODELVIEW
);
772 glDepthRange( z
, z
);
773 glViewport( (int) x
- 1, (int) y
- 1, 2, 2 );
775 /* set the raster (window) position */
778 glRasterPos4f( fx
, fy
, 0.0, w
);
780 /* restore matrices, viewport and matrix mode */
782 glMatrixMode( GL_PROJECTION
);