rastpos.c revision 01e04c3f
17117f1b4Smrg/*
27117f1b4Smrg * Mesa 3-D graphics library
37117f1b4Smrg *
47117f1b4Smrg * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
57117f1b4Smrg *
67117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a
77117f1b4Smrg * copy of this software and associated documentation files (the "Software"),
87117f1b4Smrg * to deal in the Software without restriction, including without limitation
97117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
107117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the
117117f1b4Smrg * Software is furnished to do so, subject to the following conditions:
127117f1b4Smrg *
137117f1b4Smrg * The above copyright notice and this permission notice shall be included
147117f1b4Smrg * in all copies or substantial portions of the Software.
157117f1b4Smrg *
167117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
177117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
187117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE.
237117f1b4Smrg */
247117f1b4Smrg
257117f1b4Smrg
267117f1b4Smrg/**
277117f1b4Smrg * \file rastpos.c
287117f1b4Smrg * Raster position operations.
297117f1b4Smrg */
307117f1b4Smrg
317117f1b4Smrg#include "glheader.h"
327117f1b4Smrg#include "context.h"
337117f1b4Smrg#include "feedback.h"
347117f1b4Smrg#include "macros.h"
353464ebd5Sriastradh#include "mtypes.h"
367117f1b4Smrg#include "rastpos.h"
377117f1b4Smrg#include "state.h"
3801e04c3fSmrg#include "main/viewport.h"
3901e04c3fSmrg#include "util/bitscan.h"
4001e04c3fSmrg
4101e04c3fSmrg
4201e04c3fSmrg
4301e04c3fSmrg/**
4401e04c3fSmrg * Clip a point against the view volume.
4501e04c3fSmrg *
4601e04c3fSmrg * \param v vertex vector describing the point to clip.
4701e04c3fSmrg *
4801e04c3fSmrg * \return zero if outside view volume, or one if inside.
4901e04c3fSmrg */
5001e04c3fSmrgstatic GLuint
5101e04c3fSmrgviewclip_point_xy( const GLfloat v[] )
5201e04c3fSmrg{
5301e04c3fSmrg   if (   v[0] > v[3] || v[0] < -v[3]
5401e04c3fSmrg       || v[1] > v[3] || v[1] < -v[3] ) {
5501e04c3fSmrg      return 0;
5601e04c3fSmrg   }
5701e04c3fSmrg   else {
5801e04c3fSmrg      return 1;
5901e04c3fSmrg   }
6001e04c3fSmrg}
6101e04c3fSmrg
6201e04c3fSmrg
6301e04c3fSmrg/**
6401e04c3fSmrg * Clip a point against the near Z clipping planes.
6501e04c3fSmrg *
6601e04c3fSmrg * \param v vertex vector describing the point to clip.
6701e04c3fSmrg *
6801e04c3fSmrg * \return zero if outside view volume, or one if inside.
6901e04c3fSmrg */
7001e04c3fSmrgstatic GLuint
7101e04c3fSmrgviewclip_point_near_z( const GLfloat v[] )
7201e04c3fSmrg{
7301e04c3fSmrg   if (v[2] < -v[3]) {
7401e04c3fSmrg      return 0;
7501e04c3fSmrg   }
7601e04c3fSmrg   else {
7701e04c3fSmrg      return 1;
7801e04c3fSmrg   }
7901e04c3fSmrg}
8001e04c3fSmrg
8101e04c3fSmrg
8201e04c3fSmrg/**
8301e04c3fSmrg * Clip a point against the far Z clipping planes.
8401e04c3fSmrg *
8501e04c3fSmrg * \param v vertex vector describing the point to clip.
8601e04c3fSmrg *
8701e04c3fSmrg * \return zero if outside view volume, or one if inside.
8801e04c3fSmrg */
8901e04c3fSmrgstatic GLuint
9001e04c3fSmrgviewclip_point_far_z( const GLfloat v[] )
9101e04c3fSmrg{
9201e04c3fSmrg   if (v[2] > v[3]) {
9301e04c3fSmrg      return 0;
9401e04c3fSmrg   }
9501e04c3fSmrg   else {
9601e04c3fSmrg      return 1;
9701e04c3fSmrg   }
9801e04c3fSmrg}
9901e04c3fSmrg
10001e04c3fSmrg
10101e04c3fSmrg/**
10201e04c3fSmrg * Clip a point against the user clipping planes.
10301e04c3fSmrg *
10401e04c3fSmrg * \param ctx GL context.
10501e04c3fSmrg * \param v vertex vector describing the point to clip.
10601e04c3fSmrg *
10701e04c3fSmrg * \return zero if the point was clipped, or one otherwise.
10801e04c3fSmrg */
10901e04c3fSmrgstatic GLuint
11001e04c3fSmrguserclip_point( struct gl_context *ctx, const GLfloat v[] )
11101e04c3fSmrg{
11201e04c3fSmrg   GLbitfield mask = ctx->Transform.ClipPlanesEnabled;
11301e04c3fSmrg   while (mask) {
11401e04c3fSmrg      const int p = u_bit_scan(&mask);
11501e04c3fSmrg      GLfloat dot = v[0] * ctx->Transform._ClipUserPlane[p][0]
11601e04c3fSmrg         + v[1] * ctx->Transform._ClipUserPlane[p][1]
11701e04c3fSmrg         + v[2] * ctx->Transform._ClipUserPlane[p][2]
11801e04c3fSmrg         + v[3] * ctx->Transform._ClipUserPlane[p][3];
11901e04c3fSmrg
12001e04c3fSmrg      if (dot < 0.0F) {
12101e04c3fSmrg         return 0;
12201e04c3fSmrg      }
12301e04c3fSmrg   }
12401e04c3fSmrg
12501e04c3fSmrg   return 1;
12601e04c3fSmrg}
12701e04c3fSmrg
12801e04c3fSmrg
12901e04c3fSmrg/**
13001e04c3fSmrg * Compute lighting for the raster position.  RGB modes computed.
13101e04c3fSmrg * \param ctx the context
13201e04c3fSmrg * \param vertex vertex location
13301e04c3fSmrg * \param normal normal vector
13401e04c3fSmrg * \param Rcolor returned color
13501e04c3fSmrg * \param Rspec returned specular color (if separate specular enabled)
13601e04c3fSmrg */
13701e04c3fSmrgstatic void
13801e04c3fSmrgshade_rastpos(struct gl_context *ctx,
13901e04c3fSmrg              const GLfloat vertex[4],
14001e04c3fSmrg              const GLfloat normal[3],
14101e04c3fSmrg              GLfloat Rcolor[4],
14201e04c3fSmrg              GLfloat Rspec[4])
14301e04c3fSmrg{
14401e04c3fSmrg   /*const*/ GLfloat (*base)[3] = ctx->Light._BaseColor;
14501e04c3fSmrg   GLbitfield mask;
14601e04c3fSmrg   GLfloat diffuseColor[4], specularColor[4];  /* for RGB mode only */
14701e04c3fSmrg
14801e04c3fSmrg   COPY_3V(diffuseColor, base[0]);
14901e04c3fSmrg   diffuseColor[3] = CLAMP(
15001e04c3fSmrg      ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3], 0.0F, 1.0F );
15101e04c3fSmrg   ASSIGN_4V(specularColor, 0.0, 0.0, 0.0, 1.0);
15201e04c3fSmrg
15301e04c3fSmrg   mask = ctx->Light._EnabledLights;
15401e04c3fSmrg   while (mask) {
15501e04c3fSmrg      const int i = u_bit_scan(&mask);
15601e04c3fSmrg      struct gl_light *light = &ctx->Light.Light[i];
15701e04c3fSmrg      GLfloat attenuation = 1.0;
15801e04c3fSmrg      GLfloat VP[3]; /* vector from vertex to light pos */
15901e04c3fSmrg      GLfloat n_dot_VP;
16001e04c3fSmrg      GLfloat diffuseContrib[3], specularContrib[3];
16101e04c3fSmrg
16201e04c3fSmrg      if (!(light->_Flags & LIGHT_POSITIONAL)) {
16301e04c3fSmrg         /* light at infinity */
16401e04c3fSmrg	 COPY_3V(VP, light->_VP_inf_norm);
16501e04c3fSmrg	 attenuation = light->_VP_inf_spot_attenuation;
16601e04c3fSmrg      }
16701e04c3fSmrg      else {
16801e04c3fSmrg         /* local/positional light */
16901e04c3fSmrg	 GLfloat d;
17001e04c3fSmrg
17101e04c3fSmrg         /* VP = vector from vertex pos to light[i].pos */
17201e04c3fSmrg	 SUB_3V(VP, light->_Position, vertex);
17301e04c3fSmrg         /* d = length(VP) */
17401e04c3fSmrg	 d = (GLfloat) LEN_3FV( VP );
17501e04c3fSmrg	 if (d > 1.0e-6F) {
17601e04c3fSmrg            /* normalize VP */
17701e04c3fSmrg	    GLfloat invd = 1.0F / d;
17801e04c3fSmrg	    SELF_SCALE_SCALAR_3V(VP, invd);
17901e04c3fSmrg	 }
18001e04c3fSmrg
18101e04c3fSmrg         /* atti */
18201e04c3fSmrg	 attenuation = 1.0F / (light->ConstantAttenuation + d *
18301e04c3fSmrg			       (light->LinearAttenuation + d *
18401e04c3fSmrg				light->QuadraticAttenuation));
18501e04c3fSmrg
18601e04c3fSmrg	 if (light->_Flags & LIGHT_SPOT) {
18701e04c3fSmrg	    GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection);
18801e04c3fSmrg
18901e04c3fSmrg	    if (PV_dot_dir<light->_CosCutoff) {
19001e04c3fSmrg	       continue;
19101e04c3fSmrg	    }
19201e04c3fSmrg	    else {
19301e04c3fSmrg               GLfloat spot = powf(PV_dot_dir, light->SpotExponent);
19401e04c3fSmrg	       attenuation *= spot;
19501e04c3fSmrg	    }
19601e04c3fSmrg	 }
19701e04c3fSmrg      }
19801e04c3fSmrg
19901e04c3fSmrg      if (attenuation < 1e-3F)
20001e04c3fSmrg	 continue;
20101e04c3fSmrg
20201e04c3fSmrg      n_dot_VP = DOT3( normal, VP );
20301e04c3fSmrg
20401e04c3fSmrg      if (n_dot_VP < 0.0F) {
20501e04c3fSmrg	 ACC_SCALE_SCALAR_3V(diffuseColor, attenuation, light->_MatAmbient[0]);
20601e04c3fSmrg	 continue;
20701e04c3fSmrg      }
20801e04c3fSmrg
20901e04c3fSmrg      /* Ambient + diffuse */
21001e04c3fSmrg      COPY_3V(diffuseContrib, light->_MatAmbient[0]);
21101e04c3fSmrg      ACC_SCALE_SCALAR_3V(diffuseContrib, n_dot_VP, light->_MatDiffuse[0]);
21201e04c3fSmrg
21301e04c3fSmrg      /* Specular */
21401e04c3fSmrg      {
21501e04c3fSmrg         const GLfloat *h;
21601e04c3fSmrg         GLfloat n_dot_h;
21701e04c3fSmrg
21801e04c3fSmrg         ASSIGN_3V(specularContrib, 0.0, 0.0, 0.0);
21901e04c3fSmrg
22001e04c3fSmrg	 if (ctx->Light.Model.LocalViewer) {
22101e04c3fSmrg	    GLfloat v[3];
22201e04c3fSmrg	    COPY_3V(v, vertex);
22301e04c3fSmrg	    NORMALIZE_3FV(v);
22401e04c3fSmrg	    SUB_3V(VP, VP, v);
22501e04c3fSmrg            NORMALIZE_3FV(VP);
22601e04c3fSmrg	    h = VP;
22701e04c3fSmrg	 }
22801e04c3fSmrg	 else if (light->_Flags & LIGHT_POSITIONAL) {
22901e04c3fSmrg	    ACC_3V(VP, ctx->_EyeZDir);
23001e04c3fSmrg            NORMALIZE_3FV(VP);
23101e04c3fSmrg	    h = VP;
23201e04c3fSmrg	 }
23301e04c3fSmrg         else {
23401e04c3fSmrg	    h = light->_h_inf_norm;
23501e04c3fSmrg	 }
23601e04c3fSmrg
23701e04c3fSmrg	 n_dot_h = DOT3(normal, h);
23801e04c3fSmrg
23901e04c3fSmrg	 if (n_dot_h > 0.0F) {
24001e04c3fSmrg	    GLfloat shine;
24101e04c3fSmrg	    GLfloat spec_coef;
24201e04c3fSmrg
24301e04c3fSmrg	    shine = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS][0];
24401e04c3fSmrg	    spec_coef = powf(n_dot_h, shine);
24501e04c3fSmrg
24601e04c3fSmrg	    if (spec_coef > 1.0e-10F) {
24701e04c3fSmrg               if (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) {
24801e04c3fSmrg                  ACC_SCALE_SCALAR_3V( specularContrib, spec_coef,
24901e04c3fSmrg                                       light->_MatSpecular[0]);
25001e04c3fSmrg               }
25101e04c3fSmrg               else {
25201e04c3fSmrg                  ACC_SCALE_SCALAR_3V( diffuseContrib, spec_coef,
25301e04c3fSmrg                                       light->_MatSpecular[0]);
25401e04c3fSmrg               }
25501e04c3fSmrg	    }
25601e04c3fSmrg	 }
25701e04c3fSmrg      }
25801e04c3fSmrg
25901e04c3fSmrg      ACC_SCALE_SCALAR_3V( diffuseColor, attenuation, diffuseContrib );
26001e04c3fSmrg      ACC_SCALE_SCALAR_3V( specularColor, attenuation, specularContrib );
26101e04c3fSmrg   }
26201e04c3fSmrg
26301e04c3fSmrg   Rcolor[0] = CLAMP(diffuseColor[0], 0.0F, 1.0F);
26401e04c3fSmrg   Rcolor[1] = CLAMP(diffuseColor[1], 0.0F, 1.0F);
26501e04c3fSmrg   Rcolor[2] = CLAMP(diffuseColor[2], 0.0F, 1.0F);
26601e04c3fSmrg   Rcolor[3] = CLAMP(diffuseColor[3], 0.0F, 1.0F);
26701e04c3fSmrg   Rspec[0] = CLAMP(specularColor[0], 0.0F, 1.0F);
26801e04c3fSmrg   Rspec[1] = CLAMP(specularColor[1], 0.0F, 1.0F);
26901e04c3fSmrg   Rspec[2] = CLAMP(specularColor[2], 0.0F, 1.0F);
27001e04c3fSmrg   Rspec[3] = CLAMP(specularColor[3], 0.0F, 1.0F);
27101e04c3fSmrg}
27201e04c3fSmrg
27301e04c3fSmrg
27401e04c3fSmrg/**
27501e04c3fSmrg * Do texgen needed for glRasterPos.
27601e04c3fSmrg * \param ctx  rendering context
27701e04c3fSmrg * \param vObj  object-space vertex coordinate
27801e04c3fSmrg * \param vEye  eye-space vertex coordinate
27901e04c3fSmrg * \param normal  vertex normal
28001e04c3fSmrg * \param unit  texture unit number
28101e04c3fSmrg * \param texcoord  incoming texcoord and resulting texcoord
28201e04c3fSmrg */
28301e04c3fSmrgstatic void
28401e04c3fSmrgcompute_texgen(struct gl_context *ctx, const GLfloat vObj[4], const GLfloat vEye[4],
28501e04c3fSmrg               const GLfloat normal[3], GLuint unit, GLfloat texcoord[4])
28601e04c3fSmrg{
28701e04c3fSmrg   const struct gl_fixedfunc_texture_unit *texUnit =
28801e04c3fSmrg      &ctx->Texture.FixedFuncUnit[unit];
28901e04c3fSmrg
29001e04c3fSmrg   /* always compute sphere map terms, just in case */
29101e04c3fSmrg   GLfloat u[3], two_nu, rx, ry, rz, m, mInv;
29201e04c3fSmrg   COPY_3V(u, vEye);
29301e04c3fSmrg   NORMALIZE_3FV(u);
29401e04c3fSmrg   two_nu = 2.0F * DOT3(normal, u);
29501e04c3fSmrg   rx = u[0] - normal[0] * two_nu;
29601e04c3fSmrg   ry = u[1] - normal[1] * two_nu;
29701e04c3fSmrg   rz = u[2] - normal[2] * two_nu;
29801e04c3fSmrg   m = rx * rx + ry * ry + (rz + 1.0F) * (rz + 1.0F);
29901e04c3fSmrg   if (m > 0.0F)
30001e04c3fSmrg      mInv = 0.5F * (1.0f / sqrtf(m));
30101e04c3fSmrg   else
30201e04c3fSmrg      mInv = 0.0F;
30301e04c3fSmrg
30401e04c3fSmrg   if (texUnit->TexGenEnabled & S_BIT) {
30501e04c3fSmrg      switch (texUnit->GenS.Mode) {
30601e04c3fSmrg         case GL_OBJECT_LINEAR:
30701e04c3fSmrg            texcoord[0] = DOT4(vObj, texUnit->GenS.ObjectPlane);
30801e04c3fSmrg            break;
30901e04c3fSmrg         case GL_EYE_LINEAR:
31001e04c3fSmrg            texcoord[0] = DOT4(vEye, texUnit->GenS.EyePlane);
31101e04c3fSmrg            break;
31201e04c3fSmrg         case GL_SPHERE_MAP:
31301e04c3fSmrg            texcoord[0] = rx * mInv + 0.5F;
31401e04c3fSmrg            break;
31501e04c3fSmrg         case GL_REFLECTION_MAP:
31601e04c3fSmrg            texcoord[0] = rx;
31701e04c3fSmrg            break;
31801e04c3fSmrg         case GL_NORMAL_MAP:
31901e04c3fSmrg            texcoord[0] = normal[0];
32001e04c3fSmrg            break;
32101e04c3fSmrg         default:
32201e04c3fSmrg            _mesa_problem(ctx, "Bad S texgen in compute_texgen()");
32301e04c3fSmrg            return;
32401e04c3fSmrg      }
32501e04c3fSmrg   }
32601e04c3fSmrg
32701e04c3fSmrg   if (texUnit->TexGenEnabled & T_BIT) {
32801e04c3fSmrg      switch (texUnit->GenT.Mode) {
32901e04c3fSmrg         case GL_OBJECT_LINEAR:
33001e04c3fSmrg            texcoord[1] = DOT4(vObj, texUnit->GenT.ObjectPlane);
33101e04c3fSmrg            break;
33201e04c3fSmrg         case GL_EYE_LINEAR:
33301e04c3fSmrg            texcoord[1] = DOT4(vEye, texUnit->GenT.EyePlane);
33401e04c3fSmrg            break;
33501e04c3fSmrg         case GL_SPHERE_MAP:
33601e04c3fSmrg            texcoord[1] = ry * mInv + 0.5F;
33701e04c3fSmrg            break;
33801e04c3fSmrg         case GL_REFLECTION_MAP:
33901e04c3fSmrg            texcoord[1] = ry;
34001e04c3fSmrg            break;
34101e04c3fSmrg         case GL_NORMAL_MAP:
34201e04c3fSmrg            texcoord[1] = normal[1];
34301e04c3fSmrg            break;
34401e04c3fSmrg         default:
34501e04c3fSmrg            _mesa_problem(ctx, "Bad T texgen in compute_texgen()");
34601e04c3fSmrg            return;
34701e04c3fSmrg      }
34801e04c3fSmrg   }
34901e04c3fSmrg
35001e04c3fSmrg   if (texUnit->TexGenEnabled & R_BIT) {
35101e04c3fSmrg      switch (texUnit->GenR.Mode) {
35201e04c3fSmrg         case GL_OBJECT_LINEAR:
35301e04c3fSmrg            texcoord[2] = DOT4(vObj, texUnit->GenR.ObjectPlane);
35401e04c3fSmrg            break;
35501e04c3fSmrg         case GL_EYE_LINEAR:
35601e04c3fSmrg            texcoord[2] = DOT4(vEye, texUnit->GenR.EyePlane);
35701e04c3fSmrg            break;
35801e04c3fSmrg         case GL_REFLECTION_MAP:
35901e04c3fSmrg            texcoord[2] = rz;
36001e04c3fSmrg            break;
36101e04c3fSmrg         case GL_NORMAL_MAP:
36201e04c3fSmrg            texcoord[2] = normal[2];
36301e04c3fSmrg            break;
36401e04c3fSmrg         default:
36501e04c3fSmrg            _mesa_problem(ctx, "Bad R texgen in compute_texgen()");
36601e04c3fSmrg            return;
36701e04c3fSmrg      }
36801e04c3fSmrg   }
36901e04c3fSmrg
37001e04c3fSmrg   if (texUnit->TexGenEnabled & Q_BIT) {
37101e04c3fSmrg      switch (texUnit->GenQ.Mode) {
37201e04c3fSmrg         case GL_OBJECT_LINEAR:
37301e04c3fSmrg            texcoord[3] = DOT4(vObj, texUnit->GenQ.ObjectPlane);
37401e04c3fSmrg            break;
37501e04c3fSmrg         case GL_EYE_LINEAR:
37601e04c3fSmrg            texcoord[3] = DOT4(vEye, texUnit->GenQ.EyePlane);
37701e04c3fSmrg            break;
37801e04c3fSmrg         default:
37901e04c3fSmrg            _mesa_problem(ctx, "Bad Q texgen in compute_texgen()");
38001e04c3fSmrg            return;
38101e04c3fSmrg      }
38201e04c3fSmrg   }
38301e04c3fSmrg}
38401e04c3fSmrg
38501e04c3fSmrg
38601e04c3fSmrg/**
38701e04c3fSmrg * glRasterPos transformation.  Typically called via ctx->Driver.RasterPos().
38801e04c3fSmrg *
38901e04c3fSmrg * \param vObj  vertex position in object space
39001e04c3fSmrg */
39101e04c3fSmrgvoid
39201e04c3fSmrg_mesa_RasterPos(struct gl_context *ctx, const GLfloat vObj[4])
39301e04c3fSmrg{
39401e04c3fSmrg   if (_mesa_arb_vertex_program_enabled(ctx)) {
39501e04c3fSmrg      /* XXX implement this */
39601e04c3fSmrg      _mesa_problem(ctx, "Vertex programs not implemented for glRasterPos");
39701e04c3fSmrg      return;
39801e04c3fSmrg   }
39901e04c3fSmrg   else {
40001e04c3fSmrg      GLfloat eye[4], clip[4], ndc[3], d;
40101e04c3fSmrg      GLfloat *norm, eyenorm[3];
40201e04c3fSmrg      GLfloat *objnorm = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
40301e04c3fSmrg      float scale[3], translate[3];
40401e04c3fSmrg
40501e04c3fSmrg      /* apply modelview matrix:  eye = MV * obj */
40601e04c3fSmrg      TRANSFORM_POINT( eye, ctx->ModelviewMatrixStack.Top->m, vObj );
40701e04c3fSmrg      /* apply projection matrix:  clip = Proj * eye */
40801e04c3fSmrg      TRANSFORM_POINT( clip, ctx->ProjectionMatrixStack.Top->m, eye );
40901e04c3fSmrg
41001e04c3fSmrg      /* clip to view volume. */
41101e04c3fSmrg      if (!ctx->Transform.DepthClampNear) {
41201e04c3fSmrg         if (viewclip_point_near_z(clip) == 0) {
41301e04c3fSmrg            ctx->Current.RasterPosValid = GL_FALSE;
41401e04c3fSmrg            return;
41501e04c3fSmrg         }
41601e04c3fSmrg      }
41701e04c3fSmrg      if (!ctx->Transform.DepthClampFar) {
41801e04c3fSmrg         if (viewclip_point_far_z(clip) == 0) {
41901e04c3fSmrg            ctx->Current.RasterPosValid = GL_FALSE;
42001e04c3fSmrg            return;
42101e04c3fSmrg         }
42201e04c3fSmrg      }
42301e04c3fSmrg      if (!ctx->Transform.RasterPositionUnclipped) {
42401e04c3fSmrg         if (viewclip_point_xy(clip) == 0) {
42501e04c3fSmrg            ctx->Current.RasterPosValid = GL_FALSE;
42601e04c3fSmrg            return;
42701e04c3fSmrg         }
42801e04c3fSmrg      }
42901e04c3fSmrg
43001e04c3fSmrg      /* clip to user clipping planes */
43101e04c3fSmrg      if (ctx->Transform.ClipPlanesEnabled && !userclip_point(ctx, clip)) {
43201e04c3fSmrg         ctx->Current.RasterPosValid = GL_FALSE;
43301e04c3fSmrg         return;
43401e04c3fSmrg      }
43501e04c3fSmrg
43601e04c3fSmrg      /* ndc = clip / W */
43701e04c3fSmrg      d = (clip[3] == 0.0F) ? 1.0F : 1.0F / clip[3];
43801e04c3fSmrg      ndc[0] = clip[0] * d;
43901e04c3fSmrg      ndc[1] = clip[1] * d;
44001e04c3fSmrg      ndc[2] = clip[2] * d;
44101e04c3fSmrg      /* wincoord = viewport_mapping(ndc) */
44201e04c3fSmrg      _mesa_get_viewport_xform(ctx, 0, scale, translate);
44301e04c3fSmrg      ctx->Current.RasterPos[0] = ndc[0] * scale[0] + translate[0];
44401e04c3fSmrg      ctx->Current.RasterPos[1] = ndc[1] * scale[1] + translate[1];
44501e04c3fSmrg      ctx->Current.RasterPos[2] = ndc[2] * scale[2] + translate[2];
44601e04c3fSmrg      ctx->Current.RasterPos[3] = clip[3];
44701e04c3fSmrg
44801e04c3fSmrg      if (ctx->Transform.DepthClampNear &&
44901e04c3fSmrg          ctx->Transform.DepthClampFar) {
45001e04c3fSmrg         ctx->Current.RasterPos[3] = CLAMP(ctx->Current.RasterPos[3],
45101e04c3fSmrg                                           ctx->ViewportArray[0].Near,
45201e04c3fSmrg                                           ctx->ViewportArray[0].Far);
45301e04c3fSmrg      } else {
45401e04c3fSmrg         /* Clamp against near and far plane separately */
45501e04c3fSmrg         if (ctx->Transform.DepthClampNear) {
45601e04c3fSmrg            ctx->Current.RasterPos[3] = MAX2(ctx->Current.RasterPos[3],
45701e04c3fSmrg                                             ctx->ViewportArray[0].Near);
45801e04c3fSmrg         }
45901e04c3fSmrg
46001e04c3fSmrg         if (ctx->Transform.DepthClampFar) {
46101e04c3fSmrg            ctx->Current.RasterPos[3] = MIN2(ctx->Current.RasterPos[3],
46201e04c3fSmrg                                             ctx->ViewportArray[0].Far);
46301e04c3fSmrg         }
46401e04c3fSmrg      }
46501e04c3fSmrg
46601e04c3fSmrg      /* compute raster distance */
46701e04c3fSmrg      if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
46801e04c3fSmrg         ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0];
46901e04c3fSmrg      else
47001e04c3fSmrg         ctx->Current.RasterDistance =
47101e04c3fSmrg                        sqrtf( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] );
47201e04c3fSmrg
47301e04c3fSmrg      /* compute transformed normal vector (for lighting or texgen) */
47401e04c3fSmrg      if (ctx->_NeedEyeCoords) {
47501e04c3fSmrg         const GLfloat *inv = ctx->ModelviewMatrixStack.Top->inv;
47601e04c3fSmrg         TRANSFORM_NORMAL( eyenorm, objnorm, inv );
47701e04c3fSmrg         norm = eyenorm;
47801e04c3fSmrg      }
47901e04c3fSmrg      else {
48001e04c3fSmrg         norm = objnorm;
48101e04c3fSmrg      }
48201e04c3fSmrg
48301e04c3fSmrg      /* update raster color */
48401e04c3fSmrg      if (ctx->Light.Enabled) {
48501e04c3fSmrg         /* lighting */
48601e04c3fSmrg         shade_rastpos( ctx, vObj, norm,
48701e04c3fSmrg                        ctx->Current.RasterColor,
48801e04c3fSmrg                        ctx->Current.RasterSecondaryColor );
48901e04c3fSmrg      }
49001e04c3fSmrg      else {
49101e04c3fSmrg         /* use current color */
49201e04c3fSmrg	 COPY_4FV(ctx->Current.RasterColor,
49301e04c3fSmrg		  ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
49401e04c3fSmrg	 COPY_4FV(ctx->Current.RasterSecondaryColor,
49501e04c3fSmrg		  ctx->Current.Attrib[VERT_ATTRIB_COLOR1]);
49601e04c3fSmrg      }
49701e04c3fSmrg
49801e04c3fSmrg      /* texture coords */
49901e04c3fSmrg      {
50001e04c3fSmrg         GLuint u;
50101e04c3fSmrg         for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
50201e04c3fSmrg            GLfloat tc[4];
50301e04c3fSmrg            COPY_4V(tc, ctx->Current.Attrib[VERT_ATTRIB_TEX0 + u]);
50401e04c3fSmrg            if (ctx->Texture.FixedFuncUnit[u].TexGenEnabled) {
50501e04c3fSmrg               compute_texgen(ctx, vObj, eye, norm, u, tc);
50601e04c3fSmrg            }
50701e04c3fSmrg            TRANSFORM_POINT(ctx->Current.RasterTexCoords[u],
50801e04c3fSmrg                            ctx->TextureMatrixStack[u].Top->m, tc);
50901e04c3fSmrg         }
51001e04c3fSmrg      }
51101e04c3fSmrg
51201e04c3fSmrg      ctx->Current.RasterPosValid = GL_TRUE;
51301e04c3fSmrg   }
51401e04c3fSmrg
51501e04c3fSmrg   if (ctx->RenderMode == GL_SELECT) {
51601e04c3fSmrg      _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] );
51701e04c3fSmrg   }
51801e04c3fSmrg}
5194a49301eSmrg
5204a49301eSmrg
5217117f1b4Smrg/**
522c1f859d4Smrg * Helper function for all the RasterPos functions.
5237117f1b4Smrg */
5247117f1b4Smrgstatic void
525c1f859d4Smrgrasterpos(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
526c1f859d4Smrg{
527c1f859d4Smrg   GET_CURRENT_CONTEXT(ctx);
528c1f859d4Smrg   GLfloat p[4];
5297117f1b4Smrg
530c1f859d4Smrg   p[0] = x;
531c1f859d4Smrg   p[1] = y;
532c1f859d4Smrg   p[2] = z;
533c1f859d4Smrg   p[3] = w;
5347117f1b4Smrg
535af69d88dSmrg   FLUSH_VERTICES(ctx, 0);
5367117f1b4Smrg   FLUSH_CURRENT(ctx, 0);
5377117f1b4Smrg
5387117f1b4Smrg   if (ctx->NewState)
5397117f1b4Smrg      _mesa_update_state( ctx );
5407117f1b4Smrg
541c1f859d4Smrg   ctx->Driver.RasterPos(ctx, p);
5427117f1b4Smrg}
5437117f1b4Smrg
5447117f1b4Smrg
545af69d88dSmrgvoid GLAPIENTRY
5467117f1b4Smrg_mesa_RasterPos2d(GLdouble x, GLdouble y)
5477117f1b4Smrg{
548c1f859d4Smrg   rasterpos((GLfloat)x, (GLfloat)y, (GLfloat)0.0, (GLfloat)1.0);
5497117f1b4Smrg}
5507117f1b4Smrg
551af69d88dSmrgvoid GLAPIENTRY
5527117f1b4Smrg_mesa_RasterPos2f(GLfloat x, GLfloat y)
5537117f1b4Smrg{
554c1f859d4Smrg   rasterpos(x, y, 0.0F, 1.0F);
5557117f1b4Smrg}
5567117f1b4Smrg
557af69d88dSmrgvoid GLAPIENTRY
5587117f1b4Smrg_mesa_RasterPos2i(GLint x, GLint y)
5597117f1b4Smrg{
560c1f859d4Smrg   rasterpos((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
5617117f1b4Smrg}
5627117f1b4Smrg
563af69d88dSmrgvoid GLAPIENTRY
5647117f1b4Smrg_mesa_RasterPos2s(GLshort x, GLshort y)
5657117f1b4Smrg{
566c1f859d4Smrg   rasterpos(x, y, 0.0F, 1.0F);
5677117f1b4Smrg}
5687117f1b4Smrg
569af69d88dSmrgvoid GLAPIENTRY
5707117f1b4Smrg_mesa_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
5717117f1b4Smrg{
572c1f859d4Smrg   rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
5737117f1b4Smrg}
5747117f1b4Smrg
575af69d88dSmrgvoid GLAPIENTRY
5767117f1b4Smrg_mesa_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
5777117f1b4Smrg{
578c1f859d4Smrg   rasterpos(x, y, z, 1.0F);
5797117f1b4Smrg}
5807117f1b4Smrg
581af69d88dSmrgvoid GLAPIENTRY
5827117f1b4Smrg_mesa_RasterPos3i(GLint x, GLint y, GLint z)
5837117f1b4Smrg{
584c1f859d4Smrg   rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
5857117f1b4Smrg}
5867117f1b4Smrg
587af69d88dSmrgvoid GLAPIENTRY
5887117f1b4Smrg_mesa_RasterPos3s(GLshort x, GLshort y, GLshort z)
5897117f1b4Smrg{
590c1f859d4Smrg   rasterpos(x, y, z, 1.0F);
5917117f1b4Smrg}
5927117f1b4Smrg
593af69d88dSmrgvoid GLAPIENTRY
5947117f1b4Smrg_mesa_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
5957117f1b4Smrg{
596c1f859d4Smrg   rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
5977117f1b4Smrg}
5987117f1b4Smrg
599af69d88dSmrgvoid GLAPIENTRY
6007117f1b4Smrg_mesa_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
6017117f1b4Smrg{
602c1f859d4Smrg   rasterpos(x, y, z, w);
6037117f1b4Smrg}
6047117f1b4Smrg
605af69d88dSmrgvoid GLAPIENTRY
6067117f1b4Smrg_mesa_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
6077117f1b4Smrg{
608c1f859d4Smrg   rasterpos((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
6097117f1b4Smrg}
6107117f1b4Smrg
611af69d88dSmrgvoid GLAPIENTRY
6127117f1b4Smrg_mesa_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
6137117f1b4Smrg{
614c1f859d4Smrg   rasterpos(x, y, z, w);
6157117f1b4Smrg}
6167117f1b4Smrg
617af69d88dSmrgvoid GLAPIENTRY
6187117f1b4Smrg_mesa_RasterPos2dv(const GLdouble *v)
6197117f1b4Smrg{
620c1f859d4Smrg   rasterpos((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
6217117f1b4Smrg}
6227117f1b4Smrg
623af69d88dSmrgvoid GLAPIENTRY
6247117f1b4Smrg_mesa_RasterPos2fv(const GLfloat *v)
6257117f1b4Smrg{
626c1f859d4Smrg   rasterpos(v[0], v[1], 0.0F, 1.0F);
6277117f1b4Smrg}
6287117f1b4Smrg
629af69d88dSmrgvoid GLAPIENTRY
6307117f1b4Smrg_mesa_RasterPos2iv(const GLint *v)
6317117f1b4Smrg{
632c1f859d4Smrg   rasterpos((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
6337117f1b4Smrg}
6347117f1b4Smrg
635af69d88dSmrgvoid GLAPIENTRY
6367117f1b4Smrg_mesa_RasterPos2sv(const GLshort *v)
6377117f1b4Smrg{
638c1f859d4Smrg   rasterpos(v[0], v[1], 0.0F, 1.0F);
6397117f1b4Smrg}
6407117f1b4Smrg
641af69d88dSmrgvoid GLAPIENTRY
6427117f1b4Smrg_mesa_RasterPos3dv(const GLdouble *v)
6437117f1b4Smrg{
644c1f859d4Smrg   rasterpos((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
6457117f1b4Smrg}
6467117f1b4Smrg
647af69d88dSmrgvoid GLAPIENTRY
6487117f1b4Smrg_mesa_RasterPos3fv(const GLfloat *v)
6497117f1b4Smrg{
650c1f859d4Smrg   rasterpos(v[0], v[1], v[2], 1.0F);
6517117f1b4Smrg}
6527117f1b4Smrg
653af69d88dSmrgvoid GLAPIENTRY
6547117f1b4Smrg_mesa_RasterPos3iv(const GLint *v)
6557117f1b4Smrg{
656c1f859d4Smrg   rasterpos((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
6577117f1b4Smrg}
6587117f1b4Smrg
659af69d88dSmrgvoid GLAPIENTRY
6607117f1b4Smrg_mesa_RasterPos3sv(const GLshort *v)
6617117f1b4Smrg{
662c1f859d4Smrg   rasterpos(v[0], v[1], v[2], 1.0F);
6637117f1b4Smrg}
6647117f1b4Smrg
665af69d88dSmrgvoid GLAPIENTRY
6667117f1b4Smrg_mesa_RasterPos4dv(const GLdouble *v)
6677117f1b4Smrg{
668c1f859d4Smrg   rasterpos((GLfloat) v[0], (GLfloat) v[1],
6697117f1b4Smrg		     (GLfloat) v[2], (GLfloat) v[3]);
6707117f1b4Smrg}
6717117f1b4Smrg
672af69d88dSmrgvoid GLAPIENTRY
6737117f1b4Smrg_mesa_RasterPos4fv(const GLfloat *v)
6747117f1b4Smrg{
675c1f859d4Smrg   rasterpos(v[0], v[1], v[2], v[3]);
6767117f1b4Smrg}
6777117f1b4Smrg
678af69d88dSmrgvoid GLAPIENTRY
6797117f1b4Smrg_mesa_RasterPos4iv(const GLint *v)
6807117f1b4Smrg{
681c1f859d4Smrg   rasterpos((GLfloat) v[0], (GLfloat) v[1],
6827117f1b4Smrg		     (GLfloat) v[2], (GLfloat) v[3]);
6837117f1b4Smrg}
6847117f1b4Smrg
685af69d88dSmrgvoid GLAPIENTRY
6867117f1b4Smrg_mesa_RasterPos4sv(const GLshort *v)
6877117f1b4Smrg{
688c1f859d4Smrg   rasterpos(v[0], v[1], v[2], v[3]);
6897117f1b4Smrg}
6907117f1b4Smrg
6917117f1b4Smrg
6927117f1b4Smrg/**********************************************************************/
6937117f1b4Smrg/***           GL_ARB_window_pos / GL_MESA_window_pos               ***/
6947117f1b4Smrg/**********************************************************************/
6957117f1b4Smrg
6964a49301eSmrg
6977117f1b4Smrg/**
6987117f1b4Smrg * All glWindowPosMESA and glWindowPosARB commands call this function to
6997117f1b4Smrg * update the current raster position.
7007117f1b4Smrg */
7017117f1b4Smrgstatic void
7027117f1b4Smrgwindow_pos3f(GLfloat x, GLfloat y, GLfloat z)
7037117f1b4Smrg{
7047117f1b4Smrg   GET_CURRENT_CONTEXT(ctx);
7057117f1b4Smrg   GLfloat z2;
7067117f1b4Smrg
707af69d88dSmrg   FLUSH_VERTICES(ctx, 0);
7087117f1b4Smrg   FLUSH_CURRENT(ctx, 0);
7097117f1b4Smrg
710af69d88dSmrg   z2 = CLAMP(z, 0.0F, 1.0F)
711af69d88dSmrg      * (ctx->ViewportArray[0].Far - ctx->ViewportArray[0].Near)
712af69d88dSmrg      + ctx->ViewportArray[0].Near;
7137117f1b4Smrg
7147117f1b4Smrg   /* set raster position */
7157117f1b4Smrg   ctx->Current.RasterPos[0] = x;
7167117f1b4Smrg   ctx->Current.RasterPos[1] = y;
7177117f1b4Smrg   ctx->Current.RasterPos[2] = z2;
7187117f1b4Smrg   ctx->Current.RasterPos[3] = 1.0F;
7197117f1b4Smrg
7207117f1b4Smrg   ctx->Current.RasterPosValid = GL_TRUE;
7217117f1b4Smrg
7227117f1b4Smrg   if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
7237117f1b4Smrg      ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0];
7247117f1b4Smrg   else
7257117f1b4Smrg      ctx->Current.RasterDistance = 0.0;
7267117f1b4Smrg
7277117f1b4Smrg   /* raster color = current color or index */
728cdc920a0Smrg   ctx->Current.RasterColor[0]
729cdc920a0Smrg      = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0], 0.0F, 1.0F);
730cdc920a0Smrg   ctx->Current.RasterColor[1]
731cdc920a0Smrg      = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1], 0.0F, 1.0F);
732cdc920a0Smrg   ctx->Current.RasterColor[2]
733cdc920a0Smrg      = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2], 0.0F, 1.0F);
734cdc920a0Smrg   ctx->Current.RasterColor[3]
735cdc920a0Smrg      = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3], 0.0F, 1.0F);
736cdc920a0Smrg   ctx->Current.RasterSecondaryColor[0]
737cdc920a0Smrg      = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0], 0.0F, 1.0F);
738cdc920a0Smrg   ctx->Current.RasterSecondaryColor[1]
739cdc920a0Smrg      = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1], 0.0F, 1.0F);
740cdc920a0Smrg   ctx->Current.RasterSecondaryColor[2]
741cdc920a0Smrg      = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2], 0.0F, 1.0F);
742cdc920a0Smrg   ctx->Current.RasterSecondaryColor[3]
743cdc920a0Smrg      = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3], 0.0F, 1.0F);
7447117f1b4Smrg
7457117f1b4Smrg   /* raster texcoord = current texcoord */
7467117f1b4Smrg   {
7477117f1b4Smrg      GLuint texSet;
7487117f1b4Smrg      for (texSet = 0; texSet < ctx->Const.MaxTextureCoordUnits; texSet++) {
74901e04c3fSmrg         assert(texSet < ARRAY_SIZE(ctx->Current.RasterTexCoords));
7507117f1b4Smrg         COPY_4FV( ctx->Current.RasterTexCoords[texSet],
7517117f1b4Smrg                  ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] );
7527117f1b4Smrg      }
7537117f1b4Smrg   }
7547117f1b4Smrg
7557117f1b4Smrg   if (ctx->RenderMode==GL_SELECT) {
7567117f1b4Smrg      _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] );
7577117f1b4Smrg   }
7587117f1b4Smrg}
7597117f1b4Smrg
7607117f1b4Smrg
7617117f1b4Smrg/* This is just to support the GL_MESA_window_pos version */
7627117f1b4Smrgstatic void
7637117f1b4Smrgwindow_pos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
7647117f1b4Smrg{
7657117f1b4Smrg   GET_CURRENT_CONTEXT(ctx);
7667117f1b4Smrg   window_pos3f(x, y, z);
7677117f1b4Smrg   ctx->Current.RasterPos[3] = w;
7687117f1b4Smrg}
7697117f1b4Smrg
7707117f1b4Smrg
771af69d88dSmrgvoid GLAPIENTRY
772af69d88dSmrg_mesa_WindowPos2d(GLdouble x, GLdouble y)
7737117f1b4Smrg{
7747117f1b4Smrg   window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
7757117f1b4Smrg}
7767117f1b4Smrg
777af69d88dSmrgvoid GLAPIENTRY
778af69d88dSmrg_mesa_WindowPos2f(GLfloat x, GLfloat y)
7797117f1b4Smrg{
7807117f1b4Smrg   window_pos4f(x, y, 0.0F, 1.0F);
7817117f1b4Smrg}
7827117f1b4Smrg
783af69d88dSmrgvoid GLAPIENTRY
784af69d88dSmrg_mesa_WindowPos2i(GLint x, GLint y)
7857117f1b4Smrg{
7867117f1b4Smrg   window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
7877117f1b4Smrg}
7887117f1b4Smrg
789af69d88dSmrgvoid GLAPIENTRY
790af69d88dSmrg_mesa_WindowPos2s(GLshort x, GLshort y)
7917117f1b4Smrg{
7927117f1b4Smrg   window_pos4f(x, y, 0.0F, 1.0F);
7937117f1b4Smrg}
7947117f1b4Smrg
795af69d88dSmrgvoid GLAPIENTRY
796af69d88dSmrg_mesa_WindowPos3d(GLdouble x, GLdouble y, GLdouble z)
7977117f1b4Smrg{
7987117f1b4Smrg   window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
7997117f1b4Smrg}
8007117f1b4Smrg
801af69d88dSmrgvoid GLAPIENTRY
802af69d88dSmrg_mesa_WindowPos3f(GLfloat x, GLfloat y, GLfloat z)
8037117f1b4Smrg{
8047117f1b4Smrg   window_pos4f(x, y, z, 1.0F);
8057117f1b4Smrg}
8067117f1b4Smrg
807af69d88dSmrgvoid GLAPIENTRY
808af69d88dSmrg_mesa_WindowPos3i(GLint x, GLint y, GLint z)
8097117f1b4Smrg{
8107117f1b4Smrg   window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
8117117f1b4Smrg}
8127117f1b4Smrg
813af69d88dSmrgvoid GLAPIENTRY
814af69d88dSmrg_mesa_WindowPos3s(GLshort x, GLshort y, GLshort z)
8157117f1b4Smrg{
8167117f1b4Smrg   window_pos4f(x, y, z, 1.0F);
8177117f1b4Smrg}
8187117f1b4Smrg
819af69d88dSmrgvoid GLAPIENTRY
8207117f1b4Smrg_mesa_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
8217117f1b4Smrg{
8227117f1b4Smrg   window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
8237117f1b4Smrg}
8247117f1b4Smrg
825af69d88dSmrgvoid GLAPIENTRY
8267117f1b4Smrg_mesa_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
8277117f1b4Smrg{
8287117f1b4Smrg   window_pos4f(x, y, z, w);
8297117f1b4Smrg}
8307117f1b4Smrg
831af69d88dSmrgvoid GLAPIENTRY
8327117f1b4Smrg_mesa_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
8337117f1b4Smrg{
8347117f1b4Smrg   window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
8357117f1b4Smrg}
8367117f1b4Smrg
837af69d88dSmrgvoid GLAPIENTRY
8387117f1b4Smrg_mesa_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
8397117f1b4Smrg{
8407117f1b4Smrg   window_pos4f(x, y, z, w);
8417117f1b4Smrg}
8427117f1b4Smrg
843af69d88dSmrgvoid GLAPIENTRY
844af69d88dSmrg_mesa_WindowPos2dv(const GLdouble *v)
8457117f1b4Smrg{
8467117f1b4Smrg   window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
8477117f1b4Smrg}
8487117f1b4Smrg
849af69d88dSmrgvoid GLAPIENTRY
850af69d88dSmrg_mesa_WindowPos2fv(const GLfloat *v)
8517117f1b4Smrg{
8527117f1b4Smrg   window_pos4f(v[0], v[1], 0.0F, 1.0F);
8537117f1b4Smrg}
8547117f1b4Smrg
855af69d88dSmrgvoid GLAPIENTRY
856af69d88dSmrg_mesa_WindowPos2iv(const GLint *v)
8577117f1b4Smrg{
8587117f1b4Smrg   window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
8597117f1b4Smrg}
8607117f1b4Smrg
861af69d88dSmrgvoid GLAPIENTRY
862af69d88dSmrg_mesa_WindowPos2sv(const GLshort *v)
8637117f1b4Smrg{
8647117f1b4Smrg   window_pos4f(v[0], v[1], 0.0F, 1.0F);
8657117f1b4Smrg}
8667117f1b4Smrg
867af69d88dSmrgvoid GLAPIENTRY
868af69d88dSmrg_mesa_WindowPos3dv(const GLdouble *v)
8697117f1b4Smrg{
8707117f1b4Smrg   window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
8717117f1b4Smrg}
8727117f1b4Smrg
873af69d88dSmrgvoid GLAPIENTRY
874af69d88dSmrg_mesa_WindowPos3fv(const GLfloat *v)
8757117f1b4Smrg{
8767117f1b4Smrg   window_pos4f(v[0], v[1], v[2], 1.0);
8777117f1b4Smrg}
8787117f1b4Smrg
879af69d88dSmrgvoid GLAPIENTRY
880af69d88dSmrg_mesa_WindowPos3iv(const GLint *v)
8817117f1b4Smrg{
8827117f1b4Smrg   window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
8837117f1b4Smrg}
8847117f1b4Smrg
885af69d88dSmrgvoid GLAPIENTRY
886af69d88dSmrg_mesa_WindowPos3sv(const GLshort *v)
8877117f1b4Smrg{
8887117f1b4Smrg   window_pos4f(v[0], v[1], v[2], 1.0F);
8897117f1b4Smrg}
8907117f1b4Smrg
891af69d88dSmrgvoid GLAPIENTRY
8927117f1b4Smrg_mesa_WindowPos4dvMESA(const GLdouble *v)
8937117f1b4Smrg{
8947117f1b4Smrg   window_pos4f((GLfloat) v[0], (GLfloat) v[1],
8957117f1b4Smrg			 (GLfloat) v[2], (GLfloat) v[3]);
8967117f1b4Smrg}
8977117f1b4Smrg
898af69d88dSmrgvoid GLAPIENTRY
8997117f1b4Smrg_mesa_WindowPos4fvMESA(const GLfloat *v)
9007117f1b4Smrg{
9017117f1b4Smrg   window_pos4f(v[0], v[1], v[2], v[3]);
9027117f1b4Smrg}
9037117f1b4Smrg
904af69d88dSmrgvoid GLAPIENTRY
9057117f1b4Smrg_mesa_WindowPos4ivMESA(const GLint *v)
9067117f1b4Smrg{
9077117f1b4Smrg   window_pos4f((GLfloat) v[0], (GLfloat) v[1],
9087117f1b4Smrg			 (GLfloat) v[2], (GLfloat) v[3]);
9097117f1b4Smrg}
9107117f1b4Smrg
911af69d88dSmrgvoid GLAPIENTRY
9127117f1b4Smrg_mesa_WindowPos4svMESA(const GLshort *v)
9137117f1b4Smrg{
9147117f1b4Smrg   window_pos4f(v[0], v[1], v[2], v[3]);
9157117f1b4Smrg}
9167117f1b4Smrg
9177117f1b4Smrg
9187117f1b4Smrg#if 0
9197117f1b4Smrg
9207117f1b4Smrg/*
9217117f1b4Smrg * OpenGL implementation of glWindowPos*MESA()
9227117f1b4Smrg */
9237117f1b4Smrgvoid glWindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
9247117f1b4Smrg{
9257117f1b4Smrg   GLfloat fx, fy;
9267117f1b4Smrg
9277117f1b4Smrg   /* Push current matrix mode and viewport attributes */
9287117f1b4Smrg   glPushAttrib( GL_TRANSFORM_BIT | GL_VIEWPORT_BIT );
9297117f1b4Smrg
9307117f1b4Smrg   /* Setup projection parameters */
9317117f1b4Smrg   glMatrixMode( GL_PROJECTION );
9327117f1b4Smrg   glPushMatrix();
9337117f1b4Smrg   glLoadIdentity();
9347117f1b4Smrg   glMatrixMode( GL_MODELVIEW );
9357117f1b4Smrg   glPushMatrix();
9367117f1b4Smrg   glLoadIdentity();
9377117f1b4Smrg
9387117f1b4Smrg   glDepthRange( z, z );
9397117f1b4Smrg   glViewport( (int) x - 1, (int) y - 1, 2, 2 );
9407117f1b4Smrg
9417117f1b4Smrg   /* set the raster (window) position */
9427117f1b4Smrg   fx = x - (int) x;
9437117f1b4Smrg   fy = y - (int) y;
9447117f1b4Smrg   glRasterPos4f( fx, fy, 0.0, w );
9457117f1b4Smrg
9467117f1b4Smrg   /* restore matrices, viewport and matrix mode */
9477117f1b4Smrg   glPopMatrix();
9487117f1b4Smrg   glMatrixMode( GL_PROJECTION );
9497117f1b4Smrg   glPopMatrix();
9507117f1b4Smrg
9517117f1b4Smrg   glPopAttrib();
9527117f1b4Smrg}
9537117f1b4Smrg
9547117f1b4Smrg#endif
9557117f1b4Smrg
9567117f1b4Smrg
9577117f1b4Smrg/**********************************************************************/
9587117f1b4Smrg/** \name Initialization                                              */
9597117f1b4Smrg/**********************************************************************/
9607117f1b4Smrg/*@{*/
9617117f1b4Smrg
9627117f1b4Smrg/**
9637117f1b4Smrg * Initialize the context current raster position information.
9647117f1b4Smrg *
9657117f1b4Smrg * \param ctx GL context.
9667117f1b4Smrg *
9677117f1b4Smrg * Initialize the current raster position information in
9683464ebd5Sriastradh * __struct gl_contextRec::Current, and adds the extension entry points to the
9697117f1b4Smrg * dispatcher.
9707117f1b4Smrg */
9713464ebd5Sriastradhvoid _mesa_init_rastpos( struct gl_context * ctx )
9727117f1b4Smrg{
97301e04c3fSmrg   unsigned i;
9747117f1b4Smrg
9757117f1b4Smrg   ASSIGN_4V( ctx->Current.RasterPos, 0.0, 0.0, 0.0, 1.0 );
9767117f1b4Smrg   ctx->Current.RasterDistance = 0.0;
9777117f1b4Smrg   ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 );
9787117f1b4Smrg   ASSIGN_4V( ctx->Current.RasterSecondaryColor, 0.0, 0.0, 0.0, 1.0 );
97901e04c3fSmrg   for (i = 0; i < ARRAY_SIZE(ctx->Current.RasterTexCoords); i++)
9807117f1b4Smrg      ASSIGN_4V( ctx->Current.RasterTexCoords[i], 0.0, 0.0, 0.0, 1.0 );
9817117f1b4Smrg   ctx->Current.RasterPosValid = GL_TRUE;
9827117f1b4Smrg}
9837117f1b4Smrg
9847117f1b4Smrg/*@}*/
985