rastpos.c revision ac541734146071e279a8c379bce98f40195069e5
1/* $Id: rastpos.c,v 1.29 2001/07/05 15:31:21 brianp Exp $ */
2
3/*
4 * Mesa 3-D graphics library
5 * Version:  3.5
6 *
7 * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27
28#ifdef PC_HEADER
29#include "all.h"
30#else
31#include "glheader.h"
32#include "clip.h"
33#include "colormac.h"
34#include "context.h"
35#include "feedback.h"
36#include "light.h"
37#include "macros.h"
38#include "mmath.h"
39#include "rastpos.h"
40#include "state.h"
41#include "simple_list.h"
42#include "mtypes.h"
43
44#include "math/m_matrix.h"
45#include "math/m_xform.h"
46#endif
47
48
49/*
50 * Clip a point against the view volume.
51 * Input:  v - vertex-vector describing the point to clip
52 * Return:  0 = outside view volume
53 *          1 = inside view volume
54 */
55static GLuint
56viewclip_point( const GLfloat v[] )
57{
58   if (   v[0] > v[3] || v[0] < -v[3]
59       || v[1] > v[3] || v[1] < -v[3]
60       || v[2] > v[3] || v[2] < -v[3] ) {
61      return 0;
62   }
63   else {
64      return 1;
65   }
66}
67
68
69/* As above, but only clip test against far/near Z planes */
70static GLuint
71viewclip_point_z( const GLfloat v[] )
72{
73   if (v[2] > v[3] || v[2] < -v[3] ) {
74      return 0;
75   }
76   else {
77      return 1;
78   }
79}
80
81
82
83/*
84 * Clip a point against the user clipping planes.
85 * Input:  v - vertex-vector describing the point to clip.
86 * Return:  0 = point was clipped
87 *          1 = point not clipped
88 */
89static GLuint
90userclip_point( GLcontext* ctx, const GLfloat v[] )
91{
92   GLuint p;
93
94   for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
95      if (ctx->Transform.ClipEnabled[p]) {
96	 GLfloat dot = v[0] * ctx->Transform._ClipUserPlane[p][0]
97		     + v[1] * ctx->Transform._ClipUserPlane[p][1]
98		     + v[2] * ctx->Transform._ClipUserPlane[p][2]
99		     + v[3] * ctx->Transform._ClipUserPlane[p][3];
100         if (dot < 0.0F) {
101            return 0;
102         }
103      }
104   }
105
106   return 1;
107}
108
109
110/* This has been split off to allow the normal shade routines to
111 * get a little closer to the vertex buffer, and to use the
112 * GLvector objects directly.
113 * Input: ctx - the context
114 *        vertex - vertex location
115 *        normal - normal vector
116 * Output: Rcolor - returned color
117 *         Rspec  - returned specular color (if separate specular enabled)
118 *         Rindex - returned color index
119 */
120static void
121shade_rastpos(GLcontext *ctx,
122              const GLfloat vertex[4],
123              const GLfloat normal[3],
124              GLfloat Rcolor[4],
125              GLfloat Rspec[4],
126              GLuint *Rindex)
127{
128   GLfloat (*base)[3] = ctx->Light._BaseColor;
129   const GLfloat *sumA = ctx->Light._BaseAlpha;
130   struct gl_light *light;
131   GLfloat diffuseColor[4], specularColor[4];
132   GLfloat diffuse = 0, specular = 0;
133
134   if (!ctx->_ShineTable[0] || !ctx->_ShineTable[1])
135      _mesa_validate_all_lighting_tables( ctx );
136
137   COPY_3V(diffuseColor, base[0]);
138   diffuseColor[3] = sumA[0];
139   ASSIGN_4V(specularColor, 0.0, 0.0, 0.0, 0.0);
140
141   foreach (light, &ctx->Light.EnabledList) {
142      GLfloat n_dot_h;
143      GLfloat attenuation = 1.0;
144      GLfloat VP[3];
145      GLfloat n_dot_VP;
146      GLfloat *h;
147      GLfloat diffuseContrib[3], specularContrib[3];
148      GLboolean normalized;
149
150      if (!(light->_Flags & LIGHT_POSITIONAL)) {
151	 COPY_3V(VP, light->_VP_inf_norm);
152	 attenuation = light->_VP_inf_spot_attenuation;
153      }
154      else {
155	 GLfloat d;
156
157	 SUB_3V(VP, light->_Position, vertex);
158	 d = LEN_3FV( VP );
159
160	 if ( d > 1e-6) {
161	    GLfloat invd = 1.0F / d;
162	    SELF_SCALE_SCALAR_3V(VP, invd);
163	 }
164	 attenuation = 1.0F / (light->ConstantAttenuation + d *
165			       (light->LinearAttenuation + d *
166				light->QuadraticAttenuation));
167
168	 if (light->_Flags & LIGHT_SPOT) {
169	    GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
170
171	    if (PV_dot_dir<light->_CosCutoff) {
172	       continue;
173	    }
174	    else {
175	       double x = PV_dot_dir * (EXP_TABLE_SIZE-1);
176	       int k = (int) x;
177	       GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
178			       + (x-k)*light->_SpotExpTable[k][1]);
179	       attenuation *= spot;
180	    }
181	 }
182      }
183
184      if (attenuation < 1e-3)
185	 continue;
186
187      n_dot_VP = DOT3( normal, VP );
188
189      if (n_dot_VP < 0.0F) {
190	 ACC_SCALE_SCALAR_3V(diffuseColor, attenuation, light->_MatAmbient[0]);
191	 continue;
192      }
193
194      COPY_3V(diffuseContrib, light->_MatAmbient[0]);
195      ACC_SCALE_SCALAR_3V(diffuseContrib, n_dot_VP, light->_MatDiffuse[0]);
196      diffuse += n_dot_VP * light->_dli * attenuation;
197      ASSIGN_3V(specularContrib, 0.0, 0.0, 0.0);
198
199      {
200	 if (ctx->Light.Model.LocalViewer) {
201	    GLfloat v[3];
202	    COPY_3V(v, vertex);
203	    NORMALIZE_3FV(v);
204	    SUB_3V(VP, VP, v);
205	    h = VP;
206	    normalized = 0;
207	 }
208	 else if (light->_Flags & LIGHT_POSITIONAL) {
209	    h = VP;
210	    ACC_3V(h, ctx->_EyeZDir);
211	    normalized = 0;
212	 }
213         else {
214	    h = light->_h_inf_norm;
215	    normalized = 1;
216	 }
217
218	 n_dot_h = DOT3(normal, h);
219
220	 if (n_dot_h > 0.0F) {
221	    const struct gl_material *mat = &ctx->Light.Material[0];
222	    GLfloat spec_coef;
223	    GLfloat shininess = mat->Shininess;
224
225	    if (!normalized) {
226	       n_dot_h *= n_dot_h;
227	       n_dot_h /= LEN_SQUARED_3FV( h );
228	       shininess *= .5;
229	    }
230
231	    GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec_coef );
232
233	    if (spec_coef > 1.0e-10) {
234               if (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) {
235                  ACC_SCALE_SCALAR_3V( specularContrib, spec_coef,
236                                       light->_MatSpecular[0]);
237               }
238               else {
239                  ACC_SCALE_SCALAR_3V( diffuseContrib, spec_coef,
240                                       light->_MatSpecular[0]);
241               }
242	       specular += spec_coef * light->_sli * attenuation;
243	    }
244	 }
245      }
246
247      ACC_SCALE_SCALAR_3V( diffuseColor, attenuation, diffuseContrib );
248      ACC_SCALE_SCALAR_3V( specularColor, attenuation, specularContrib );
249   }
250
251   if (ctx->Visual.rgbMode) {
252      Rcolor[0] = CLAMP(diffuseColor[0], 0.0F, 1.0F);
253      Rcolor[1] = CLAMP(diffuseColor[1], 0.0F, 1.0F);
254      Rcolor[2] = CLAMP(diffuseColor[2], 0.0F, 1.0F);
255      Rcolor[3] = CLAMP(diffuseColor[3], 0.0F, 1.0F);
256      Rspec[0] = CLAMP(specularColor[0], 0.0F, 1.0F);
257      Rspec[1] = CLAMP(specularColor[1], 0.0F, 1.0F);
258      Rspec[2] = CLAMP(specularColor[2], 0.0F, 1.0F);
259      Rspec[3] = CLAMP(specularColor[3], 0.0F, 1.0F);
260   }
261   else {
262      struct gl_material *mat = &ctx->Light.Material[0];
263      GLfloat d_a = mat->DiffuseIndex - mat->AmbientIndex;
264      GLfloat s_a = mat->SpecularIndex - mat->AmbientIndex;
265      GLfloat ind = mat->AmbientIndex
266                  + diffuse * (1.0F-specular) * d_a
267                  + specular * s_a;
268      if (ind > mat->SpecularIndex) {
269	 ind = mat->SpecularIndex;
270      }
271      *Rindex = (GLuint) (GLint) ind;
272   }
273
274}
275
276/*
277 * Caller:  context->API.RasterPos4f
278 */
279static void
280raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
281{
282   GLfloat v[4], eye[4], clip[4], ndc[3], d;
283   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
284   FLUSH_CURRENT(ctx, 0);
285
286   if (ctx->NewState)
287      _mesa_update_state( ctx );
288
289   ASSIGN_4V( v, x, y, z, w );
290   TRANSFORM_POINT( eye, ctx->ModelView.m, v );
291
292   /* raster color */
293   if (ctx->Light.Enabled) {
294      GLfloat *norm, eyenorm[3];
295      GLfloat *objnorm = ctx->Current.Normal;
296
297      if (ctx->_NeedEyeCoords) {
298	 GLfloat *inv = ctx->ModelView.inv;
299	 TRANSFORM_NORMAL( eyenorm, objnorm, inv );
300	 norm = eyenorm;
301      }
302      else {
303	 norm = objnorm;
304      }
305
306      shade_rastpos( ctx, v, norm,
307                     ctx->Current.RasterColor,
308                     ctx->Current.RasterSecondaryColor,
309                     &ctx->Current.RasterIndex );
310
311   }
312   else {
313      /* use current color or index */
314      if (ctx->Visual.rgbMode) {
315         COPY_4FV(ctx->Current.RasterColor, ctx->Current.Color);
316         COPY_4FV(ctx->Current.RasterSecondaryColor,
317                  ctx->Current.SecondaryColor);
318      }
319      else {
320	 ctx->Current.RasterIndex = ctx->Current.Index;
321      }
322   }
323
324   /* compute raster distance */
325   ctx->Current.RasterDistance = (GLfloat)
326                      GL_SQRT( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] );
327
328   /* apply projection matrix:  clip = Proj * eye */
329   TRANSFORM_POINT( clip, ctx->ProjectionMatrix.m, eye );
330
331   /* clip to view volume */
332   if (ctx->Transform.RasterPositionUnclipped) {
333      /* GL_IBM_rasterpos_clip: only clip against Z */
334      if (viewclip_point_z(clip) == 0)
335         ctx->Current.RasterPosValid = GL_FALSE;
336   }
337   else if (viewclip_point(clip) == 0) {
338      /* Normal OpenGL behaviour */
339      ctx->Current.RasterPosValid = GL_FALSE;
340      return;
341   }
342
343   /* clip to user clipping planes */
344   if (ctx->Transform._AnyClip &&
345       userclip_point(ctx, clip) == 0) {
346      ctx->Current.RasterPosValid = GL_FALSE;
347      return;
348   }
349
350   /* ndc = clip / W */
351   ASSERT( clip[3]!=0.0 );
352   d = 1.0F / clip[3];
353   ndc[0] = clip[0] * d;
354   ndc[1] = clip[1] * d;
355   ndc[2] = clip[2] * d;
356
357   ctx->Current.RasterPos[0] = (ndc[0] * ctx->Viewport._WindowMap.m[MAT_SX] +
358				ctx->Viewport._WindowMap.m[MAT_TX]);
359   ctx->Current.RasterPos[1] = (ndc[1] * ctx->Viewport._WindowMap.m[MAT_SY] +
360				ctx->Viewport._WindowMap.m[MAT_TY]);
361   ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport._WindowMap.m[MAT_SZ] +
362				ctx->Viewport._WindowMap.m[MAT_TZ]) / ctx->DepthMaxF;
363   ctx->Current.RasterPos[3] = clip[3];
364   ctx->Current.RasterPosValid = GL_TRUE;
365
366   ctx->Current.RasterFogCoord = ctx->Current.FogCoord;
367
368   {
369      GLuint texSet;
370      for (texSet = 0; texSet < ctx->Const.MaxTextureUnits; texSet++) {
371         COPY_4FV( ctx->Current.RasterMultiTexCoord[texSet],
372                  ctx->Current.Texcoord[texSet] );
373      }
374   }
375
376   if (ctx->RenderMode==GL_SELECT) {
377      _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] );
378   }
379
380}
381
382
383
384void
385_mesa_RasterPos2d(GLdouble x, GLdouble y)
386{
387   _mesa_RasterPos4f(x, y, 0.0F, 1.0F);
388}
389
390void
391_mesa_RasterPos2f(GLfloat x, GLfloat y)
392{
393   _mesa_RasterPos4f(x, y, 0.0F, 1.0F);
394}
395
396void
397_mesa_RasterPos2i(GLint x, GLint y)
398{
399   _mesa_RasterPos4f(x, y, 0.0F, 1.0F);
400}
401
402void
403_mesa_RasterPos2s(GLshort x, GLshort y)
404{
405   _mesa_RasterPos4f(x, y, 0.0F, 1.0F);
406}
407
408void
409_mesa_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
410{
411   _mesa_RasterPos4f(x, y, z, 1.0F);
412}
413
414void
415_mesa_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
416{
417   _mesa_RasterPos4f(x, y, z, 1.0F);
418}
419
420void
421_mesa_RasterPos3i(GLint x, GLint y, GLint z)
422{
423   _mesa_RasterPos4f(x, y, z, 1.0F);
424}
425
426void
427_mesa_RasterPos3s(GLshort x, GLshort y, GLshort z)
428{
429   _mesa_RasterPos4f(x, y, z, 1.0F);
430}
431
432void
433_mesa_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
434{
435   _mesa_RasterPos4f(x, y, z, w);
436}
437
438void
439_mesa_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
440{
441   GET_CURRENT_CONTEXT(ctx);
442   raster_pos4f(ctx, x, y, z, w);
443}
444
445void
446_mesa_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
447{
448   _mesa_RasterPos4f(x, y, z, w);
449}
450
451void
452_mesa_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
453{
454   _mesa_RasterPos4f(x, y, z, w);
455}
456
457void
458_mesa_RasterPos2dv(const GLdouble *v)
459{
460   _mesa_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
461}
462
463void
464_mesa_RasterPos2fv(const GLfloat *v)
465{
466   _mesa_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
467}
468
469void
470_mesa_RasterPos2iv(const GLint *v)
471{
472   _mesa_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
473}
474
475void
476_mesa_RasterPos2sv(const GLshort *v)
477{
478   _mesa_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
479}
480
481void
482_mesa_RasterPos3dv(const GLdouble *v)
483{
484   _mesa_RasterPos4f(v[0], v[1], v[2], 1.0F);
485}
486
487void
488_mesa_RasterPos3fv(const GLfloat *v)
489{
490   _mesa_RasterPos4f(v[0], v[1], v[2], 1.0F);
491}
492
493void
494_mesa_RasterPos3iv(const GLint *v)
495{
496   _mesa_RasterPos4f(v[0], v[1], v[2], 1.0F);
497}
498
499void
500_mesa_RasterPos3sv(const GLshort *v)
501{
502   _mesa_RasterPos4f(v[0], v[1], v[2], 1.0F);
503}
504
505void
506_mesa_RasterPos4dv(const GLdouble *v)
507{
508   _mesa_RasterPos4f(v[0], v[1], v[2], v[3]);
509}
510
511void
512_mesa_RasterPos4fv(const GLfloat *v)
513{
514   _mesa_RasterPos4f(v[0], v[1], v[2], v[3]);
515}
516
517void
518_mesa_RasterPos4iv(const GLint *v)
519{
520   _mesa_RasterPos4f(v[0], v[1], v[2], v[3]);
521}
522
523void
524_mesa_RasterPos4sv(const GLshort *v)
525{
526   _mesa_RasterPos4f(v[0], v[1], v[2], v[3]);
527}
528
529
530
531/**********************************************************************/
532/***                     GL_MESA_window_pos                         ***/
533/**********************************************************************/
534
535
536/*
537 * This is a MESA extension function.  Pretty much just like glRasterPos
538 * except we don't apply the modelview or projection matrices; specify a
539 * window coordinate directly.
540 * Caller:  context->API.WindowPos4fMESA pointer.
541 */
542void
543_mesa_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
544{
545   GET_CURRENT_CONTEXT(ctx);
546   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
547   FLUSH_CURRENT(ctx, 0);
548
549   /* set raster position */
550   ctx->Current.RasterPos[0] = x;
551   ctx->Current.RasterPos[1] = y;
552   ctx->Current.RasterPos[2] = CLAMP( z, 0.0F, 1.0F );
553   ctx->Current.RasterPos[3] = w;
554
555   ctx->Current.RasterPosValid = GL_TRUE;
556   ctx->Current.RasterDistance = 0.0F;
557   ctx->Current.RasterFogCoord = 0.0F;
558
559   /* raster color = current color or index */
560   if (ctx->Visual.rgbMode) {
561      ctx->Current.RasterColor[0] = (ctx->Current.Color[0]);
562      ctx->Current.RasterColor[1] = (ctx->Current.Color[1]);
563      ctx->Current.RasterColor[2] = (ctx->Current.Color[2]);
564      ctx->Current.RasterColor[3] = (ctx->Current.Color[3]);
565   }
566   else {
567      ctx->Current.RasterIndex = ctx->Current.Index;
568   }
569
570   /* raster texcoord = current texcoord */
571   {
572      GLuint texSet;
573      for (texSet = 0; texSet < ctx->Const.MaxTextureUnits; texSet++) {
574         COPY_4FV( ctx->Current.RasterMultiTexCoord[texSet],
575                  ctx->Current.Texcoord[texSet] );
576      }
577   }
578
579   if (ctx->RenderMode==GL_SELECT) {
580      _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] );
581   }
582}
583
584
585
586
587void
588_mesa_WindowPos2dMESA(GLdouble x, GLdouble y)
589{
590   _mesa_WindowPos4fMESA(x, y, 0.0F, 1.0F);
591}
592
593void
594_mesa_WindowPos2fMESA(GLfloat x, GLfloat y)
595{
596   _mesa_WindowPos4fMESA(x, y, 0.0F, 1.0F);
597}
598
599void
600_mesa_WindowPos2iMESA(GLint x, GLint y)
601{
602   _mesa_WindowPos4fMESA(x, y, 0.0F, 1.0F);
603}
604
605void
606_mesa_WindowPos2sMESA(GLshort x, GLshort y)
607{
608   _mesa_WindowPos4fMESA(x, y, 0.0F, 1.0F);
609}
610
611void
612_mesa_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
613{
614   _mesa_WindowPos4fMESA(x, y, z, 1.0F);
615}
616
617void
618_mesa_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
619{
620   _mesa_WindowPos4fMESA(x, y, z, 1.0F);
621}
622
623void
624_mesa_WindowPos3iMESA(GLint x, GLint y, GLint z)
625{
626   _mesa_WindowPos4fMESA(x, y, z, 1.0F);
627}
628
629void
630_mesa_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
631{
632   _mesa_WindowPos4fMESA(x, y, z, 1.0F);
633}
634
635void
636_mesa_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
637{
638   _mesa_WindowPos4fMESA(x, y, z, w);
639}
640
641void
642_mesa_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
643{
644   _mesa_WindowPos4fMESA(x, y, z, w);
645}
646
647void
648_mesa_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
649{
650   _mesa_WindowPos4fMESA(x, y, z, w);
651}
652
653void
654_mesa_WindowPos2dvMESA(const GLdouble *v)
655{
656   _mesa_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
657}
658
659void
660_mesa_WindowPos2fvMESA(const GLfloat *v)
661{
662   _mesa_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
663}
664
665void
666_mesa_WindowPos2ivMESA(const GLint *v)
667{
668   _mesa_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
669}
670
671void
672_mesa_WindowPos2svMESA(const GLshort *v)
673{
674   _mesa_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
675}
676
677void
678_mesa_WindowPos3dvMESA(const GLdouble *v)
679{
680   _mesa_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
681}
682
683void
684_mesa_WindowPos3fvMESA(const GLfloat *v)
685{
686   _mesa_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
687}
688
689void
690_mesa_WindowPos3ivMESA(const GLint *v)
691{
692   _mesa_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
693}
694
695void
696_mesa_WindowPos3svMESA(const GLshort *v)
697{
698   _mesa_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
699}
700
701void
702_mesa_WindowPos4dvMESA(const GLdouble *v)
703{
704   _mesa_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
705}
706
707void
708_mesa_WindowPos4fvMESA(const GLfloat *v)
709{
710   _mesa_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
711}
712
713void
714_mesa_WindowPos4ivMESA(const GLint *v)
715{
716   _mesa_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
717}
718
719void
720_mesa_WindowPos4svMESA(const GLshort *v)
721{
722   _mesa_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
723}
724
725
726
727#if 0
728
729/*
730 * OpenGL implementation of glWindowPos*MESA()
731 */
732void glWindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
733{
734   GLfloat fx, fy;
735
736   /* Push current matrix mode and viewport attributes */
737   glPushAttrib( GL_TRANSFORM_BIT | GL_VIEWPORT_BIT );
738
739   /* Setup projection parameters */
740   glMatrixMode( GL_PROJECTION );
741   glPushMatrix();
742   glLoadIdentity();
743   glMatrixMode( GL_MODELVIEW );
744   glPushMatrix();
745   glLoadIdentity();
746
747   glDepthRange( z, z );
748   glViewport( (int) x - 1, (int) y - 1, 2, 2 );
749
750   /* set the raster (window) position */
751   fx = x - (int) x;
752   fy = y - (int) y;
753   glRasterPos4f( fx, fy, 0.0, w );
754
755   /* restore matrices, viewport and matrix mode */
756   glPopMatrix();
757   glMatrixMode( GL_PROJECTION );
758   glPopMatrix();
759
760   glPopAttrib();
761}
762
763#endif
764