2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
28 * Raster position operations.
38 #include "main/dispatch.h"
39 #include "main/viewport.h"
40 #include "util/bitscan.h"
45 * Clip a point against the view volume.
47 * \param v vertex vector describing the point to clip.
49 * \return zero if outside view volume, or one if inside.
52 viewclip_point_xy( const GLfloat v
[] )
54 if ( v
[0] > v
[3] || v
[0] < -v
[3]
55 || v
[1] > v
[3] || v
[1] < -v
[3] ) {
65 * Clip a point against the far/near Z clipping planes.
67 * \param v vertex vector describing the point to clip.
69 * \return zero if outside view volume, or one if inside.
72 viewclip_point_z( const GLfloat v
[] )
74 if (v
[2] > v
[3] || v
[2] < -v
[3] ) {
84 * Clip a point against the user clipping planes.
86 * \param ctx GL context.
87 * \param v vertex vector describing the point to clip.
89 * \return zero if the point was clipped, or one otherwise.
92 userclip_point( struct gl_context
*ctx
, const GLfloat v
[] )
94 GLbitfield mask
= ctx
->Transform
.ClipPlanesEnabled
;
96 const int p
= u_bit_scan(&mask
);
97 GLfloat dot
= v
[0] * ctx
->Transform
._ClipUserPlane
[p
][0]
98 + v
[1] * ctx
->Transform
._ClipUserPlane
[p
][1]
99 + v
[2] * ctx
->Transform
._ClipUserPlane
[p
][2]
100 + v
[3] * ctx
->Transform
._ClipUserPlane
[p
][3];
112 * Compute lighting for the raster position. RGB modes computed.
113 * \param ctx the context
114 * \param vertex vertex location
115 * \param normal normal vector
116 * \param Rcolor returned color
117 * \param Rspec returned specular color (if separate specular enabled)
120 shade_rastpos(struct gl_context
*ctx
,
121 const GLfloat vertex
[4],
122 const GLfloat normal
[3],
126 /*const*/ GLfloat (*base
)[3] = ctx
->Light
._BaseColor
;
128 GLfloat diffuseColor
[4], specularColor
[4]; /* for RGB mode only */
130 COPY_3V(diffuseColor
, base
[0]);
131 diffuseColor
[3] = CLAMP(
132 ctx
->Light
.Material
.Attrib
[MAT_ATTRIB_FRONT_DIFFUSE
][3], 0.0F
, 1.0F
);
133 ASSIGN_4V(specularColor
, 0.0, 0.0, 0.0, 1.0);
135 mask
= ctx
->Light
._EnabledLights
;
137 const int i
= u_bit_scan(&mask
);
138 struct gl_light
*light
= &ctx
->Light
.Light
[i
];
139 GLfloat attenuation
= 1.0;
140 GLfloat VP
[3]; /* vector from vertex to light pos */
142 GLfloat diffuseContrib
[3], specularContrib
[3];
144 if (!(light
->_Flags
& LIGHT_POSITIONAL
)) {
145 /* light at infinity */
146 COPY_3V(VP
, light
->_VP_inf_norm
);
147 attenuation
= light
->_VP_inf_spot_attenuation
;
150 /* local/positional light */
153 /* VP = vector from vertex pos to light[i].pos */
154 SUB_3V(VP
, light
->_Position
, vertex
);
156 d
= (GLfloat
) LEN_3FV( VP
);
159 GLfloat invd
= 1.0F
/ d
;
160 SELF_SCALE_SCALAR_3V(VP
, invd
);
164 attenuation
= 1.0F
/ (light
->ConstantAttenuation
+ d
*
165 (light
->LinearAttenuation
+ d
*
166 light
->QuadraticAttenuation
));
168 if (light
->_Flags
& LIGHT_SPOT
) {
169 GLfloat PV_dot_dir
= - DOT3(VP
, light
->_NormSpotDirection
);
171 if (PV_dot_dir
<light
->_CosCutoff
) {
175 GLfloat spot
= powf(PV_dot_dir
, light
->SpotExponent
);
181 if (attenuation
< 1e-3F
)
184 n_dot_VP
= DOT3( normal
, VP
);
186 if (n_dot_VP
< 0.0F
) {
187 ACC_SCALE_SCALAR_3V(diffuseColor
, attenuation
, light
->_MatAmbient
[0]);
191 /* Ambient + diffuse */
192 COPY_3V(diffuseContrib
, light
->_MatAmbient
[0]);
193 ACC_SCALE_SCALAR_3V(diffuseContrib
, n_dot_VP
, light
->_MatDiffuse
[0]);
200 ASSIGN_3V(specularContrib
, 0.0, 0.0, 0.0);
202 if (ctx
->Light
.Model
.LocalViewer
) {
210 else if (light
->_Flags
& LIGHT_POSITIONAL
) {
211 ACC_3V(VP
, ctx
->_EyeZDir
);
216 h
= light
->_h_inf_norm
;
219 n_dot_h
= DOT3(normal
, h
);
221 if (n_dot_h
> 0.0F
) {
225 shine
= ctx
->Light
.Material
.Attrib
[MAT_ATTRIB_FRONT_SHININESS
][0];
226 spec_coef
= powf(n_dot_h
, shine
);
228 if (spec_coef
> 1.0e-10F
) {
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]);
241 ACC_SCALE_SCALAR_3V( diffuseColor
, attenuation
, diffuseContrib
);
242 ACC_SCALE_SCALAR_3V( specularColor
, attenuation
, specularContrib
);
245 Rcolor
[0] = CLAMP(diffuseColor
[0], 0.0F
, 1.0F
);
246 Rcolor
[1] = CLAMP(diffuseColor
[1], 0.0F
, 1.0F
);
247 Rcolor
[2] = CLAMP(diffuseColor
[2], 0.0F
, 1.0F
);
248 Rcolor
[3] = CLAMP(diffuseColor
[3], 0.0F
, 1.0F
);
249 Rspec
[0] = CLAMP(specularColor
[0], 0.0F
, 1.0F
);
250 Rspec
[1] = CLAMP(specularColor
[1], 0.0F
, 1.0F
);
251 Rspec
[2] = CLAMP(specularColor
[2], 0.0F
, 1.0F
);
252 Rspec
[3] = CLAMP(specularColor
[3], 0.0F
, 1.0F
);
257 * Do texgen needed for glRasterPos.
258 * \param ctx rendering context
259 * \param vObj object-space vertex coordinate
260 * \param vEye eye-space vertex coordinate
261 * \param normal vertex normal
262 * \param unit texture unit number
263 * \param texcoord incoming texcoord and resulting texcoord
266 compute_texgen(struct gl_context
*ctx
, const GLfloat vObj
[4], const GLfloat vEye
[4],
267 const GLfloat normal
[3], GLuint unit
, GLfloat texcoord
[4])
269 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
271 /* always compute sphere map terms, just in case */
272 GLfloat u
[3], two_nu
, rx
, ry
, rz
, m
, mInv
;
275 two_nu
= 2.0F
* DOT3(normal
, u
);
276 rx
= u
[0] - normal
[0] * two_nu
;
277 ry
= u
[1] - normal
[1] * two_nu
;
278 rz
= u
[2] - normal
[2] * two_nu
;
279 m
= rx
* rx
+ ry
* ry
+ (rz
+ 1.0F
) * (rz
+ 1.0F
);
281 mInv
= 0.5F
* (1.0f
/ sqrtf(m
));
285 if (texUnit
->TexGenEnabled
& S_BIT
) {
286 switch (texUnit
->GenS
.Mode
) {
287 case GL_OBJECT_LINEAR
:
288 texcoord
[0] = DOT4(vObj
, texUnit
->GenS
.ObjectPlane
);
291 texcoord
[0] = DOT4(vEye
, texUnit
->GenS
.EyePlane
);
294 texcoord
[0] = rx
* mInv
+ 0.5F
;
296 case GL_REFLECTION_MAP
:
300 texcoord
[0] = normal
[0];
303 _mesa_problem(ctx
, "Bad S texgen in compute_texgen()");
308 if (texUnit
->TexGenEnabled
& T_BIT
) {
309 switch (texUnit
->GenT
.Mode
) {
310 case GL_OBJECT_LINEAR
:
311 texcoord
[1] = DOT4(vObj
, texUnit
->GenT
.ObjectPlane
);
314 texcoord
[1] = DOT4(vEye
, texUnit
->GenT
.EyePlane
);
317 texcoord
[1] = ry
* mInv
+ 0.5F
;
319 case GL_REFLECTION_MAP
:
323 texcoord
[1] = normal
[1];
326 _mesa_problem(ctx
, "Bad T texgen in compute_texgen()");
331 if (texUnit
->TexGenEnabled
& R_BIT
) {
332 switch (texUnit
->GenR
.Mode
) {
333 case GL_OBJECT_LINEAR
:
334 texcoord
[2] = DOT4(vObj
, texUnit
->GenR
.ObjectPlane
);
337 texcoord
[2] = DOT4(vEye
, texUnit
->GenR
.EyePlane
);
339 case GL_REFLECTION_MAP
:
343 texcoord
[2] = normal
[2];
346 _mesa_problem(ctx
, "Bad R texgen in compute_texgen()");
351 if (texUnit
->TexGenEnabled
& Q_BIT
) {
352 switch (texUnit
->GenQ
.Mode
) {
353 case GL_OBJECT_LINEAR
:
354 texcoord
[3] = DOT4(vObj
, texUnit
->GenQ
.ObjectPlane
);
357 texcoord
[3] = DOT4(vEye
, texUnit
->GenQ
.EyePlane
);
360 _mesa_problem(ctx
, "Bad Q texgen in compute_texgen()");
368 * glRasterPos transformation. Typically called via ctx->Driver.RasterPos().
370 * \param vObj vertex position in object space
373 _mesa_RasterPos(struct gl_context
*ctx
, const GLfloat vObj
[4])
375 if (_mesa_arb_vertex_program_enabled(ctx
)) {
376 /* XXX implement this */
377 _mesa_problem(ctx
, "Vertex programs not implemented for glRasterPos");
381 GLfloat eye
[4], clip
[4], ndc
[3], d
;
382 GLfloat
*norm
, eyenorm
[3];
383 GLfloat
*objnorm
= ctx
->Current
.Attrib
[VERT_ATTRIB_NORMAL
];
384 float scale
[3], translate
[3];
386 /* apply modelview matrix: eye = MV * obj */
387 TRANSFORM_POINT( eye
, ctx
->ModelviewMatrixStack
.Top
->m
, vObj
);
388 /* apply projection matrix: clip = Proj * eye */
389 TRANSFORM_POINT( clip
, ctx
->ProjectionMatrixStack
.Top
->m
, eye
);
391 /* clip to view volume. */
392 if (!ctx
->Transform
.DepthClamp
) {
393 if (viewclip_point_z(clip
) == 0) {
394 ctx
->Current
.RasterPosValid
= GL_FALSE
;
398 if (!ctx
->Transform
.RasterPositionUnclipped
) {
399 if (viewclip_point_xy(clip
) == 0) {
400 ctx
->Current
.RasterPosValid
= GL_FALSE
;
405 /* clip to user clipping planes */
406 if (ctx
->Transform
.ClipPlanesEnabled
&& !userclip_point(ctx
, clip
)) {
407 ctx
->Current
.RasterPosValid
= GL_FALSE
;
412 d
= (clip
[3] == 0.0F
) ? 1.0F
: 1.0F
/ clip
[3];
413 ndc
[0] = clip
[0] * d
;
414 ndc
[1] = clip
[1] * d
;
415 ndc
[2] = clip
[2] * d
;
416 /* wincoord = viewport_mapping(ndc) */
417 _mesa_get_viewport_xform(ctx
, 0, scale
, translate
);
418 ctx
->Current
.RasterPos
[0] = ndc
[0] * scale
[0] + translate
[0];
419 ctx
->Current
.RasterPos
[1] = ndc
[1] * scale
[1] + translate
[1];
420 ctx
->Current
.RasterPos
[2] = ndc
[2] * scale
[2] + translate
[2];
421 ctx
->Current
.RasterPos
[3] = clip
[3];
423 if (ctx
->Transform
.DepthClamp
) {
424 ctx
->Current
.RasterPos
[3] = CLAMP(ctx
->Current
.RasterPos
[3],
425 ctx
->ViewportArray
[0].Near
,
426 ctx
->ViewportArray
[0].Far
);
429 /* compute raster distance */
430 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
)
431 ctx
->Current
.RasterDistance
= ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0];
433 ctx
->Current
.RasterDistance
=
434 sqrtf( eye
[0]*eye
[0] + eye
[1]*eye
[1] + eye
[2]*eye
[2] );
436 /* compute transformed normal vector (for lighting or texgen) */
437 if (ctx
->_NeedEyeCoords
) {
438 const GLfloat
*inv
= ctx
->ModelviewMatrixStack
.Top
->inv
;
439 TRANSFORM_NORMAL( eyenorm
, objnorm
, inv
);
446 /* update raster color */
447 if (ctx
->Light
.Enabled
) {
449 shade_rastpos( ctx
, vObj
, norm
,
450 ctx
->Current
.RasterColor
,
451 ctx
->Current
.RasterSecondaryColor
);
454 /* use current color */
455 COPY_4FV(ctx
->Current
.RasterColor
,
456 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
]);
457 COPY_4FV(ctx
->Current
.RasterSecondaryColor
,
458 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
]);
464 for (u
= 0; u
< ctx
->Const
.MaxTextureCoordUnits
; u
++) {
466 COPY_4V(tc
, ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ u
]);
467 if (ctx
->Texture
.Unit
[u
].TexGenEnabled
) {
468 compute_texgen(ctx
, vObj
, eye
, norm
, u
, tc
);
470 TRANSFORM_POINT(ctx
->Current
.RasterTexCoords
[u
],
471 ctx
->TextureMatrixStack
[u
].Top
->m
, tc
);
475 ctx
->Current
.RasterPosValid
= GL_TRUE
;
478 if (ctx
->RenderMode
== GL_SELECT
) {
479 _mesa_update_hitflag( ctx
, ctx
->Current
.RasterPos
[2] );
485 * Helper function for all the RasterPos functions.
488 rasterpos(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
490 GET_CURRENT_CONTEXT(ctx
);
498 FLUSH_VERTICES(ctx
, 0);
499 FLUSH_CURRENT(ctx
, 0);
502 _mesa_update_state( ctx
);
504 ctx
->Driver
.RasterPos(ctx
, p
);
509 _mesa_RasterPos2d(GLdouble x
, GLdouble y
)
511 rasterpos((GLfloat
)x
, (GLfloat
)y
, (GLfloat
)0.0, (GLfloat
)1.0);
515 _mesa_RasterPos2f(GLfloat x
, GLfloat y
)
517 rasterpos(x
, y
, 0.0F
, 1.0F
);
521 _mesa_RasterPos2i(GLint x
, GLint y
)
523 rasterpos((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
527 _mesa_RasterPos2s(GLshort x
, GLshort y
)
529 rasterpos(x
, y
, 0.0F
, 1.0F
);
533 _mesa_RasterPos3d(GLdouble x
, GLdouble y
, GLdouble z
)
535 rasterpos((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
539 _mesa_RasterPos3f(GLfloat x
, GLfloat y
, GLfloat z
)
541 rasterpos(x
, y
, z
, 1.0F
);
545 _mesa_RasterPos3i(GLint x
, GLint y
, GLint z
)
547 rasterpos((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
551 _mesa_RasterPos3s(GLshort x
, GLshort y
, GLshort z
)
553 rasterpos(x
, y
, z
, 1.0F
);
557 _mesa_RasterPos4d(GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
559 rasterpos((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
563 _mesa_RasterPos4f(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
565 rasterpos(x
, y
, z
, w
);
569 _mesa_RasterPos4i(GLint x
, GLint y
, GLint z
, GLint w
)
571 rasterpos((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
575 _mesa_RasterPos4s(GLshort x
, GLshort y
, GLshort z
, GLshort w
)
577 rasterpos(x
, y
, z
, w
);
581 _mesa_RasterPos2dv(const GLdouble
*v
)
583 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
587 _mesa_RasterPos2fv(const GLfloat
*v
)
589 rasterpos(v
[0], v
[1], 0.0F
, 1.0F
);
593 _mesa_RasterPos2iv(const GLint
*v
)
595 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
599 _mesa_RasterPos2sv(const GLshort
*v
)
601 rasterpos(v
[0], v
[1], 0.0F
, 1.0F
);
605 _mesa_RasterPos3dv(const GLdouble
*v
)
607 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
611 _mesa_RasterPos3fv(const GLfloat
*v
)
613 rasterpos(v
[0], v
[1], v
[2], 1.0F
);
617 _mesa_RasterPos3iv(const GLint
*v
)
619 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
623 _mesa_RasterPos3sv(const GLshort
*v
)
625 rasterpos(v
[0], v
[1], v
[2], 1.0F
);
629 _mesa_RasterPos4dv(const GLdouble
*v
)
631 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1],
632 (GLfloat
) v
[2], (GLfloat
) v
[3]);
636 _mesa_RasterPos4fv(const GLfloat
*v
)
638 rasterpos(v
[0], v
[1], v
[2], v
[3]);
642 _mesa_RasterPos4iv(const GLint
*v
)
644 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1],
645 (GLfloat
) v
[2], (GLfloat
) v
[3]);
649 _mesa_RasterPos4sv(const GLshort
*v
)
651 rasterpos(v
[0], v
[1], v
[2], v
[3]);
655 /**********************************************************************/
656 /*** GL_ARB_window_pos / GL_MESA_window_pos ***/
657 /**********************************************************************/
661 * All glWindowPosMESA and glWindowPosARB commands call this function to
662 * update the current raster position.
665 window_pos3f(GLfloat x
, GLfloat y
, GLfloat z
)
667 GET_CURRENT_CONTEXT(ctx
);
670 FLUSH_VERTICES(ctx
, 0);
671 FLUSH_CURRENT(ctx
, 0);
673 z2
= CLAMP(z
, 0.0F
, 1.0F
)
674 * (ctx
->ViewportArray
[0].Far
- ctx
->ViewportArray
[0].Near
)
675 + ctx
->ViewportArray
[0].Near
;
677 /* set raster position */
678 ctx
->Current
.RasterPos
[0] = x
;
679 ctx
->Current
.RasterPos
[1] = y
;
680 ctx
->Current
.RasterPos
[2] = z2
;
681 ctx
->Current
.RasterPos
[3] = 1.0F
;
683 ctx
->Current
.RasterPosValid
= GL_TRUE
;
685 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
)
686 ctx
->Current
.RasterDistance
= ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0];
688 ctx
->Current
.RasterDistance
= 0.0;
690 /* raster color = current color or index */
691 ctx
->Current
.RasterColor
[0]
692 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][0], 0.0F
, 1.0F
);
693 ctx
->Current
.RasterColor
[1]
694 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][1], 0.0F
, 1.0F
);
695 ctx
->Current
.RasterColor
[2]
696 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][2], 0.0F
, 1.0F
);
697 ctx
->Current
.RasterColor
[3]
698 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][3], 0.0F
, 1.0F
);
699 ctx
->Current
.RasterSecondaryColor
[0]
700 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][0], 0.0F
, 1.0F
);
701 ctx
->Current
.RasterSecondaryColor
[1]
702 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][1], 0.0F
, 1.0F
);
703 ctx
->Current
.RasterSecondaryColor
[2]
704 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][2], 0.0F
, 1.0F
);
705 ctx
->Current
.RasterSecondaryColor
[3]
706 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][3], 0.0F
, 1.0F
);
708 /* raster texcoord = current texcoord */
711 for (texSet
= 0; texSet
< ctx
->Const
.MaxTextureCoordUnits
; texSet
++) {
712 assert(texSet
< ARRAY_SIZE(ctx
->Current
.RasterTexCoords
));
713 COPY_4FV( ctx
->Current
.RasterTexCoords
[texSet
],
714 ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ texSet
] );
718 if (ctx
->RenderMode
==GL_SELECT
) {
719 _mesa_update_hitflag( ctx
, ctx
->Current
.RasterPos
[2] );
724 /* This is just to support the GL_MESA_window_pos version */
726 window_pos4f(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
728 GET_CURRENT_CONTEXT(ctx
);
729 window_pos3f(x
, y
, z
);
730 ctx
->Current
.RasterPos
[3] = w
;
735 _mesa_WindowPos2d(GLdouble x
, GLdouble y
)
737 window_pos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
741 _mesa_WindowPos2f(GLfloat x
, GLfloat y
)
743 window_pos4f(x
, y
, 0.0F
, 1.0F
);
747 _mesa_WindowPos2i(GLint x
, GLint y
)
749 window_pos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
753 _mesa_WindowPos2s(GLshort x
, GLshort y
)
755 window_pos4f(x
, y
, 0.0F
, 1.0F
);
759 _mesa_WindowPos3d(GLdouble x
, GLdouble y
, GLdouble z
)
761 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
765 _mesa_WindowPos3f(GLfloat x
, GLfloat y
, GLfloat z
)
767 window_pos4f(x
, y
, z
, 1.0F
);
771 _mesa_WindowPos3i(GLint x
, GLint y
, GLint z
)
773 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
777 _mesa_WindowPos3s(GLshort x
, GLshort y
, GLshort z
)
779 window_pos4f(x
, y
, z
, 1.0F
);
783 _mesa_WindowPos4dMESA(GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
785 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
789 _mesa_WindowPos4fMESA(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
791 window_pos4f(x
, y
, z
, w
);
795 _mesa_WindowPos4iMESA(GLint x
, GLint y
, GLint z
, GLint w
)
797 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
801 _mesa_WindowPos4sMESA(GLshort x
, GLshort y
, GLshort z
, GLshort w
)
803 window_pos4f(x
, y
, z
, w
);
807 _mesa_WindowPos2dv(const GLdouble
*v
)
809 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
813 _mesa_WindowPos2fv(const GLfloat
*v
)
815 window_pos4f(v
[0], v
[1], 0.0F
, 1.0F
);
819 _mesa_WindowPos2iv(const GLint
*v
)
821 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
825 _mesa_WindowPos2sv(const GLshort
*v
)
827 window_pos4f(v
[0], v
[1], 0.0F
, 1.0F
);
831 _mesa_WindowPos3dv(const GLdouble
*v
)
833 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
837 _mesa_WindowPos3fv(const GLfloat
*v
)
839 window_pos4f(v
[0], v
[1], v
[2], 1.0);
843 _mesa_WindowPos3iv(const GLint
*v
)
845 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
849 _mesa_WindowPos3sv(const GLshort
*v
)
851 window_pos4f(v
[0], v
[1], v
[2], 1.0F
);
855 _mesa_WindowPos4dvMESA(const GLdouble
*v
)
857 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
858 (GLfloat
) v
[2], (GLfloat
) v
[3]);
862 _mesa_WindowPos4fvMESA(const GLfloat
*v
)
864 window_pos4f(v
[0], v
[1], v
[2], v
[3]);
868 _mesa_WindowPos4ivMESA(const GLint
*v
)
870 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
871 (GLfloat
) v
[2], (GLfloat
) v
[3]);
875 _mesa_WindowPos4svMESA(const GLshort
*v
)
877 window_pos4f(v
[0], v
[1], v
[2], v
[3]);
884 * OpenGL implementation of glWindowPos*MESA()
886 void glWindowPos4fMESA( GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
890 /* Push current matrix mode and viewport attributes */
891 glPushAttrib( GL_TRANSFORM_BIT
| GL_VIEWPORT_BIT
);
893 /* Setup projection parameters */
894 glMatrixMode( GL_PROJECTION
);
897 glMatrixMode( GL_MODELVIEW
);
901 glDepthRange( z
, z
);
902 glViewport( (int) x
- 1, (int) y
- 1, 2, 2 );
904 /* set the raster (window) position */
907 glRasterPos4f( fx
, fy
, 0.0, w
);
909 /* restore matrices, viewport and matrix mode */
911 glMatrixMode( GL_PROJECTION
);
920 /**********************************************************************/
921 /** \name Initialization */
922 /**********************************************************************/
926 * Initialize the context current raster position information.
928 * \param ctx GL context.
930 * Initialize the current raster position information in
931 * __struct gl_contextRec::Current, and adds the extension entry points to the
934 void _mesa_init_rastpos( struct gl_context
* ctx
)
938 ASSIGN_4V( ctx
->Current
.RasterPos
, 0.0, 0.0, 0.0, 1.0 );
939 ctx
->Current
.RasterDistance
= 0.0;
940 ASSIGN_4V( ctx
->Current
.RasterColor
, 1.0, 1.0, 1.0, 1.0 );
941 ASSIGN_4V( ctx
->Current
.RasterSecondaryColor
, 0.0, 0.0, 0.0, 1.0 );
942 for (i
= 0; i
< ARRAY_SIZE(ctx
->Current
.RasterTexCoords
); i
++)
943 ASSIGN_4V( ctx
->Current
.RasterTexCoords
[i
], 0.0, 0.0, 0.0, 1.0 );
944 ctx
->Current
.RasterPosValid
= GL_TRUE
;