3 * Raster position operations.
7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 #include "simple_list.h"
43 #include "math/m_matrix.h"
47 * Clip a point against the view volume.
49 * \param v vertex vector describing the point to clip.
51 * \return zero if outside view volume, or one if inside.
54 viewclip_point( const GLfloat v
[] )
56 if ( v
[0] > v
[3] || v
[0] < -v
[3]
57 || v
[1] > v
[3] || v
[1] < -v
[3]
58 || v
[2] > v
[3] || v
[2] < -v
[3] ) {
68 * Clip a point against the far/near Z clipping planes.
70 * \param v vertex vector describing the point to clip.
72 * \return zero if outside view volume, or one if inside.
75 viewclip_point_z( const GLfloat v
[] )
77 if (v
[2] > v
[3] || v
[2] < -v
[3] ) {
87 * Clip a point against the user clipping planes.
89 * \param ctx GL context.
90 * \param v vertex vector describing the point to clip.
92 * \return zero if the point was clipped, or one otherwise.
95 userclip_point( GLcontext
*ctx
, const GLfloat v
[] )
99 for (p
= 0; p
< ctx
->Const
.MaxClipPlanes
; p
++) {
100 if (ctx
->Transform
.ClipPlanesEnabled
& (1 << p
)) {
101 GLfloat dot
= v
[0] * ctx
->Transform
._ClipUserPlane
[p
][0]
102 + v
[1] * ctx
->Transform
._ClipUserPlane
[p
][1]
103 + v
[2] * ctx
->Transform
._ClipUserPlane
[p
][2]
104 + v
[3] * ctx
->Transform
._ClipUserPlane
[p
][3];
116 * This has been split off to allow the normal shade routines to
117 * get a little closer to the vertex buffer, and to use the
118 * GLvector objects directly.
119 * \param ctx the context
120 * \param vertex vertex location
121 * \param normal normal vector
122 * \param Rcolor returned color
123 * \param Rspec returned specular color (if separate specular enabled)
124 * \param Rindex returned color index
127 shade_rastpos(GLcontext
*ctx
,
128 const GLfloat vertex
[4],
129 const GLfloat normal
[3],
134 GLfloat (*base
)[3] = ctx
->Light
._BaseColor
;
135 struct gl_light
*light
;
136 GLfloat diffuseColor
[4], specularColor
[4];
137 GLfloat diffuse
= 0, specular
= 0;
139 if (!ctx
->_ShineTable
[0] || !ctx
->_ShineTable
[1])
140 _mesa_validate_all_lighting_tables( ctx
);
142 COPY_3V(diffuseColor
, base
[0]);
143 diffuseColor
[3] = CLAMP(
144 ctx
->Light
.Material
.Attrib
[MAT_ATTRIB_FRONT_DIFFUSE
][3], 0.0F
, 1.0F
);
145 ASSIGN_4V(specularColor
, 0.0, 0.0, 0.0, 0.0);
147 foreach (light
, &ctx
->Light
.EnabledList
) {
149 GLfloat attenuation
= 1.0;
153 GLfloat diffuseContrib
[3], specularContrib
[3];
154 GLboolean normalized
;
156 if (!(light
->_Flags
& LIGHT_POSITIONAL
)) {
157 COPY_3V(VP
, light
->_VP_inf_norm
);
158 attenuation
= light
->_VP_inf_spot_attenuation
;
163 SUB_3V(VP
, light
->_Position
, vertex
);
164 d
= (GLfloat
) LEN_3FV( VP
);
167 GLfloat invd
= 1.0F
/ d
;
168 SELF_SCALE_SCALAR_3V(VP
, invd
);
170 attenuation
= 1.0F
/ (light
->ConstantAttenuation
+ d
*
171 (light
->LinearAttenuation
+ d
*
172 light
->QuadraticAttenuation
));
174 if (light
->_Flags
& LIGHT_SPOT
) {
175 GLfloat PV_dot_dir
= - DOT3(VP
, light
->_NormDirection
);
177 if (PV_dot_dir
<light
->_CosCutoff
) {
181 double x
= PV_dot_dir
* (EXP_TABLE_SIZE
-1);
183 GLfloat spot
= (GLfloat
) (light
->_SpotExpTable
[k
][0]
184 + (x
-k
)*light
->_SpotExpTable
[k
][1]);
190 if (attenuation
< 1e-3)
193 n_dot_VP
= DOT3( normal
, VP
);
195 if (n_dot_VP
< 0.0F
) {
196 ACC_SCALE_SCALAR_3V(diffuseColor
, attenuation
, light
->_MatAmbient
[0]);
200 COPY_3V(diffuseContrib
, light
->_MatAmbient
[0]);
201 ACC_SCALE_SCALAR_3V(diffuseContrib
, n_dot_VP
, light
->_MatDiffuse
[0]);
202 diffuse
+= n_dot_VP
* light
->_dli
* attenuation
;
203 ASSIGN_3V(specularContrib
, 0.0, 0.0, 0.0);
206 if (ctx
->Light
.Model
.LocalViewer
) {
214 else if (light
->_Flags
& LIGHT_POSITIONAL
) {
216 ACC_3V(h
, ctx
->_EyeZDir
);
220 h
= light
->_h_inf_norm
;
224 n_dot_h
= DOT3(normal
, h
);
226 if (n_dot_h
> 0.0F
) {
227 GLfloat (*mat
)[4] = ctx
->Light
.Material
.Attrib
;
229 GLfloat shininess
= mat
[MAT_ATTRIB_FRONT_SHININESS
][0];
233 n_dot_h
/= LEN_SQUARED_3FV( h
);
237 GET_SHINE_TAB_ENTRY( ctx
->_ShineTable
[0], n_dot_h
, spec_coef
);
239 if (spec_coef
> 1.0e-10) {
240 if (ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
) {
241 ACC_SCALE_SCALAR_3V( specularContrib
, spec_coef
,
242 light
->_MatSpecular
[0]);
245 ACC_SCALE_SCALAR_3V( diffuseContrib
, spec_coef
,
246 light
->_MatSpecular
[0]);
248 specular
+= spec_coef
* light
->_sli
* attenuation
;
253 ACC_SCALE_SCALAR_3V( diffuseColor
, attenuation
, diffuseContrib
);
254 ACC_SCALE_SCALAR_3V( specularColor
, attenuation
, specularContrib
);
257 if (ctx
->Visual
.rgbMode
) {
258 Rcolor
[0] = CLAMP(diffuseColor
[0], 0.0F
, 1.0F
);
259 Rcolor
[1] = CLAMP(diffuseColor
[1], 0.0F
, 1.0F
);
260 Rcolor
[2] = CLAMP(diffuseColor
[2], 0.0F
, 1.0F
);
261 Rcolor
[3] = CLAMP(diffuseColor
[3], 0.0F
, 1.0F
);
262 Rspec
[0] = CLAMP(specularColor
[0], 0.0F
, 1.0F
);
263 Rspec
[1] = CLAMP(specularColor
[1], 0.0F
, 1.0F
);
264 Rspec
[2] = CLAMP(specularColor
[2], 0.0F
, 1.0F
);
265 Rspec
[3] = CLAMP(specularColor
[3], 0.0F
, 1.0F
);
268 GLfloat
*ind
= ctx
->Light
.Material
.Attrib
[MAT_ATTRIB_FRONT_INDEXES
];
269 GLfloat d_a
= ind
[MAT_INDEX_DIFFUSE
] - ind
[MAT_INDEX_AMBIENT
];
270 GLfloat s_a
= ind
[MAT_INDEX_SPECULAR
] - ind
[MAT_INDEX_AMBIENT
];
271 GLfloat i
= (ind
[MAT_INDEX_AMBIENT
]
272 + diffuse
* (1.0F
-specular
) * d_a
274 if (i
> ind
[MAT_INDEX_SPECULAR
]) {
275 i
= ind
[MAT_INDEX_SPECULAR
];
283 * Set the raster position for pixel operations.
285 * All glRasterPos command call this function to update the current
288 * \param ctx GL context.
289 * \param x x coordinate for the raster position.
290 * \param y y coordinate for the raster position.
291 * \param z z coordinate for the raster position.
292 * \param w w coordinate for the raster position.
294 * \sa Called by _mesa_RasterPos4f().
296 * Flushes the vertices, transforms and clips the vertex coordinates, and
297 * finally sets the current raster position and associated data in
298 * __GLcontextRec::Current. When in selection mode calls
299 * _mesa_update_hitflag() with the current raster position.
302 raster_pos4f(GLcontext
*ctx
, GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
304 GLfloat v
[4], eye
[4], clip
[4], ndc
[3], d
;
305 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
306 FLUSH_CURRENT(ctx
, 0);
309 _mesa_update_state( ctx
);
311 if (ctx
->VertexProgram
.Enabled
) {
312 /* XXX implement this */
313 _mesa_problem(ctx
, "Vertex programs not implemented for glRasterPos");
317 ASSIGN_4V( v
, x
, y
, z
, w
);
318 TRANSFORM_POINT( eye
, ctx
->ModelviewMatrixStack
.Top
->m
, v
);
321 if (ctx
->Light
.Enabled
) {
322 GLfloat
*norm
, eyenorm
[3];
323 GLfloat
*objnorm
= ctx
->Current
.Attrib
[VERT_ATTRIB_NORMAL
];
325 if (ctx
->_NeedEyeCoords
) {
326 GLfloat
*inv
= ctx
->ModelviewMatrixStack
.Top
->inv
;
327 TRANSFORM_NORMAL( eyenorm
, objnorm
, inv
);
334 shade_rastpos( ctx
, v
, norm
,
335 ctx
->Current
.RasterColor
,
336 ctx
->Current
.RasterSecondaryColor
,
337 &ctx
->Current
.RasterIndex
);
340 /* use current color or index */
341 if (ctx
->Visual
.rgbMode
) {
342 COPY_4FV(ctx
->Current
.RasterColor
,
343 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
]);
344 COPY_4FV(ctx
->Current
.RasterSecondaryColor
,
345 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
]);
348 ctx
->Current
.RasterIndex
= ctx
->Current
.Index
;
352 /* compute raster distance */
353 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
)
354 ctx
->Current
.RasterDistance
= ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0];
356 ctx
->Current
.RasterDistance
=
357 SQRTF( eye
[0]*eye
[0] + eye
[1]*eye
[1] + eye
[2]*eye
[2] );
359 /* apply projection matrix: clip = Proj * eye */
360 TRANSFORM_POINT( clip
, ctx
->ProjectionMatrixStack
.Top
->m
, eye
);
362 /* clip to view volume */
363 if (ctx
->Transform
.RasterPositionUnclipped
) {
364 /* GL_IBM_rasterpos_clip: only clip against Z */
365 if (viewclip_point_z(clip
) == 0) {
366 ctx
->Current
.RasterPosValid
= GL_FALSE
;
370 else if (viewclip_point(clip
) == 0) {
371 /* Normal OpenGL behaviour */
372 ctx
->Current
.RasterPosValid
= GL_FALSE
;
376 /* clip to user clipping planes */
377 if (ctx
->Transform
.ClipPlanesEnabled
&& !userclip_point(ctx
, clip
)) {
378 ctx
->Current
.RasterPosValid
= GL_FALSE
;
383 d
= (clip
[3] == 0.0F
) ? 1.0F
: 1.0F
/ clip
[3];
384 ndc
[0] = clip
[0] * d
;
385 ndc
[1] = clip
[1] * d
;
386 ndc
[2] = clip
[2] * d
;
388 ctx
->Current
.RasterPos
[0] = (ndc
[0] * ctx
->Viewport
._WindowMap
.m
[MAT_SX
] +
389 ctx
->Viewport
._WindowMap
.m
[MAT_TX
]);
390 ctx
->Current
.RasterPos
[1] = (ndc
[1] * ctx
->Viewport
._WindowMap
.m
[MAT_SY
] +
391 ctx
->Viewport
._WindowMap
.m
[MAT_TY
]);
392 ctx
->Current
.RasterPos
[2] = (ndc
[2] * ctx
->Viewport
._WindowMap
.m
[MAT_SZ
] +
393 ctx
->Viewport
._WindowMap
.m
[MAT_TZ
]) / ctx
->DepthMaxF
;
394 ctx
->Current
.RasterPos
[3] = clip
[3];
395 ctx
->Current
.RasterPosValid
= GL_TRUE
;
399 for (texSet
= 0; texSet
< ctx
->Const
.MaxTextureCoordUnits
; texSet
++) {
400 COPY_4FV( ctx
->Current
.RasterTexCoords
[texSet
],
401 ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ texSet
] );
407 if (ctx
->RenderMode
==GL_SELECT
) {
408 _mesa_update_hitflag( ctx
, ctx
->Current
.RasterPos
[2] );
413 /** Calls _mesa_RasterPos4f() */
415 _mesa_RasterPos2d(GLdouble x
, GLdouble y
)
417 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
420 /** Calls _mesa_RasterPos4f() */
422 _mesa_RasterPos2f(GLfloat x
, GLfloat y
)
424 _mesa_RasterPos4f(x
, y
, 0.0F
, 1.0F
);
427 /** Calls _mesa_RasterPos4f() */
429 _mesa_RasterPos2i(GLint x
, GLint y
)
431 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
434 /** Calls _mesa_RasterPos4f() */
436 _mesa_RasterPos2s(GLshort x
, GLshort y
)
438 _mesa_RasterPos4f(x
, y
, 0.0F
, 1.0F
);
441 /** Calls _mesa_RasterPos4f() */
443 _mesa_RasterPos3d(GLdouble x
, GLdouble y
, GLdouble z
)
445 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
448 /** Calls _mesa_RasterPos4f() */
450 _mesa_RasterPos3f(GLfloat x
, GLfloat y
, GLfloat z
)
452 _mesa_RasterPos4f(x
, y
, z
, 1.0F
);
455 /** Calls _mesa_RasterPos4f() */
457 _mesa_RasterPos3i(GLint x
, GLint y
, GLint z
)
459 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
462 /** Calls _mesa_RasterPos4f() */
464 _mesa_RasterPos3s(GLshort x
, GLshort y
, GLshort z
)
466 _mesa_RasterPos4f(x
, y
, z
, 1.0F
);
469 /** Calls _mesa_RasterPos4f() */
471 _mesa_RasterPos4d(GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
473 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
476 /** Calls raster_pos4f() */
478 _mesa_RasterPos4f(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
480 GET_CURRENT_CONTEXT(ctx
);
481 raster_pos4f(ctx
, x
, y
, z
, w
);
484 /** Calls _mesa_RasterPos4f() */
486 _mesa_RasterPos4i(GLint x
, GLint y
, GLint z
, GLint w
)
488 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
491 /** Calls _mesa_RasterPos4f() */
493 _mesa_RasterPos4s(GLshort x
, GLshort y
, GLshort z
, GLshort w
)
495 _mesa_RasterPos4f(x
, y
, z
, w
);
498 /** Calls _mesa_RasterPos4f() */
500 _mesa_RasterPos2dv(const GLdouble
*v
)
502 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
505 /** Calls _mesa_RasterPos4f() */
507 _mesa_RasterPos2fv(const GLfloat
*v
)
509 _mesa_RasterPos4f(v
[0], v
[1], 0.0F
, 1.0F
);
512 /** Calls _mesa_RasterPos4f() */
514 _mesa_RasterPos2iv(const GLint
*v
)
516 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
519 /** Calls _mesa_RasterPos4f() */
521 _mesa_RasterPos2sv(const GLshort
*v
)
523 _mesa_RasterPos4f(v
[0], v
[1], 0.0F
, 1.0F
);
526 /** Calls _mesa_RasterPos4f() */
528 _mesa_RasterPos3dv(const GLdouble
*v
)
530 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
533 /** Calls _mesa_RasterPos4f() */
535 _mesa_RasterPos3fv(const GLfloat
*v
)
537 _mesa_RasterPos4f(v
[0], v
[1], v
[2], 1.0F
);
540 /** Calls _mesa_RasterPos4f() */
542 _mesa_RasterPos3iv(const GLint
*v
)
544 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
547 /** Calls _mesa_RasterPos4f() */
549 _mesa_RasterPos3sv(const GLshort
*v
)
551 _mesa_RasterPos4f(v
[0], v
[1], v
[2], 1.0F
);
554 /** Calls _mesa_RasterPos4f() */
556 _mesa_RasterPos4dv(const GLdouble
*v
)
558 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
559 (GLfloat
) v
[2], (GLfloat
) v
[3]);
562 /** Calls _mesa_RasterPos4f() */
564 _mesa_RasterPos4fv(const GLfloat
*v
)
566 _mesa_RasterPos4f(v
[0], v
[1], v
[2], v
[3]);
569 /** Calls _mesa_RasterPos4f() */
571 _mesa_RasterPos4iv(const GLint
*v
)
573 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
574 (GLfloat
) v
[2], (GLfloat
) v
[3]);
577 /** Calls _mesa_RasterPos4f() */
579 _mesa_RasterPos4sv(const GLshort
*v
)
581 _mesa_RasterPos4f(v
[0], v
[1], v
[2], v
[3]);
585 /**********************************************************************/
586 /*** GL_ARB_window_pos / GL_MESA_window_pos ***/
587 /**********************************************************************/
589 #if FEATURE_windowpos
591 * All glWindowPosMESA and glWindowPosARB commands call this function to
592 * update the current raster position.
595 window_pos3f(GLfloat x
, GLfloat y
, GLfloat z
)
597 GET_CURRENT_CONTEXT(ctx
);
600 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
601 FLUSH_CURRENT(ctx
, 0);
603 z2
= CLAMP(z
, 0.0F
, 1.0F
) * (ctx
->Viewport
.Far
- ctx
->Viewport
.Near
)
604 + ctx
->Viewport
.Near
;
606 /* set raster position */
607 ctx
->Current
.RasterPos
[0] = x
;
608 ctx
->Current
.RasterPos
[1] = y
;
609 ctx
->Current
.RasterPos
[2] = z2
;
610 ctx
->Current
.RasterPos
[3] = 1.0F
;
612 ctx
->Current
.RasterPosValid
= GL_TRUE
;
614 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
)
615 ctx
->Current
.RasterDistance
= ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0];
617 ctx
->Current
.RasterDistance
= 0.0;
619 /* raster color = current color or index */
620 if (ctx
->Visual
.rgbMode
) {
621 ctx
->Current
.RasterColor
[0]
622 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][0], 0.0F
, 1.0F
);
623 ctx
->Current
.RasterColor
[1]
624 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][1], 0.0F
, 1.0F
);
625 ctx
->Current
.RasterColor
[2]
626 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][2], 0.0F
, 1.0F
);
627 ctx
->Current
.RasterColor
[3]
628 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][3], 0.0F
, 1.0F
);
629 ctx
->Current
.RasterSecondaryColor
[0]
630 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][0], 0.0F
, 1.0F
);
631 ctx
->Current
.RasterSecondaryColor
[1]
632 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][1], 0.0F
, 1.0F
);
633 ctx
->Current
.RasterSecondaryColor
[2]
634 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][2], 0.0F
, 1.0F
);
635 ctx
->Current
.RasterSecondaryColor
[3]
636 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][3], 0.0F
, 1.0F
);
639 ctx
->Current
.RasterIndex
= ctx
->Current
.Index
;
642 /* raster texcoord = current texcoord */
645 for (texSet
= 0; texSet
< ctx
->Const
.MaxTextureCoordUnits
; texSet
++) {
646 COPY_4FV( ctx
->Current
.RasterTexCoords
[texSet
],
647 ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ texSet
] );
651 if (ctx
->RenderMode
==GL_SELECT
) {
652 _mesa_update_hitflag( ctx
, ctx
->Current
.RasterPos
[2] );
657 /* This is just to support the GL_MESA_window_pos version */
659 window_pos4f(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
661 GET_CURRENT_CONTEXT(ctx
);
662 window_pos3f(x
, y
, z
);
663 ctx
->Current
.RasterPos
[3] = w
;
668 _mesa_WindowPos2dMESA(GLdouble x
, GLdouble y
)
670 window_pos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
674 _mesa_WindowPos2fMESA(GLfloat x
, GLfloat y
)
676 window_pos4f(x
, y
, 0.0F
, 1.0F
);
680 _mesa_WindowPos2iMESA(GLint x
, GLint y
)
682 window_pos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
686 _mesa_WindowPos2sMESA(GLshort x
, GLshort y
)
688 window_pos4f(x
, y
, 0.0F
, 1.0F
);
692 _mesa_WindowPos3dMESA(GLdouble x
, GLdouble y
, GLdouble z
)
694 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
698 _mesa_WindowPos3fMESA(GLfloat x
, GLfloat y
, GLfloat z
)
700 window_pos4f(x
, y
, z
, 1.0F
);
704 _mesa_WindowPos3iMESA(GLint x
, GLint y
, GLint z
)
706 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
710 _mesa_WindowPos3sMESA(GLshort x
, GLshort y
, GLshort z
)
712 window_pos4f(x
, y
, z
, 1.0F
);
716 _mesa_WindowPos4dMESA(GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
718 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
722 _mesa_WindowPos4fMESA(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
724 window_pos4f(x
, y
, z
, w
);
728 _mesa_WindowPos4iMESA(GLint x
, GLint y
, GLint z
, GLint w
)
730 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
734 _mesa_WindowPos4sMESA(GLshort x
, GLshort y
, GLshort z
, GLshort w
)
736 window_pos4f(x
, y
, z
, w
);
740 _mesa_WindowPos2dvMESA(const GLdouble
*v
)
742 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
746 _mesa_WindowPos2fvMESA(const GLfloat
*v
)
748 window_pos4f(v
[0], v
[1], 0.0F
, 1.0F
);
752 _mesa_WindowPos2ivMESA(const GLint
*v
)
754 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
758 _mesa_WindowPos2svMESA(const GLshort
*v
)
760 window_pos4f(v
[0], v
[1], 0.0F
, 1.0F
);
764 _mesa_WindowPos3dvMESA(const GLdouble
*v
)
766 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
770 _mesa_WindowPos3fvMESA(const GLfloat
*v
)
772 window_pos4f(v
[0], v
[1], v
[2], 1.0);
776 _mesa_WindowPos3ivMESA(const GLint
*v
)
778 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
782 _mesa_WindowPos3svMESA(const GLshort
*v
)
784 window_pos4f(v
[0], v
[1], v
[2], 1.0F
);
788 _mesa_WindowPos4dvMESA(const GLdouble
*v
)
790 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
791 (GLfloat
) v
[2], (GLfloat
) v
[3]);
795 _mesa_WindowPos4fvMESA(const GLfloat
*v
)
797 window_pos4f(v
[0], v
[1], v
[2], v
[3]);
801 _mesa_WindowPos4ivMESA(const GLint
*v
)
803 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
804 (GLfloat
) v
[2], (GLfloat
) v
[3]);
808 _mesa_WindowPos4svMESA(const GLshort
*v
)
810 window_pos4f(v
[0], v
[1], v
[2], v
[3]);
818 * OpenGL implementation of glWindowPos*MESA()
820 void glWindowPos4fMESA( GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
824 /* Push current matrix mode and viewport attributes */
825 glPushAttrib( GL_TRANSFORM_BIT
| GL_VIEWPORT_BIT
);
827 /* Setup projection parameters */
828 glMatrixMode( GL_PROJECTION
);
831 glMatrixMode( GL_MODELVIEW
);
835 glDepthRange( z
, z
);
836 glViewport( (int) x
- 1, (int) y
- 1, 2, 2 );
838 /* set the raster (window) position */
841 glRasterPos4f( fx
, fy
, 0.0, w
);
843 /* restore matrices, viewport and matrix mode */
845 glMatrixMode( GL_PROJECTION
);
854 /**********************************************************************/
855 /** \name Initialization */
856 /**********************************************************************/
860 * Initialize the context current raster position information.
862 * \param ctx GL context.
864 * Initialize the current raster position information in
865 * __GLcontextRec::Current, and adds the extension entry points to the
868 void _mesa_init_rastpos( GLcontext
* ctx
)
872 ASSIGN_4V( ctx
->Current
.RasterPos
, 0.0, 0.0, 0.0, 1.0 );
873 ctx
->Current
.RasterDistance
= 0.0;
874 ASSIGN_4V( ctx
->Current
.RasterColor
, 1.0, 1.0, 1.0, 1.0 );
875 ctx
->Current
.RasterIndex
= 1.0;
876 for (i
=0; i
<MAX_TEXTURE_UNITS
; i
++)
877 ASSIGN_4V( ctx
->Current
.RasterTexCoords
[i
], 0.0, 0.0, 0.0, 1.0 );
878 ctx
->Current
.RasterPosValid
= GL_TRUE
;
881 * For XFree86/DRI: tell libGL to add these functions to the dispatcher.
882 * Basically, we should add all extension functions above offset 577.
883 * This enables older libGL libraries to work with newer drivers that
884 * have newer extensions.
886 /* GL_ARB_window_pos aliases with GL_MESA_window_pos */
887 _glapi_add_entrypoint("glWindowPos2dARB", 513);
888 _glapi_add_entrypoint("glWindowPos2dvARB", 514);
889 _glapi_add_entrypoint("glWindowPos2fARB", 515);
890 _glapi_add_entrypoint("glWindowPos2fvARB", 516);
891 _glapi_add_entrypoint("glWindowPos2iARB", 517);
892 _glapi_add_entrypoint("glWindowPos2ivARB", 518);
893 _glapi_add_entrypoint("glWindowPos2sARB", 519);
894 _glapi_add_entrypoint("glWindowPos2svARB", 520);
895 _glapi_add_entrypoint("glWindowPos3dARB", 521);
896 _glapi_add_entrypoint("glWindowPos3dvARB", 522);
897 _glapi_add_entrypoint("glWindowPos3fARB", 523);
898 _glapi_add_entrypoint("glWindowPos3fvARB", 524);
899 _glapi_add_entrypoint("glWindowPos3iARB", 525);
900 _glapi_add_entrypoint("glWindowPos3ivARB", 526);
901 _glapi_add_entrypoint("glWindowPos3sARB", 527);
902 _glapi_add_entrypoint("glWindowPos3svARB", 528);