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/simple_list.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
[] )
96 for (p
= 0; p
< ctx
->Const
.MaxClipPlanes
; p
++) {
97 if (ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) {
98 GLfloat dot
= v
[0] * ctx
->Transform
._ClipUserPlane
[p
][0]
99 + v
[1] * ctx
->Transform
._ClipUserPlane
[p
][1]
100 + v
[2] * ctx
->Transform
._ClipUserPlane
[p
][2]
101 + v
[3] * ctx
->Transform
._ClipUserPlane
[p
][3];
113 * Compute lighting for the raster position. RGB modes computed.
114 * \param ctx the context
115 * \param vertex vertex location
116 * \param normal normal vector
117 * \param Rcolor returned color
118 * \param Rspec returned specular color (if separate specular enabled)
121 shade_rastpos(struct gl_context
*ctx
,
122 const GLfloat vertex
[4],
123 const GLfloat normal
[3],
127 /*const*/ GLfloat (*base
)[3] = ctx
->Light
._BaseColor
;
128 const struct gl_light
*light
;
129 GLfloat diffuseColor
[4], specularColor
[4]; /* for RGB mode only */
131 COPY_3V(diffuseColor
, base
[0]);
132 diffuseColor
[3] = CLAMP(
133 ctx
->Light
.Material
.Attrib
[MAT_ATTRIB_FRONT_DIFFUSE
][3], 0.0F
, 1.0F
);
134 ASSIGN_4V(specularColor
, 0.0, 0.0, 0.0, 1.0);
136 foreach (light
, &ctx
->Light
.EnabledList
) {
137 GLfloat attenuation
= 1.0;
138 GLfloat VP
[3]; /* vector from vertex to light pos */
140 GLfloat diffuseContrib
[3], specularContrib
[3];
142 if (!(light
->_Flags
& LIGHT_POSITIONAL
)) {
143 /* light at infinity */
144 COPY_3V(VP
, light
->_VP_inf_norm
);
145 attenuation
= light
->_VP_inf_spot_attenuation
;
148 /* local/positional light */
151 /* VP = vector from vertex pos to light[i].pos */
152 SUB_3V(VP
, light
->_Position
, vertex
);
154 d
= (GLfloat
) LEN_3FV( VP
);
157 GLfloat invd
= 1.0F
/ d
;
158 SELF_SCALE_SCALAR_3V(VP
, invd
);
162 attenuation
= 1.0F
/ (light
->ConstantAttenuation
+ d
*
163 (light
->LinearAttenuation
+ d
*
164 light
->QuadraticAttenuation
));
166 if (light
->_Flags
& LIGHT_SPOT
) {
167 GLfloat PV_dot_dir
= - DOT3(VP
, light
->_NormSpotDirection
);
169 if (PV_dot_dir
<light
->_CosCutoff
) {
173 GLfloat spot
= powf(PV_dot_dir
, light
->SpotExponent
);
179 if (attenuation
< 1e-3F
)
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 /* Ambient + diffuse */
190 COPY_3V(diffuseContrib
, light
->_MatAmbient
[0]);
191 ACC_SCALE_SCALAR_3V(diffuseContrib
, n_dot_VP
, light
->_MatDiffuse
[0]);
198 ASSIGN_3V(specularContrib
, 0.0, 0.0, 0.0);
200 if (ctx
->Light
.Model
.LocalViewer
) {
208 else if (light
->_Flags
& LIGHT_POSITIONAL
) {
209 ACC_3V(VP
, ctx
->_EyeZDir
);
214 h
= light
->_h_inf_norm
;
217 n_dot_h
= DOT3(normal
, h
);
219 if (n_dot_h
> 0.0F
) {
223 shine
= ctx
->Light
.Material
.Attrib
[MAT_ATTRIB_FRONT_SHININESS
][0];
224 spec_coef
= powf(n_dot_h
, shine
);
226 if (spec_coef
> 1.0e-10F
) {
227 if (ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
) {
228 ACC_SCALE_SCALAR_3V( specularContrib
, spec_coef
,
229 light
->_MatSpecular
[0]);
232 ACC_SCALE_SCALAR_3V( diffuseContrib
, spec_coef
,
233 light
->_MatSpecular
[0]);
239 ACC_SCALE_SCALAR_3V( diffuseColor
, attenuation
, diffuseContrib
);
240 ACC_SCALE_SCALAR_3V( specularColor
, attenuation
, specularContrib
);
243 Rcolor
[0] = CLAMP(diffuseColor
[0], 0.0F
, 1.0F
);
244 Rcolor
[1] = CLAMP(diffuseColor
[1], 0.0F
, 1.0F
);
245 Rcolor
[2] = CLAMP(diffuseColor
[2], 0.0F
, 1.0F
);
246 Rcolor
[3] = CLAMP(diffuseColor
[3], 0.0F
, 1.0F
);
247 Rspec
[0] = CLAMP(specularColor
[0], 0.0F
, 1.0F
);
248 Rspec
[1] = CLAMP(specularColor
[1], 0.0F
, 1.0F
);
249 Rspec
[2] = CLAMP(specularColor
[2], 0.0F
, 1.0F
);
250 Rspec
[3] = CLAMP(specularColor
[3], 0.0F
, 1.0F
);
255 * Do texgen needed for glRasterPos.
256 * \param ctx rendering context
257 * \param vObj object-space vertex coordinate
258 * \param vEye eye-space vertex coordinate
259 * \param normal vertex normal
260 * \param unit texture unit number
261 * \param texcoord incoming texcoord and resulting texcoord
264 compute_texgen(struct gl_context
*ctx
, const GLfloat vObj
[4], const GLfloat vEye
[4],
265 const GLfloat normal
[3], GLuint unit
, GLfloat texcoord
[4])
267 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
269 /* always compute sphere map terms, just in case */
270 GLfloat u
[3], two_nu
, rx
, ry
, rz
, m
, mInv
;
273 two_nu
= 2.0F
* DOT3(normal
, u
);
274 rx
= u
[0] - normal
[0] * two_nu
;
275 ry
= u
[1] - normal
[1] * two_nu
;
276 rz
= u
[2] - normal
[2] * two_nu
;
277 m
= rx
* rx
+ ry
* ry
+ (rz
+ 1.0F
) * (rz
+ 1.0F
);
279 mInv
= 0.5F
* (1.0f
/ sqrtf(m
));
283 if (texUnit
->TexGenEnabled
& S_BIT
) {
284 switch (texUnit
->GenS
.Mode
) {
285 case GL_OBJECT_LINEAR
:
286 texcoord
[0] = DOT4(vObj
, texUnit
->GenS
.ObjectPlane
);
289 texcoord
[0] = DOT4(vEye
, texUnit
->GenS
.EyePlane
);
292 texcoord
[0] = rx
* mInv
+ 0.5F
;
294 case GL_REFLECTION_MAP
:
298 texcoord
[0] = normal
[0];
301 _mesa_problem(ctx
, "Bad S texgen in compute_texgen()");
306 if (texUnit
->TexGenEnabled
& T_BIT
) {
307 switch (texUnit
->GenT
.Mode
) {
308 case GL_OBJECT_LINEAR
:
309 texcoord
[1] = DOT4(vObj
, texUnit
->GenT
.ObjectPlane
);
312 texcoord
[1] = DOT4(vEye
, texUnit
->GenT
.EyePlane
);
315 texcoord
[1] = ry
* mInv
+ 0.5F
;
317 case GL_REFLECTION_MAP
:
321 texcoord
[1] = normal
[1];
324 _mesa_problem(ctx
, "Bad T texgen in compute_texgen()");
329 if (texUnit
->TexGenEnabled
& R_BIT
) {
330 switch (texUnit
->GenR
.Mode
) {
331 case GL_OBJECT_LINEAR
:
332 texcoord
[2] = DOT4(vObj
, texUnit
->GenR
.ObjectPlane
);
335 texcoord
[2] = DOT4(vEye
, texUnit
->GenR
.EyePlane
);
337 case GL_REFLECTION_MAP
:
341 texcoord
[2] = normal
[2];
344 _mesa_problem(ctx
, "Bad R texgen in compute_texgen()");
349 if (texUnit
->TexGenEnabled
& Q_BIT
) {
350 switch (texUnit
->GenQ
.Mode
) {
351 case GL_OBJECT_LINEAR
:
352 texcoord
[3] = DOT4(vObj
, texUnit
->GenQ
.ObjectPlane
);
355 texcoord
[3] = DOT4(vEye
, texUnit
->GenQ
.EyePlane
);
358 _mesa_problem(ctx
, "Bad Q texgen in compute_texgen()");
366 * glRasterPos transformation. Typically called via ctx->Driver.RasterPos().
368 * \param vObj vertex position in object space
371 _mesa_RasterPos(struct gl_context
*ctx
, const GLfloat vObj
[4])
373 if (ctx
->VertexProgram
._Enabled
) {
374 /* XXX implement this */
375 _mesa_problem(ctx
, "Vertex programs not implemented for glRasterPos");
379 GLfloat eye
[4], clip
[4], ndc
[3], d
;
380 GLfloat
*norm
, eyenorm
[3];
381 GLfloat
*objnorm
= ctx
->Current
.Attrib
[VERT_ATTRIB_NORMAL
];
382 float scale
[3], translate
[3];
384 /* apply modelview matrix: eye = MV * obj */
385 TRANSFORM_POINT( eye
, ctx
->ModelviewMatrixStack
.Top
->m
, vObj
);
386 /* apply projection matrix: clip = Proj * eye */
387 TRANSFORM_POINT( clip
, ctx
->ProjectionMatrixStack
.Top
->m
, eye
);
389 /* clip to view volume. */
390 if (!ctx
->Transform
.DepthClamp
) {
391 if (viewclip_point_z(clip
) == 0) {
392 ctx
->Current
.RasterPosValid
= GL_FALSE
;
396 if (!ctx
->Transform
.RasterPositionUnclipped
) {
397 if (viewclip_point_xy(clip
) == 0) {
398 ctx
->Current
.RasterPosValid
= GL_FALSE
;
403 /* clip to user clipping planes */
404 if (ctx
->Transform
.ClipPlanesEnabled
&& !userclip_point(ctx
, clip
)) {
405 ctx
->Current
.RasterPosValid
= GL_FALSE
;
410 d
= (clip
[3] == 0.0F
) ? 1.0F
: 1.0F
/ clip
[3];
411 ndc
[0] = clip
[0] * d
;
412 ndc
[1] = clip
[1] * d
;
413 ndc
[2] = clip
[2] * d
;
414 /* wincoord = viewport_mapping(ndc) */
415 _mesa_get_viewport_xform(ctx
, 0, scale
, translate
);
416 ctx
->Current
.RasterPos
[0] = ndc
[0] * scale
[0] + translate
[0];
417 ctx
->Current
.RasterPos
[1] = ndc
[1] * scale
[1] + translate
[1];
418 ctx
->Current
.RasterPos
[2] = ndc
[2] * scale
[2] + translate
[2];
419 ctx
->Current
.RasterPos
[3] = clip
[3];
421 if (ctx
->Transform
.DepthClamp
) {
422 ctx
->Current
.RasterPos
[3] = CLAMP(ctx
->Current
.RasterPos
[3],
423 ctx
->ViewportArray
[0].Near
,
424 ctx
->ViewportArray
[0].Far
);
427 /* compute raster distance */
428 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
)
429 ctx
->Current
.RasterDistance
= ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0];
431 ctx
->Current
.RasterDistance
=
432 sqrtf( eye
[0]*eye
[0] + eye
[1]*eye
[1] + eye
[2]*eye
[2] );
434 /* compute transformed normal vector (for lighting or texgen) */
435 if (ctx
->_NeedEyeCoords
) {
436 const GLfloat
*inv
= ctx
->ModelviewMatrixStack
.Top
->inv
;
437 TRANSFORM_NORMAL( eyenorm
, objnorm
, inv
);
444 /* update raster color */
445 if (ctx
->Light
.Enabled
) {
447 shade_rastpos( ctx
, vObj
, norm
,
448 ctx
->Current
.RasterColor
,
449 ctx
->Current
.RasterSecondaryColor
);
452 /* use current color */
453 COPY_4FV(ctx
->Current
.RasterColor
,
454 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
]);
455 COPY_4FV(ctx
->Current
.RasterSecondaryColor
,
456 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
]);
462 for (u
= 0; u
< ctx
->Const
.MaxTextureCoordUnits
; u
++) {
464 COPY_4V(tc
, ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ u
]);
465 if (ctx
->Texture
.Unit
[u
].TexGenEnabled
) {
466 compute_texgen(ctx
, vObj
, eye
, norm
, u
, tc
);
468 TRANSFORM_POINT(ctx
->Current
.RasterTexCoords
[u
],
469 ctx
->TextureMatrixStack
[u
].Top
->m
, tc
);
473 ctx
->Current
.RasterPosValid
= GL_TRUE
;
476 if (ctx
->RenderMode
== GL_SELECT
) {
477 _mesa_update_hitflag( ctx
, ctx
->Current
.RasterPos
[2] );
483 * Helper function for all the RasterPos functions.
486 rasterpos(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
488 GET_CURRENT_CONTEXT(ctx
);
496 FLUSH_VERTICES(ctx
, 0);
497 FLUSH_CURRENT(ctx
, 0);
500 _mesa_update_state( ctx
);
502 ctx
->Driver
.RasterPos(ctx
, p
);
507 _mesa_RasterPos2d(GLdouble x
, GLdouble y
)
509 rasterpos((GLfloat
)x
, (GLfloat
)y
, (GLfloat
)0.0, (GLfloat
)1.0);
513 _mesa_RasterPos2f(GLfloat x
, GLfloat y
)
515 rasterpos(x
, y
, 0.0F
, 1.0F
);
519 _mesa_RasterPos2i(GLint x
, GLint y
)
521 rasterpos((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
525 _mesa_RasterPos2s(GLshort x
, GLshort y
)
527 rasterpos(x
, y
, 0.0F
, 1.0F
);
531 _mesa_RasterPos3d(GLdouble x
, GLdouble y
, GLdouble z
)
533 rasterpos((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
537 _mesa_RasterPos3f(GLfloat x
, GLfloat y
, GLfloat z
)
539 rasterpos(x
, y
, z
, 1.0F
);
543 _mesa_RasterPos3i(GLint x
, GLint y
, GLint z
)
545 rasterpos((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
549 _mesa_RasterPos3s(GLshort x
, GLshort y
, GLshort z
)
551 rasterpos(x
, y
, z
, 1.0F
);
555 _mesa_RasterPos4d(GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
557 rasterpos((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
561 _mesa_RasterPos4f(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
563 rasterpos(x
, y
, z
, w
);
567 _mesa_RasterPos4i(GLint x
, GLint y
, GLint z
, GLint w
)
569 rasterpos((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
573 _mesa_RasterPos4s(GLshort x
, GLshort y
, GLshort z
, GLshort w
)
575 rasterpos(x
, y
, z
, w
);
579 _mesa_RasterPos2dv(const GLdouble
*v
)
581 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
585 _mesa_RasterPos2fv(const GLfloat
*v
)
587 rasterpos(v
[0], v
[1], 0.0F
, 1.0F
);
591 _mesa_RasterPos2iv(const GLint
*v
)
593 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
597 _mesa_RasterPos2sv(const GLshort
*v
)
599 rasterpos(v
[0], v
[1], 0.0F
, 1.0F
);
603 _mesa_RasterPos3dv(const GLdouble
*v
)
605 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
609 _mesa_RasterPos3fv(const GLfloat
*v
)
611 rasterpos(v
[0], v
[1], v
[2], 1.0F
);
615 _mesa_RasterPos3iv(const GLint
*v
)
617 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
621 _mesa_RasterPos3sv(const GLshort
*v
)
623 rasterpos(v
[0], v
[1], v
[2], 1.0F
);
627 _mesa_RasterPos4dv(const GLdouble
*v
)
629 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1],
630 (GLfloat
) v
[2], (GLfloat
) v
[3]);
634 _mesa_RasterPos4fv(const GLfloat
*v
)
636 rasterpos(v
[0], v
[1], v
[2], v
[3]);
640 _mesa_RasterPos4iv(const GLint
*v
)
642 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1],
643 (GLfloat
) v
[2], (GLfloat
) v
[3]);
647 _mesa_RasterPos4sv(const GLshort
*v
)
649 rasterpos(v
[0], v
[1], v
[2], v
[3]);
653 /**********************************************************************/
654 /*** GL_ARB_window_pos / GL_MESA_window_pos ***/
655 /**********************************************************************/
659 * All glWindowPosMESA and glWindowPosARB commands call this function to
660 * update the current raster position.
663 window_pos3f(GLfloat x
, GLfloat y
, GLfloat z
)
665 GET_CURRENT_CONTEXT(ctx
);
668 FLUSH_VERTICES(ctx
, 0);
669 FLUSH_CURRENT(ctx
, 0);
671 z2
= CLAMP(z
, 0.0F
, 1.0F
)
672 * (ctx
->ViewportArray
[0].Far
- ctx
->ViewportArray
[0].Near
)
673 + ctx
->ViewportArray
[0].Near
;
675 /* set raster position */
676 ctx
->Current
.RasterPos
[0] = x
;
677 ctx
->Current
.RasterPos
[1] = y
;
678 ctx
->Current
.RasterPos
[2] = z2
;
679 ctx
->Current
.RasterPos
[3] = 1.0F
;
681 ctx
->Current
.RasterPosValid
= GL_TRUE
;
683 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
)
684 ctx
->Current
.RasterDistance
= ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0];
686 ctx
->Current
.RasterDistance
= 0.0;
688 /* raster color = current color or index */
689 ctx
->Current
.RasterColor
[0]
690 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][0], 0.0F
, 1.0F
);
691 ctx
->Current
.RasterColor
[1]
692 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][1], 0.0F
, 1.0F
);
693 ctx
->Current
.RasterColor
[2]
694 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][2], 0.0F
, 1.0F
);
695 ctx
->Current
.RasterColor
[3]
696 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][3], 0.0F
, 1.0F
);
697 ctx
->Current
.RasterSecondaryColor
[0]
698 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][0], 0.0F
, 1.0F
);
699 ctx
->Current
.RasterSecondaryColor
[1]
700 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][1], 0.0F
, 1.0F
);
701 ctx
->Current
.RasterSecondaryColor
[2]
702 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][2], 0.0F
, 1.0F
);
703 ctx
->Current
.RasterSecondaryColor
[3]
704 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][3], 0.0F
, 1.0F
);
706 /* raster texcoord = current texcoord */
709 for (texSet
= 0; texSet
< ctx
->Const
.MaxTextureCoordUnits
; texSet
++) {
710 assert(texSet
< ARRAY_SIZE(ctx
->Current
.RasterTexCoords
));
711 COPY_4FV( ctx
->Current
.RasterTexCoords
[texSet
],
712 ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ texSet
] );
716 if (ctx
->RenderMode
==GL_SELECT
) {
717 _mesa_update_hitflag( ctx
, ctx
->Current
.RasterPos
[2] );
722 /* This is just to support the GL_MESA_window_pos version */
724 window_pos4f(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
726 GET_CURRENT_CONTEXT(ctx
);
727 window_pos3f(x
, y
, z
);
728 ctx
->Current
.RasterPos
[3] = w
;
733 _mesa_WindowPos2d(GLdouble x
, GLdouble y
)
735 window_pos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
739 _mesa_WindowPos2f(GLfloat x
, GLfloat y
)
741 window_pos4f(x
, y
, 0.0F
, 1.0F
);
745 _mesa_WindowPos2i(GLint x
, GLint y
)
747 window_pos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
751 _mesa_WindowPos2s(GLshort x
, GLshort y
)
753 window_pos4f(x
, y
, 0.0F
, 1.0F
);
757 _mesa_WindowPos3d(GLdouble x
, GLdouble y
, GLdouble z
)
759 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
763 _mesa_WindowPos3f(GLfloat x
, GLfloat y
, GLfloat z
)
765 window_pos4f(x
, y
, z
, 1.0F
);
769 _mesa_WindowPos3i(GLint x
, GLint y
, GLint z
)
771 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
775 _mesa_WindowPos3s(GLshort x
, GLshort y
, GLshort z
)
777 window_pos4f(x
, y
, z
, 1.0F
);
781 _mesa_WindowPos4dMESA(GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
783 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
787 _mesa_WindowPos4fMESA(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
789 window_pos4f(x
, y
, z
, w
);
793 _mesa_WindowPos4iMESA(GLint x
, GLint y
, GLint z
, GLint w
)
795 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
799 _mesa_WindowPos4sMESA(GLshort x
, GLshort y
, GLshort z
, GLshort w
)
801 window_pos4f(x
, y
, z
, w
);
805 _mesa_WindowPos2dv(const GLdouble
*v
)
807 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
811 _mesa_WindowPos2fv(const GLfloat
*v
)
813 window_pos4f(v
[0], v
[1], 0.0F
, 1.0F
);
817 _mesa_WindowPos2iv(const GLint
*v
)
819 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
823 _mesa_WindowPos2sv(const GLshort
*v
)
825 window_pos4f(v
[0], v
[1], 0.0F
, 1.0F
);
829 _mesa_WindowPos3dv(const GLdouble
*v
)
831 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
835 _mesa_WindowPos3fv(const GLfloat
*v
)
837 window_pos4f(v
[0], v
[1], v
[2], 1.0);
841 _mesa_WindowPos3iv(const GLint
*v
)
843 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
847 _mesa_WindowPos3sv(const GLshort
*v
)
849 window_pos4f(v
[0], v
[1], v
[2], 1.0F
);
853 _mesa_WindowPos4dvMESA(const GLdouble
*v
)
855 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
856 (GLfloat
) v
[2], (GLfloat
) v
[3]);
860 _mesa_WindowPos4fvMESA(const GLfloat
*v
)
862 window_pos4f(v
[0], v
[1], v
[2], v
[3]);
866 _mesa_WindowPos4ivMESA(const GLint
*v
)
868 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
869 (GLfloat
) v
[2], (GLfloat
) v
[3]);
873 _mesa_WindowPos4svMESA(const GLshort
*v
)
875 window_pos4f(v
[0], v
[1], v
[2], v
[3]);
882 * OpenGL implementation of glWindowPos*MESA()
884 void glWindowPos4fMESA( GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
888 /* Push current matrix mode and viewport attributes */
889 glPushAttrib( GL_TRANSFORM_BIT
| GL_VIEWPORT_BIT
);
891 /* Setup projection parameters */
892 glMatrixMode( GL_PROJECTION
);
895 glMatrixMode( GL_MODELVIEW
);
899 glDepthRange( z
, z
);
900 glViewport( (int) x
- 1, (int) y
- 1, 2, 2 );
902 /* set the raster (window) position */
905 glRasterPos4f( fx
, fy
, 0.0, w
);
907 /* restore matrices, viewport and matrix mode */
909 glMatrixMode( GL_PROJECTION
);
918 /**********************************************************************/
919 /** \name Initialization */
920 /**********************************************************************/
924 * Initialize the context current raster position information.
926 * \param ctx GL context.
928 * Initialize the current raster position information in
929 * __struct gl_contextRec::Current, and adds the extension entry points to the
932 void _mesa_init_rastpos( struct gl_context
* ctx
)
936 ASSIGN_4V( ctx
->Current
.RasterPos
, 0.0, 0.0, 0.0, 1.0 );
937 ctx
->Current
.RasterDistance
= 0.0;
938 ASSIGN_4V( ctx
->Current
.RasterColor
, 1.0, 1.0, 1.0, 1.0 );
939 ASSIGN_4V( ctx
->Current
.RasterSecondaryColor
, 0.0, 0.0, 0.0, 1.0 );
940 for (i
= 0; i
< ARRAY_SIZE(ctx
->Current
.RasterTexCoords
); i
++)
941 ASSIGN_4V( ctx
->Current
.RasterTexCoords
[i
], 0.0, 0.0, 0.0, 1.0 );
942 ctx
->Current
.RasterPosValid
= GL_TRUE
;