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
[] )
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
;
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 mask
= ctx
->Light
._EnabledLights
;
138 const int i
= u_bit_scan(&mask
);
139 struct gl_light
*light
= &ctx
->Light
.Light
[i
];
140 GLfloat attenuation
= 1.0;
141 GLfloat VP
[3]; /* vector from vertex to light pos */
143 GLfloat diffuseContrib
[3], specularContrib
[3];
145 if (!(light
->_Flags
& LIGHT_POSITIONAL
)) {
146 /* light at infinity */
147 COPY_3V(VP
, light
->_VP_inf_norm
);
148 attenuation
= light
->_VP_inf_spot_attenuation
;
151 /* local/positional light */
154 /* VP = vector from vertex pos to light[i].pos */
155 SUB_3V(VP
, light
->_Position
, vertex
);
157 d
= (GLfloat
) LEN_3FV( VP
);
160 GLfloat invd
= 1.0F
/ d
;
161 SELF_SCALE_SCALAR_3V(VP
, invd
);
165 attenuation
= 1.0F
/ (light
->ConstantAttenuation
+ d
*
166 (light
->LinearAttenuation
+ d
*
167 light
->QuadraticAttenuation
));
169 if (light
->_Flags
& LIGHT_SPOT
) {
170 GLfloat PV_dot_dir
= - DOT3(VP
, light
->_NormSpotDirection
);
172 if (PV_dot_dir
<light
->_CosCutoff
) {
176 GLfloat spot
= powf(PV_dot_dir
, light
->SpotExponent
);
182 if (attenuation
< 1e-3F
)
185 n_dot_VP
= DOT3( normal
, VP
);
187 if (n_dot_VP
< 0.0F
) {
188 ACC_SCALE_SCALAR_3V(diffuseColor
, attenuation
, light
->_MatAmbient
[0]);
192 /* Ambient + diffuse */
193 COPY_3V(diffuseContrib
, light
->_MatAmbient
[0]);
194 ACC_SCALE_SCALAR_3V(diffuseContrib
, n_dot_VP
, light
->_MatDiffuse
[0]);
201 ASSIGN_3V(specularContrib
, 0.0, 0.0, 0.0);
203 if (ctx
->Light
.Model
.LocalViewer
) {
211 else if (light
->_Flags
& LIGHT_POSITIONAL
) {
212 ACC_3V(VP
, ctx
->_EyeZDir
);
217 h
= light
->_h_inf_norm
;
220 n_dot_h
= DOT3(normal
, h
);
222 if (n_dot_h
> 0.0F
) {
226 shine
= ctx
->Light
.Material
.Attrib
[MAT_ATTRIB_FRONT_SHININESS
][0];
227 spec_coef
= powf(n_dot_h
, shine
);
229 if (spec_coef
> 1.0e-10F
) {
230 if (ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
) {
231 ACC_SCALE_SCALAR_3V( specularContrib
, spec_coef
,
232 light
->_MatSpecular
[0]);
235 ACC_SCALE_SCALAR_3V( diffuseContrib
, spec_coef
,
236 light
->_MatSpecular
[0]);
242 ACC_SCALE_SCALAR_3V( diffuseColor
, attenuation
, diffuseContrib
);
243 ACC_SCALE_SCALAR_3V( specularColor
, attenuation
, specularContrib
);
246 Rcolor
[0] = CLAMP(diffuseColor
[0], 0.0F
, 1.0F
);
247 Rcolor
[1] = CLAMP(diffuseColor
[1], 0.0F
, 1.0F
);
248 Rcolor
[2] = CLAMP(diffuseColor
[2], 0.0F
, 1.0F
);
249 Rcolor
[3] = CLAMP(diffuseColor
[3], 0.0F
, 1.0F
);
250 Rspec
[0] = CLAMP(specularColor
[0], 0.0F
, 1.0F
);
251 Rspec
[1] = CLAMP(specularColor
[1], 0.0F
, 1.0F
);
252 Rspec
[2] = CLAMP(specularColor
[2], 0.0F
, 1.0F
);
253 Rspec
[3] = CLAMP(specularColor
[3], 0.0F
, 1.0F
);
258 * Do texgen needed for glRasterPos.
259 * \param ctx rendering context
260 * \param vObj object-space vertex coordinate
261 * \param vEye eye-space vertex coordinate
262 * \param normal vertex normal
263 * \param unit texture unit number
264 * \param texcoord incoming texcoord and resulting texcoord
267 compute_texgen(struct gl_context
*ctx
, const GLfloat vObj
[4], const GLfloat vEye
[4],
268 const GLfloat normal
[3], GLuint unit
, GLfloat texcoord
[4])
270 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[unit
];
272 /* always compute sphere map terms, just in case */
273 GLfloat u
[3], two_nu
, rx
, ry
, rz
, m
, mInv
;
276 two_nu
= 2.0F
* DOT3(normal
, u
);
277 rx
= u
[0] - normal
[0] * two_nu
;
278 ry
= u
[1] - normal
[1] * two_nu
;
279 rz
= u
[2] - normal
[2] * two_nu
;
280 m
= rx
* rx
+ ry
* ry
+ (rz
+ 1.0F
) * (rz
+ 1.0F
);
282 mInv
= 0.5F
* (1.0f
/ sqrtf(m
));
286 if (texUnit
->TexGenEnabled
& S_BIT
) {
287 switch (texUnit
->GenS
.Mode
) {
288 case GL_OBJECT_LINEAR
:
289 texcoord
[0] = DOT4(vObj
, texUnit
->GenS
.ObjectPlane
);
292 texcoord
[0] = DOT4(vEye
, texUnit
->GenS
.EyePlane
);
295 texcoord
[0] = rx
* mInv
+ 0.5F
;
297 case GL_REFLECTION_MAP
:
301 texcoord
[0] = normal
[0];
304 _mesa_problem(ctx
, "Bad S texgen in compute_texgen()");
309 if (texUnit
->TexGenEnabled
& T_BIT
) {
310 switch (texUnit
->GenT
.Mode
) {
311 case GL_OBJECT_LINEAR
:
312 texcoord
[1] = DOT4(vObj
, texUnit
->GenT
.ObjectPlane
);
315 texcoord
[1] = DOT4(vEye
, texUnit
->GenT
.EyePlane
);
318 texcoord
[1] = ry
* mInv
+ 0.5F
;
320 case GL_REFLECTION_MAP
:
324 texcoord
[1] = normal
[1];
327 _mesa_problem(ctx
, "Bad T texgen in compute_texgen()");
332 if (texUnit
->TexGenEnabled
& R_BIT
) {
333 switch (texUnit
->GenR
.Mode
) {
334 case GL_OBJECT_LINEAR
:
335 texcoord
[2] = DOT4(vObj
, texUnit
->GenR
.ObjectPlane
);
338 texcoord
[2] = DOT4(vEye
, texUnit
->GenR
.EyePlane
);
340 case GL_REFLECTION_MAP
:
344 texcoord
[2] = normal
[2];
347 _mesa_problem(ctx
, "Bad R texgen in compute_texgen()");
352 if (texUnit
->TexGenEnabled
& Q_BIT
) {
353 switch (texUnit
->GenQ
.Mode
) {
354 case GL_OBJECT_LINEAR
:
355 texcoord
[3] = DOT4(vObj
, texUnit
->GenQ
.ObjectPlane
);
358 texcoord
[3] = DOT4(vEye
, texUnit
->GenQ
.EyePlane
);
361 _mesa_problem(ctx
, "Bad Q texgen in compute_texgen()");
369 * glRasterPos transformation. Typically called via ctx->Driver.RasterPos().
371 * \param vObj vertex position in object space
374 _mesa_RasterPos(struct gl_context
*ctx
, const GLfloat vObj
[4])
376 if (ctx
->VertexProgram
._Enabled
) {
377 /* XXX implement this */
378 _mesa_problem(ctx
, "Vertex programs not implemented for glRasterPos");
382 GLfloat eye
[4], clip
[4], ndc
[3], d
;
383 GLfloat
*norm
, eyenorm
[3];
384 GLfloat
*objnorm
= ctx
->Current
.Attrib
[VERT_ATTRIB_NORMAL
];
385 float scale
[3], translate
[3];
387 /* apply modelview matrix: eye = MV * obj */
388 TRANSFORM_POINT( eye
, ctx
->ModelviewMatrixStack
.Top
->m
, vObj
);
389 /* apply projection matrix: clip = Proj * eye */
390 TRANSFORM_POINT( clip
, ctx
->ProjectionMatrixStack
.Top
->m
, eye
);
392 /* clip to view volume. */
393 if (!ctx
->Transform
.DepthClamp
) {
394 if (viewclip_point_z(clip
) == 0) {
395 ctx
->Current
.RasterPosValid
= GL_FALSE
;
399 if (!ctx
->Transform
.RasterPositionUnclipped
) {
400 if (viewclip_point_xy(clip
) == 0) {
401 ctx
->Current
.RasterPosValid
= GL_FALSE
;
406 /* clip to user clipping planes */
407 if (ctx
->Transform
.ClipPlanesEnabled
&& !userclip_point(ctx
, clip
)) {
408 ctx
->Current
.RasterPosValid
= GL_FALSE
;
413 d
= (clip
[3] == 0.0F
) ? 1.0F
: 1.0F
/ clip
[3];
414 ndc
[0] = clip
[0] * d
;
415 ndc
[1] = clip
[1] * d
;
416 ndc
[2] = clip
[2] * d
;
417 /* wincoord = viewport_mapping(ndc) */
418 _mesa_get_viewport_xform(ctx
, 0, scale
, translate
);
419 ctx
->Current
.RasterPos
[0] = ndc
[0] * scale
[0] + translate
[0];
420 ctx
->Current
.RasterPos
[1] = ndc
[1] * scale
[1] + translate
[1];
421 ctx
->Current
.RasterPos
[2] = ndc
[2] * scale
[2] + translate
[2];
422 ctx
->Current
.RasterPos
[3] = clip
[3];
424 if (ctx
->Transform
.DepthClamp
) {
425 ctx
->Current
.RasterPos
[3] = CLAMP(ctx
->Current
.RasterPos
[3],
426 ctx
->ViewportArray
[0].Near
,
427 ctx
->ViewportArray
[0].Far
);
430 /* compute raster distance */
431 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
)
432 ctx
->Current
.RasterDistance
= ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0];
434 ctx
->Current
.RasterDistance
=
435 sqrtf( eye
[0]*eye
[0] + eye
[1]*eye
[1] + eye
[2]*eye
[2] );
437 /* compute transformed normal vector (for lighting or texgen) */
438 if (ctx
->_NeedEyeCoords
) {
439 const GLfloat
*inv
= ctx
->ModelviewMatrixStack
.Top
->inv
;
440 TRANSFORM_NORMAL( eyenorm
, objnorm
, inv
);
447 /* update raster color */
448 if (ctx
->Light
.Enabled
) {
450 shade_rastpos( ctx
, vObj
, norm
,
451 ctx
->Current
.RasterColor
,
452 ctx
->Current
.RasterSecondaryColor
);
455 /* use current color */
456 COPY_4FV(ctx
->Current
.RasterColor
,
457 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
]);
458 COPY_4FV(ctx
->Current
.RasterSecondaryColor
,
459 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
]);
465 for (u
= 0; u
< ctx
->Const
.MaxTextureCoordUnits
; u
++) {
467 COPY_4V(tc
, ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ u
]);
468 if (ctx
->Texture
.Unit
[u
].TexGenEnabled
) {
469 compute_texgen(ctx
, vObj
, eye
, norm
, u
, tc
);
471 TRANSFORM_POINT(ctx
->Current
.RasterTexCoords
[u
],
472 ctx
->TextureMatrixStack
[u
].Top
->m
, tc
);
476 ctx
->Current
.RasterPosValid
= GL_TRUE
;
479 if (ctx
->RenderMode
== GL_SELECT
) {
480 _mesa_update_hitflag( ctx
, ctx
->Current
.RasterPos
[2] );
486 * Helper function for all the RasterPos functions.
489 rasterpos(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
491 GET_CURRENT_CONTEXT(ctx
);
499 FLUSH_VERTICES(ctx
, 0);
500 FLUSH_CURRENT(ctx
, 0);
503 _mesa_update_state( ctx
);
505 ctx
->Driver
.RasterPos(ctx
, p
);
510 _mesa_RasterPos2d(GLdouble x
, GLdouble y
)
512 rasterpos((GLfloat
)x
, (GLfloat
)y
, (GLfloat
)0.0, (GLfloat
)1.0);
516 _mesa_RasterPos2f(GLfloat x
, GLfloat y
)
518 rasterpos(x
, y
, 0.0F
, 1.0F
);
522 _mesa_RasterPos2i(GLint x
, GLint y
)
524 rasterpos((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
528 _mesa_RasterPos2s(GLshort x
, GLshort y
)
530 rasterpos(x
, y
, 0.0F
, 1.0F
);
534 _mesa_RasterPos3d(GLdouble x
, GLdouble y
, GLdouble z
)
536 rasterpos((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
540 _mesa_RasterPos3f(GLfloat x
, GLfloat y
, GLfloat z
)
542 rasterpos(x
, y
, z
, 1.0F
);
546 _mesa_RasterPos3i(GLint x
, GLint y
, GLint z
)
548 rasterpos((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
552 _mesa_RasterPos3s(GLshort x
, GLshort y
, GLshort z
)
554 rasterpos(x
, y
, z
, 1.0F
);
558 _mesa_RasterPos4d(GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
560 rasterpos((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
564 _mesa_RasterPos4f(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
566 rasterpos(x
, y
, z
, w
);
570 _mesa_RasterPos4i(GLint x
, GLint y
, GLint z
, GLint w
)
572 rasterpos((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
576 _mesa_RasterPos4s(GLshort x
, GLshort y
, GLshort z
, GLshort w
)
578 rasterpos(x
, y
, z
, w
);
582 _mesa_RasterPos2dv(const GLdouble
*v
)
584 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
588 _mesa_RasterPos2fv(const GLfloat
*v
)
590 rasterpos(v
[0], v
[1], 0.0F
, 1.0F
);
594 _mesa_RasterPos2iv(const GLint
*v
)
596 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
600 _mesa_RasterPos2sv(const GLshort
*v
)
602 rasterpos(v
[0], v
[1], 0.0F
, 1.0F
);
606 _mesa_RasterPos3dv(const GLdouble
*v
)
608 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
612 _mesa_RasterPos3fv(const GLfloat
*v
)
614 rasterpos(v
[0], v
[1], v
[2], 1.0F
);
618 _mesa_RasterPos3iv(const GLint
*v
)
620 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
624 _mesa_RasterPos3sv(const GLshort
*v
)
626 rasterpos(v
[0], v
[1], v
[2], 1.0F
);
630 _mesa_RasterPos4dv(const GLdouble
*v
)
632 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1],
633 (GLfloat
) v
[2], (GLfloat
) v
[3]);
637 _mesa_RasterPos4fv(const GLfloat
*v
)
639 rasterpos(v
[0], v
[1], v
[2], v
[3]);
643 _mesa_RasterPos4iv(const GLint
*v
)
645 rasterpos((GLfloat
) v
[0], (GLfloat
) v
[1],
646 (GLfloat
) v
[2], (GLfloat
) v
[3]);
650 _mesa_RasterPos4sv(const GLshort
*v
)
652 rasterpos(v
[0], v
[1], v
[2], v
[3]);
656 /**********************************************************************/
657 /*** GL_ARB_window_pos / GL_MESA_window_pos ***/
658 /**********************************************************************/
662 * All glWindowPosMESA and glWindowPosARB commands call this function to
663 * update the current raster position.
666 window_pos3f(GLfloat x
, GLfloat y
, GLfloat z
)
668 GET_CURRENT_CONTEXT(ctx
);
671 FLUSH_VERTICES(ctx
, 0);
672 FLUSH_CURRENT(ctx
, 0);
674 z2
= CLAMP(z
, 0.0F
, 1.0F
)
675 * (ctx
->ViewportArray
[0].Far
- ctx
->ViewportArray
[0].Near
)
676 + ctx
->ViewportArray
[0].Near
;
678 /* set raster position */
679 ctx
->Current
.RasterPos
[0] = x
;
680 ctx
->Current
.RasterPos
[1] = y
;
681 ctx
->Current
.RasterPos
[2] = z2
;
682 ctx
->Current
.RasterPos
[3] = 1.0F
;
684 ctx
->Current
.RasterPosValid
= GL_TRUE
;
686 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
)
687 ctx
->Current
.RasterDistance
= ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0];
689 ctx
->Current
.RasterDistance
= 0.0;
691 /* raster color = current color or index */
692 ctx
->Current
.RasterColor
[0]
693 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][0], 0.0F
, 1.0F
);
694 ctx
->Current
.RasterColor
[1]
695 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][1], 0.0F
, 1.0F
);
696 ctx
->Current
.RasterColor
[2]
697 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][2], 0.0F
, 1.0F
);
698 ctx
->Current
.RasterColor
[3]
699 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][3], 0.0F
, 1.0F
);
700 ctx
->Current
.RasterSecondaryColor
[0]
701 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][0], 0.0F
, 1.0F
);
702 ctx
->Current
.RasterSecondaryColor
[1]
703 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][1], 0.0F
, 1.0F
);
704 ctx
->Current
.RasterSecondaryColor
[2]
705 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][2], 0.0F
, 1.0F
);
706 ctx
->Current
.RasterSecondaryColor
[3]
707 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][3], 0.0F
, 1.0F
);
709 /* raster texcoord = current texcoord */
712 for (texSet
= 0; texSet
< ctx
->Const
.MaxTextureCoordUnits
; texSet
++) {
713 assert(texSet
< ARRAY_SIZE(ctx
->Current
.RasterTexCoords
));
714 COPY_4FV( ctx
->Current
.RasterTexCoords
[texSet
],
715 ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ texSet
] );
719 if (ctx
->RenderMode
==GL_SELECT
) {
720 _mesa_update_hitflag( ctx
, ctx
->Current
.RasterPos
[2] );
725 /* This is just to support the GL_MESA_window_pos version */
727 window_pos4f(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
729 GET_CURRENT_CONTEXT(ctx
);
730 window_pos3f(x
, y
, z
);
731 ctx
->Current
.RasterPos
[3] = w
;
736 _mesa_WindowPos2d(GLdouble x
, GLdouble y
)
738 window_pos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
742 _mesa_WindowPos2f(GLfloat x
, GLfloat y
)
744 window_pos4f(x
, y
, 0.0F
, 1.0F
);
748 _mesa_WindowPos2i(GLint x
, GLint y
)
750 window_pos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
754 _mesa_WindowPos2s(GLshort x
, GLshort y
)
756 window_pos4f(x
, y
, 0.0F
, 1.0F
);
760 _mesa_WindowPos3d(GLdouble x
, GLdouble y
, GLdouble z
)
762 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
766 _mesa_WindowPos3f(GLfloat x
, GLfloat y
, GLfloat z
)
768 window_pos4f(x
, y
, z
, 1.0F
);
772 _mesa_WindowPos3i(GLint x
, GLint y
, GLint z
)
774 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
778 _mesa_WindowPos3s(GLshort x
, GLshort y
, GLshort z
)
780 window_pos4f(x
, y
, z
, 1.0F
);
784 _mesa_WindowPos4dMESA(GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
786 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
790 _mesa_WindowPos4fMESA(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
792 window_pos4f(x
, y
, z
, w
);
796 _mesa_WindowPos4iMESA(GLint x
, GLint y
, GLint z
, GLint w
)
798 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
802 _mesa_WindowPos4sMESA(GLshort x
, GLshort y
, GLshort z
, GLshort w
)
804 window_pos4f(x
, y
, z
, w
);
808 _mesa_WindowPos2dv(const GLdouble
*v
)
810 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
814 _mesa_WindowPos2fv(const GLfloat
*v
)
816 window_pos4f(v
[0], v
[1], 0.0F
, 1.0F
);
820 _mesa_WindowPos2iv(const GLint
*v
)
822 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
826 _mesa_WindowPos2sv(const GLshort
*v
)
828 window_pos4f(v
[0], v
[1], 0.0F
, 1.0F
);
832 _mesa_WindowPos3dv(const GLdouble
*v
)
834 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
838 _mesa_WindowPos3fv(const GLfloat
*v
)
840 window_pos4f(v
[0], v
[1], v
[2], 1.0);
844 _mesa_WindowPos3iv(const GLint
*v
)
846 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
850 _mesa_WindowPos3sv(const GLshort
*v
)
852 window_pos4f(v
[0], v
[1], v
[2], 1.0F
);
856 _mesa_WindowPos4dvMESA(const GLdouble
*v
)
858 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
859 (GLfloat
) v
[2], (GLfloat
) v
[3]);
863 _mesa_WindowPos4fvMESA(const GLfloat
*v
)
865 window_pos4f(v
[0], v
[1], v
[2], v
[3]);
869 _mesa_WindowPos4ivMESA(const GLint
*v
)
871 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
872 (GLfloat
) v
[2], (GLfloat
) v
[3]);
876 _mesa_WindowPos4svMESA(const GLshort
*v
)
878 window_pos4f(v
[0], v
[1], v
[2], v
[3]);
885 * OpenGL implementation of glWindowPos*MESA()
887 void glWindowPos4fMESA( GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
891 /* Push current matrix mode and viewport attributes */
892 glPushAttrib( GL_TRANSFORM_BIT
| GL_VIEWPORT_BIT
);
894 /* Setup projection parameters */
895 glMatrixMode( GL_PROJECTION
);
898 glMatrixMode( GL_MODELVIEW
);
902 glDepthRange( z
, z
);
903 glViewport( (int) x
- 1, (int) y
- 1, 2, 2 );
905 /* set the raster (window) position */
908 glRasterPos4f( fx
, fy
, 0.0, w
);
910 /* restore matrices, viewport and matrix mode */
912 glMatrixMode( GL_PROJECTION
);
921 /**********************************************************************/
922 /** \name Initialization */
923 /**********************************************************************/
927 * Initialize the context current raster position information.
929 * \param ctx GL context.
931 * Initialize the current raster position information in
932 * __struct gl_contextRec::Current, and adds the extension entry points to the
935 void _mesa_init_rastpos( struct gl_context
* ctx
)
939 ASSIGN_4V( ctx
->Current
.RasterPos
, 0.0, 0.0, 0.0, 1.0 );
940 ctx
->Current
.RasterDistance
= 0.0;
941 ASSIGN_4V( ctx
->Current
.RasterColor
, 1.0, 1.0, 1.0, 1.0 );
942 ASSIGN_4V( ctx
->Current
.RasterSecondaryColor
, 0.0, 0.0, 0.0, 1.0 );
943 for (i
= 0; i
< ARRAY_SIZE(ctx
->Current
.RasterTexCoords
); i
++)
944 ASSIGN_4V( ctx
->Current
.RasterTexCoords
[i
], 0.0, 0.0, 0.0, 1.0 );
945 ctx
->Current
.RasterPosValid
= GL_TRUE
;