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( ctx
->Light
.Material
[0].Diffuse
[3], 0.0F
, 1.0F
);
144 ASSIGN_4V(specularColor
, 0.0, 0.0, 0.0, 0.0);
146 foreach (light
, &ctx
->Light
.EnabledList
) {
148 GLfloat attenuation
= 1.0;
152 GLfloat diffuseContrib
[3], specularContrib
[3];
153 GLboolean normalized
;
155 if (!(light
->_Flags
& LIGHT_POSITIONAL
)) {
156 COPY_3V(VP
, light
->_VP_inf_norm
);
157 attenuation
= light
->_VP_inf_spot_attenuation
;
162 SUB_3V(VP
, light
->_Position
, vertex
);
163 d
= (GLfloat
) LEN_3FV( VP
);
166 GLfloat invd
= 1.0F
/ d
;
167 SELF_SCALE_SCALAR_3V(VP
, invd
);
169 attenuation
= 1.0F
/ (light
->ConstantAttenuation
+ d
*
170 (light
->LinearAttenuation
+ d
*
171 light
->QuadraticAttenuation
));
173 if (light
->_Flags
& LIGHT_SPOT
) {
174 GLfloat PV_dot_dir
= - DOT3(VP
, light
->_NormDirection
);
176 if (PV_dot_dir
<light
->_CosCutoff
) {
180 double x
= PV_dot_dir
* (EXP_TABLE_SIZE
-1);
182 GLfloat spot
= (GLfloat
) (light
->_SpotExpTable
[k
][0]
183 + (x
-k
)*light
->_SpotExpTable
[k
][1]);
189 if (attenuation
< 1e-3)
192 n_dot_VP
= DOT3( normal
, VP
);
194 if (n_dot_VP
< 0.0F
) {
195 ACC_SCALE_SCALAR_3V(diffuseColor
, attenuation
, light
->_MatAmbient
[0]);
199 COPY_3V(diffuseContrib
, light
->_MatAmbient
[0]);
200 ACC_SCALE_SCALAR_3V(diffuseContrib
, n_dot_VP
, light
->_MatDiffuse
[0]);
201 diffuse
+= n_dot_VP
* light
->_dli
* attenuation
;
202 ASSIGN_3V(specularContrib
, 0.0, 0.0, 0.0);
205 if (ctx
->Light
.Model
.LocalViewer
) {
213 else if (light
->_Flags
& LIGHT_POSITIONAL
) {
215 ACC_3V(h
, ctx
->_EyeZDir
);
219 h
= light
->_h_inf_norm
;
223 n_dot_h
= DOT3(normal
, h
);
225 if (n_dot_h
> 0.0F
) {
226 const struct gl_material
*mat
= &ctx
->Light
.Material
[0];
228 GLfloat shininess
= mat
->Shininess
;
232 n_dot_h
/= LEN_SQUARED_3FV( h
);
236 GET_SHINE_TAB_ENTRY( ctx
->_ShineTable
[0], n_dot_h
, spec_coef
);
238 if (spec_coef
> 1.0e-10) {
239 if (ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
) {
240 ACC_SCALE_SCALAR_3V( specularContrib
, spec_coef
,
241 light
->_MatSpecular
[0]);
244 ACC_SCALE_SCALAR_3V( diffuseContrib
, spec_coef
,
245 light
->_MatSpecular
[0]);
247 specular
+= spec_coef
* light
->_sli
* attenuation
;
252 ACC_SCALE_SCALAR_3V( diffuseColor
, attenuation
, diffuseContrib
);
253 ACC_SCALE_SCALAR_3V( specularColor
, attenuation
, specularContrib
);
256 if (ctx
->Visual
.rgbMode
) {
257 Rcolor
[0] = CLAMP(diffuseColor
[0], 0.0F
, 1.0F
);
258 Rcolor
[1] = CLAMP(diffuseColor
[1], 0.0F
, 1.0F
);
259 Rcolor
[2] = CLAMP(diffuseColor
[2], 0.0F
, 1.0F
);
260 Rcolor
[3] = CLAMP(diffuseColor
[3], 0.0F
, 1.0F
);
261 Rspec
[0] = CLAMP(specularColor
[0], 0.0F
, 1.0F
);
262 Rspec
[1] = CLAMP(specularColor
[1], 0.0F
, 1.0F
);
263 Rspec
[2] = CLAMP(specularColor
[2], 0.0F
, 1.0F
);
264 Rspec
[3] = CLAMP(specularColor
[3], 0.0F
, 1.0F
);
267 struct gl_material
*mat
= &ctx
->Light
.Material
[0];
268 GLfloat d_a
= mat
->DiffuseIndex
- mat
->AmbientIndex
;
269 GLfloat s_a
= mat
->SpecularIndex
- mat
->AmbientIndex
;
270 GLfloat ind
= mat
->AmbientIndex
271 + diffuse
* (1.0F
-specular
) * d_a
273 if (ind
> mat
->SpecularIndex
) {
274 ind
= mat
->SpecularIndex
;
276 *Rindex
= (GLuint
) (GLint
) ind
;
282 * Set the raster position for pixel operations.
284 * All glRasterPos command call this function to update the current
287 * \param ctx GL context.
288 * \param x x coordinate for the raster position.
289 * \param y y coordinate for the raster position.
290 * \param z z coordinate for the raster position.
291 * \param w w coordinate for the raster position.
293 * \sa Called by _mesa_RasterPos4f().
295 * Flushes the vertices, transforms and clips the vertex coordinates, and
296 * finally sets the current raster position and associated data in
297 * __GLcontextRec::Current. When in selection mode calls
298 * _mesa_update_hitflag() with the current raster position.
301 raster_pos4f(GLcontext
*ctx
, GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
303 GLfloat v
[4], eye
[4], clip
[4], ndc
[3], d
;
304 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
305 FLUSH_CURRENT(ctx
, 0);
308 _mesa_update_state( ctx
);
310 if (ctx
->VertexProgram
.Enabled
) {
311 /* XXX implement this */
312 _mesa_problem(ctx
, "Vertex programs not implemented for glRasterPos");
316 ASSIGN_4V( v
, x
, y
, z
, w
);
317 TRANSFORM_POINT( eye
, ctx
->ModelviewMatrixStack
.Top
->m
, v
);
320 if (ctx
->Light
.Enabled
) {
321 GLfloat
*norm
, eyenorm
[3];
322 GLfloat
*objnorm
= ctx
->Current
.Attrib
[VERT_ATTRIB_NORMAL
];
324 if (ctx
->_NeedEyeCoords
) {
325 GLfloat
*inv
= ctx
->ModelviewMatrixStack
.Top
->inv
;
326 TRANSFORM_NORMAL( eyenorm
, objnorm
, inv
);
333 shade_rastpos( ctx
, v
, norm
,
334 ctx
->Current
.RasterColor
,
335 ctx
->Current
.RasterSecondaryColor
,
336 &ctx
->Current
.RasterIndex
);
339 /* use current color or index */
340 if (ctx
->Visual
.rgbMode
) {
341 COPY_4FV(ctx
->Current
.RasterColor
,
342 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
]);
343 COPY_4FV(ctx
->Current
.RasterSecondaryColor
,
344 ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
]);
347 ctx
->Current
.RasterIndex
= ctx
->Current
.Index
;
351 /* compute raster distance */
352 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
)
353 ctx
->Current
.RasterDistance
= ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0];
355 ctx
->Current
.RasterDistance
=
356 SQRTF( eye
[0]*eye
[0] + eye
[1]*eye
[1] + eye
[2]*eye
[2] );
358 /* apply projection matrix: clip = Proj * eye */
359 TRANSFORM_POINT( clip
, ctx
->ProjectionMatrixStack
.Top
->m
, eye
);
361 /* clip to view volume */
362 if (ctx
->Transform
.RasterPositionUnclipped
) {
363 /* GL_IBM_rasterpos_clip: only clip against Z */
364 if (viewclip_point_z(clip
) == 0) {
365 ctx
->Current
.RasterPosValid
= GL_FALSE
;
369 else if (viewclip_point(clip
) == 0) {
370 /* Normal OpenGL behaviour */
371 ctx
->Current
.RasterPosValid
= GL_FALSE
;
375 /* clip to user clipping planes */
376 if (ctx
->Transform
.ClipPlanesEnabled
&& !userclip_point(ctx
, clip
)) {
377 ctx
->Current
.RasterPosValid
= GL_FALSE
;
382 d
= (clip
[3] == 0.0) ? 1.0 : 1.0F
/ clip
[3];
383 ndc
[0] = clip
[0] * d
;
384 ndc
[1] = clip
[1] * d
;
385 ndc
[2] = clip
[2] * d
;
387 ctx
->Current
.RasterPos
[0] = (ndc
[0] * ctx
->Viewport
._WindowMap
.m
[MAT_SX
] +
388 ctx
->Viewport
._WindowMap
.m
[MAT_TX
]);
389 ctx
->Current
.RasterPos
[1] = (ndc
[1] * ctx
->Viewport
._WindowMap
.m
[MAT_SY
] +
390 ctx
->Viewport
._WindowMap
.m
[MAT_TY
]);
391 ctx
->Current
.RasterPos
[2] = (ndc
[2] * ctx
->Viewport
._WindowMap
.m
[MAT_SZ
] +
392 ctx
->Viewport
._WindowMap
.m
[MAT_TZ
]) / ctx
->DepthMaxF
;
393 ctx
->Current
.RasterPos
[3] = clip
[3];
394 ctx
->Current
.RasterPosValid
= GL_TRUE
;
398 for (texSet
= 0; texSet
< ctx
->Const
.MaxTextureCoordUnits
; texSet
++) {
399 COPY_4FV( ctx
->Current
.RasterTexCoords
[texSet
],
400 ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ texSet
] );
406 if (ctx
->RenderMode
==GL_SELECT
) {
407 _mesa_update_hitflag( ctx
, ctx
->Current
.RasterPos
[2] );
412 /** Calls _mesa_RasterPos4f() */
414 _mesa_RasterPos2d(GLdouble x
, GLdouble y
)
416 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
419 /** Calls _mesa_RasterPos4f() */
421 _mesa_RasterPos2f(GLfloat x
, GLfloat y
)
423 _mesa_RasterPos4f(x
, y
, 0.0F
, 1.0F
);
426 /** Calls _mesa_RasterPos4f() */
428 _mesa_RasterPos2i(GLint x
, GLint y
)
430 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
433 /** Calls _mesa_RasterPos4f() */
435 _mesa_RasterPos2s(GLshort x
, GLshort y
)
437 _mesa_RasterPos4f(x
, y
, 0.0F
, 1.0F
);
440 /** Calls _mesa_RasterPos4f() */
442 _mesa_RasterPos3d(GLdouble x
, GLdouble y
, GLdouble z
)
444 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
447 /** Calls _mesa_RasterPos4f() */
449 _mesa_RasterPos3f(GLfloat x
, GLfloat y
, GLfloat z
)
451 _mesa_RasterPos4f(x
, y
, z
, 1.0F
);
454 /** Calls _mesa_RasterPos4f() */
456 _mesa_RasterPos3i(GLint x
, GLint y
, GLint z
)
458 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
461 /** Calls _mesa_RasterPos4f() */
463 _mesa_RasterPos3s(GLshort x
, GLshort y
, GLshort z
)
465 _mesa_RasterPos4f(x
, y
, z
, 1.0F
);
468 /** Calls _mesa_RasterPos4f() */
470 _mesa_RasterPos4d(GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
472 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
475 /** Calls raster_pos4f() */
477 _mesa_RasterPos4f(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
479 GET_CURRENT_CONTEXT(ctx
);
480 raster_pos4f(ctx
, x
, y
, z
, w
);
483 /** Calls _mesa_RasterPos4f() */
485 _mesa_RasterPos4i(GLint x
, GLint y
, GLint z
, GLint w
)
487 _mesa_RasterPos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
490 /** Calls _mesa_RasterPos4f() */
492 _mesa_RasterPos4s(GLshort x
, GLshort y
, GLshort z
, GLshort w
)
494 _mesa_RasterPos4f(x
, y
, z
, w
);
497 /** Calls _mesa_RasterPos4f() */
499 _mesa_RasterPos2dv(const GLdouble
*v
)
501 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
504 /** Calls _mesa_RasterPos4f() */
506 _mesa_RasterPos2fv(const GLfloat
*v
)
508 _mesa_RasterPos4f(v
[0], v
[1], 0.0F
, 1.0F
);
511 /** Calls _mesa_RasterPos4f() */
513 _mesa_RasterPos2iv(const GLint
*v
)
515 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
518 /** Calls _mesa_RasterPos4f() */
520 _mesa_RasterPos2sv(const GLshort
*v
)
522 _mesa_RasterPos4f(v
[0], v
[1], 0.0F
, 1.0F
);
525 /** Calls _mesa_RasterPos4f() */
527 _mesa_RasterPos3dv(const GLdouble
*v
)
529 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
532 /** Calls _mesa_RasterPos4f() */
534 _mesa_RasterPos3fv(const GLfloat
*v
)
536 _mesa_RasterPos4f(v
[0], v
[1], v
[2], 1.0F
);
539 /** Calls _mesa_RasterPos4f() */
541 _mesa_RasterPos3iv(const GLint
*v
)
543 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
546 /** Calls _mesa_RasterPos4f() */
548 _mesa_RasterPos3sv(const GLshort
*v
)
550 _mesa_RasterPos4f(v
[0], v
[1], v
[2], 1.0F
);
553 /** Calls _mesa_RasterPos4f() */
555 _mesa_RasterPos4dv(const GLdouble
*v
)
557 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
558 (GLfloat
) v
[2], (GLfloat
) v
[3]);
561 /** Calls _mesa_RasterPos4f() */
563 _mesa_RasterPos4fv(const GLfloat
*v
)
565 _mesa_RasterPos4f(v
[0], v
[1], v
[2], v
[3]);
568 /** Calls _mesa_RasterPos4f() */
570 _mesa_RasterPos4iv(const GLint
*v
)
572 _mesa_RasterPos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
573 (GLfloat
) v
[2], (GLfloat
) v
[3]);
576 /** Calls _mesa_RasterPos4f() */
578 _mesa_RasterPos4sv(const GLshort
*v
)
580 _mesa_RasterPos4f(v
[0], v
[1], v
[2], v
[3]);
584 /**********************************************************************/
585 /*** GL_ARB_window_pos / GL_MESA_window_pos ***/
586 /**********************************************************************/
588 #if FEATURE_windowpos
590 * All glWindowPosMESA and glWindowPosARB commands call this function to
591 * update the current raster position.
594 window_pos3f(GLfloat x
, GLfloat y
, GLfloat z
)
596 GET_CURRENT_CONTEXT(ctx
);
599 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
600 FLUSH_CURRENT(ctx
, 0);
602 z2
= CLAMP(z
, 0.0F
, 1.0F
) * (ctx
->Viewport
.Far
- ctx
->Viewport
.Near
)
603 + ctx
->Viewport
.Near
;
605 /* set raster position */
606 ctx
->Current
.RasterPos
[0] = x
;
607 ctx
->Current
.RasterPos
[1] = y
;
608 ctx
->Current
.RasterPos
[2] = z2
;
609 ctx
->Current
.RasterPos
[3] = 1.0F
;
611 ctx
->Current
.RasterPosValid
= GL_TRUE
;
613 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
)
614 ctx
->Current
.RasterDistance
= ctx
->Current
.Attrib
[VERT_ATTRIB_FOG
][0];
616 ctx
->Current
.RasterDistance
= 0.0;
618 /* raster color = current color or index */
619 if (ctx
->Visual
.rgbMode
) {
620 ctx
->Current
.RasterColor
[0]
621 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][0], 0.0F
, 1.0F
);
622 ctx
->Current
.RasterColor
[1]
623 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][1], 0.0F
, 1.0F
);
624 ctx
->Current
.RasterColor
[2]
625 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][2], 0.0F
, 1.0F
);
626 ctx
->Current
.RasterColor
[3]
627 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR0
][3], 0.0F
, 1.0F
);
628 ctx
->Current
.RasterSecondaryColor
[0]
629 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][0], 0.0F
, 1.0F
);
630 ctx
->Current
.RasterSecondaryColor
[1]
631 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][1], 0.0F
, 1.0F
);
632 ctx
->Current
.RasterSecondaryColor
[2]
633 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][2], 0.0F
, 1.0F
);
634 ctx
->Current
.RasterSecondaryColor
[3]
635 = CLAMP(ctx
->Current
.Attrib
[VERT_ATTRIB_COLOR1
][3], 0.0F
, 1.0F
);
638 ctx
->Current
.RasterIndex
= ctx
->Current
.Index
;
641 /* raster texcoord = current texcoord */
644 for (texSet
= 0; texSet
< ctx
->Const
.MaxTextureCoordUnits
; texSet
++) {
645 COPY_4FV( ctx
->Current
.RasterTexCoords
[texSet
],
646 ctx
->Current
.Attrib
[VERT_ATTRIB_TEX0
+ texSet
] );
650 if (ctx
->RenderMode
==GL_SELECT
) {
651 _mesa_update_hitflag( ctx
, ctx
->Current
.RasterPos
[2] );
656 /* This is just to support the GL_MESA_window_pos version */
658 window_pos4f(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
660 GET_CURRENT_CONTEXT(ctx
);
661 window_pos3f(x
, y
, z
);
662 ctx
->Current
.RasterPos
[3] = w
;
667 _mesa_WindowPos2dMESA(GLdouble x
, GLdouble y
)
669 window_pos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
673 _mesa_WindowPos2fMESA(GLfloat x
, GLfloat y
)
675 window_pos4f(x
, y
, 0.0F
, 1.0F
);
679 _mesa_WindowPos2iMESA(GLint x
, GLint y
)
681 window_pos4f((GLfloat
) x
, (GLfloat
) y
, 0.0F
, 1.0F
);
685 _mesa_WindowPos2sMESA(GLshort x
, GLshort y
)
687 window_pos4f(x
, y
, 0.0F
, 1.0F
);
691 _mesa_WindowPos3dMESA(GLdouble x
, GLdouble y
, GLdouble z
)
693 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
697 _mesa_WindowPos3fMESA(GLfloat x
, GLfloat y
, GLfloat z
)
699 window_pos4f(x
, y
, z
, 1.0F
);
703 _mesa_WindowPos3iMESA(GLint x
, GLint y
, GLint z
)
705 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, 1.0F
);
709 _mesa_WindowPos3sMESA(GLshort x
, GLshort y
, GLshort z
)
711 window_pos4f(x
, y
, z
, 1.0F
);
715 _mesa_WindowPos4dMESA(GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
717 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
721 _mesa_WindowPos4fMESA(GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
723 window_pos4f(x
, y
, z
, w
);
727 _mesa_WindowPos4iMESA(GLint x
, GLint y
, GLint z
, GLint w
)
729 window_pos4f((GLfloat
) x
, (GLfloat
) y
, (GLfloat
) z
, (GLfloat
) w
);
733 _mesa_WindowPos4sMESA(GLshort x
, GLshort y
, GLshort z
, GLshort w
)
735 window_pos4f(x
, y
, z
, w
);
739 _mesa_WindowPos2dvMESA(const GLdouble
*v
)
741 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
745 _mesa_WindowPos2fvMESA(const GLfloat
*v
)
747 window_pos4f(v
[0], v
[1], 0.0F
, 1.0F
);
751 _mesa_WindowPos2ivMESA(const GLint
*v
)
753 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], 0.0F
, 1.0F
);
757 _mesa_WindowPos2svMESA(const GLshort
*v
)
759 window_pos4f(v
[0], v
[1], 0.0F
, 1.0F
);
763 _mesa_WindowPos3dvMESA(const GLdouble
*v
)
765 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
769 _mesa_WindowPos3fvMESA(const GLfloat
*v
)
771 window_pos4f(v
[0], v
[1], v
[2], 1.0);
775 _mesa_WindowPos3ivMESA(const GLint
*v
)
777 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1], (GLfloat
) v
[2], 1.0F
);
781 _mesa_WindowPos3svMESA(const GLshort
*v
)
783 window_pos4f(v
[0], v
[1], v
[2], 1.0F
);
787 _mesa_WindowPos4dvMESA(const GLdouble
*v
)
789 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
790 (GLfloat
) v
[2], (GLfloat
) v
[3]);
794 _mesa_WindowPos4fvMESA(const GLfloat
*v
)
796 window_pos4f(v
[0], v
[1], v
[2], v
[3]);
800 _mesa_WindowPos4ivMESA(const GLint
*v
)
802 window_pos4f((GLfloat
) v
[0], (GLfloat
) v
[1],
803 (GLfloat
) v
[2], (GLfloat
) v
[3]);
807 _mesa_WindowPos4svMESA(const GLshort
*v
)
809 window_pos4f(v
[0], v
[1], v
[2], v
[3]);
817 * OpenGL implementation of glWindowPos*MESA()
819 void glWindowPos4fMESA( GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
823 /* Push current matrix mode and viewport attributes */
824 glPushAttrib( GL_TRANSFORM_BIT
| GL_VIEWPORT_BIT
);
826 /* Setup projection parameters */
827 glMatrixMode( GL_PROJECTION
);
830 glMatrixMode( GL_MODELVIEW
);
834 glDepthRange( z
, z
);
835 glViewport( (int) x
- 1, (int) y
- 1, 2, 2 );
837 /* set the raster (window) position */
840 glRasterPos4f( fx
, fy
, 0.0, w
);
842 /* restore matrices, viewport and matrix mode */
844 glMatrixMode( GL_PROJECTION
);
853 /**********************************************************************/
854 /** \name Initialization */
855 /**********************************************************************/
859 * Initialize the context current raster position information.
861 * \param ctx GL context.
863 * Initialize the current raster position information in
864 * __GLcontextRec::Current, and adds the extension entry points to the
867 void _mesa_init_rastpos( GLcontext
* ctx
)
871 ASSIGN_4V( ctx
->Current
.RasterPos
, 0.0, 0.0, 0.0, 1.0 );
872 ctx
->Current
.RasterDistance
= 0.0;
873 ASSIGN_4V( ctx
->Current
.RasterColor
, 1.0, 1.0, 1.0, 1.0 );
874 ctx
->Current
.RasterIndex
= 1;
875 for (i
=0; i
<MAX_TEXTURE_UNITS
; i
++)
876 ASSIGN_4V( ctx
->Current
.RasterTexCoords
[i
], 0.0, 0.0, 0.0, 1.0 );
877 ctx
->Current
.RasterPosValid
= GL_TRUE
;
880 * For XFree86/DRI: tell libGL to add these functions to the dispatcher.
881 * Basically, we should add all extension functions above offset 577.
882 * This enables older libGL libraries to work with newer drivers that
883 * have newer extensions.
885 /* GL_ARB_window_pos aliases with GL_MESA_window_pos */
886 _glapi_add_entrypoint("glWindowPos2dARB", 513);
887 _glapi_add_entrypoint("glWindowPos2dvARB", 514);
888 _glapi_add_entrypoint("glWindowPos2fARB", 515);
889 _glapi_add_entrypoint("glWindowPos2fvARB", 516);
890 _glapi_add_entrypoint("glWindowPos2iARB", 517);
891 _glapi_add_entrypoint("glWindowPos2ivARB", 518);
892 _glapi_add_entrypoint("glWindowPos2sARB", 519);
893 _glapi_add_entrypoint("glWindowPos2svARB", 520);
894 _glapi_add_entrypoint("glWindowPos3dARB", 521);
895 _glapi_add_entrypoint("glWindowPos3dvARB", 522);
896 _glapi_add_entrypoint("glWindowPos3fARB", 523);
897 _glapi_add_entrypoint("glWindowPos3fvARB", 524);
898 _glapi_add_entrypoint("glWindowPos3iARB", 525);
899 _glapi_add_entrypoint("glWindowPos3ivARB", 526);
900 _glapi_add_entrypoint("glWindowPos3sARB", 527);
901 _glapi_add_entrypoint("glWindowPos3svARB", 528);