1c1f859d4Smrg/*
2c1f859d4Smrg * Mesa 3-D graphics library
3c1f859d4Smrg *
4c1f859d4Smrg * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
54a49301eSmrg * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
6c1f859d4Smrg *
7c1f859d4Smrg * Permission is hereby granted, free of charge, to any person obtaining a
8c1f859d4Smrg * copy of this software and associated documentation files (the "Software"),
9c1f859d4Smrg * to deal in the Software without restriction, including without limitation
10c1f859d4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11c1f859d4Smrg * and/or sell copies of the Software, and to permit persons to whom the
12c1f859d4Smrg * Software is furnished to do so, subject to the following conditions:
13c1f859d4Smrg *
14c1f859d4Smrg * The above copyright notice and this permission notice shall be included
15c1f859d4Smrg * in all copies or substantial portions of the Software.
16c1f859d4Smrg *
17c1f859d4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18c1f859d4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19c1f859d4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE.
24c1f859d4Smrg */
25c1f859d4Smrg
26c1f859d4Smrg/**
27c1f859d4Smrg * \file texgen.c
28c1f859d4Smrg *
29c1f859d4Smrg * glTexGen-related functions
30c1f859d4Smrg */
31c1f859d4Smrg
32c1f859d4Smrg
33c1f859d4Smrg#include "main/glheader.h"
34c1f859d4Smrg#include "main/context.h"
35c1f859d4Smrg#include "main/enums.h"
36c1f859d4Smrg#include "main/macros.h"
37c1f859d4Smrg#include "main/texgen.h"
384a49301eSmrg#include "main/texstate.h"
394a49301eSmrg#include "math/m_matrix.h"
40c1f859d4Smrg
41c1f859d4Smrg
424a49301eSmrg/**
434a49301eSmrg * Return texgen state for given coordinate
444a49301eSmrg */
454a49301eSmrgstatic struct gl_texgen *
467ec681f3Smrgget_texgen(struct gl_context *ctx, GLuint texunitIndex, GLenum coord, const char* caller)
474a49301eSmrg{
487ec681f3Smrg   struct gl_fixedfunc_texture_unit* texUnit;
497ec681f3Smrg   if (texunitIndex >= ctx->Const.MaxTextureCoordUnits) {
507ec681f3Smrg      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unit=%d)", caller, texunitIndex);
517ec681f3Smrg      return NULL;
527ec681f3Smrg   }
537ec681f3Smrg
547ec681f3Smrg   texUnit = _mesa_get_fixedfunc_tex_unit(ctx, texunitIndex);
557ec681f3Smrg
56af69d88dSmrg   if (ctx->API == API_OPENGLES) {
57af69d88dSmrg      return (coord == GL_TEXTURE_GEN_STR_OES)
58af69d88dSmrg         ? &texUnit->GenS : NULL;
59af69d88dSmrg   }
60af69d88dSmrg
614a49301eSmrg   switch (coord) {
624a49301eSmrg   case GL_S:
634a49301eSmrg      return &texUnit->GenS;
644a49301eSmrg   case GL_T:
654a49301eSmrg      return &texUnit->GenT;
664a49301eSmrg   case GL_R:
674a49301eSmrg      return &texUnit->GenR;
684a49301eSmrg   case GL_Q:
694a49301eSmrg      return &texUnit->GenQ;
704a49301eSmrg   default:
714a49301eSmrg      return NULL;
724a49301eSmrg   }
734a49301eSmrg}
744a49301eSmrg
75c1f859d4Smrg
767ec681f3Smrg/* Helper for glTexGenfv and glMultiTexGenfvEXT functions */
777ec681f3Smrgstatic void
787ec681f3Smrgtexgenfv( GLuint texunitIndex, GLenum coord, GLenum pname,
797ec681f3Smrg          const GLfloat *params, const char* caller )
80c1f859d4Smrg{
814a49301eSmrg   struct gl_texgen *texgen;
824a49301eSmrg   GET_CURRENT_CONTEXT(ctx);
83c1f859d4Smrg
847ec681f3Smrg   texgen = get_texgen(ctx, texunitIndex, coord, caller);
854a49301eSmrg   if (!texgen) {
867ec681f3Smrg      _mesa_error(ctx, GL_INVALID_ENUM, "%s(coord)", caller);
874a49301eSmrg      return;
884a49301eSmrg   }
894a49301eSmrg
907ec681f3Smrg   struct gl_fixedfunc_texture_unit *unit = &ctx->Texture.FixedFuncUnit[texunitIndex];
917ec681f3Smrg   int index = coord == GL_TEXTURE_GEN_STR_OES ? 0 : (coord - GL_S);
927ec681f3Smrg
934a49301eSmrg   switch (pname) {
944a49301eSmrg   case GL_TEXTURE_GEN_MODE:
954a49301eSmrg      {
964a49301eSmrg         GLenum mode = (GLenum) (GLint) params[0];
974a49301eSmrg         GLbitfield bit = 0x0;
984a49301eSmrg         if (texgen->Mode == mode)
994a49301eSmrg            return;
1004a49301eSmrg         switch (mode) {
1014a49301eSmrg         case GL_OBJECT_LINEAR:
1024a49301eSmrg            bit = TEXGEN_OBJ_LINEAR;
1034a49301eSmrg            break;
1044a49301eSmrg         case GL_EYE_LINEAR:
1054a49301eSmrg            bit = TEXGEN_EYE_LINEAR;
1064a49301eSmrg            break;
1074a49301eSmrg         case GL_SPHERE_MAP:
1084a49301eSmrg            if (coord == GL_S || coord == GL_T)
1094a49301eSmrg               bit = TEXGEN_SPHERE_MAP;
1104a49301eSmrg            break;
1114a49301eSmrg         case GL_REFLECTION_MAP_NV:
1124a49301eSmrg            if (coord != GL_Q)
1134a49301eSmrg               bit = TEXGEN_REFLECTION_MAP_NV;
1144a49301eSmrg            break;
1154a49301eSmrg         case GL_NORMAL_MAP_NV:
1164a49301eSmrg            if (coord != GL_Q)
1174a49301eSmrg               bit = TEXGEN_NORMAL_MAP_NV;
1184a49301eSmrg            break;
1194a49301eSmrg         default:
1204a49301eSmrg            ; /* nop */
1214a49301eSmrg         }
1224a49301eSmrg         if (!bit) {
1234a49301eSmrg            _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
1244a49301eSmrg            return;
1254a49301eSmrg         }
126af69d88dSmrg         if (ctx->API != API_OPENGL_COMPAT
127af69d88dSmrg             && (bit & (TEXGEN_REFLECTION_MAP_NV | TEXGEN_NORMAL_MAP_NV)) == 0) {
128af69d88dSmrg            _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
129af69d88dSmrg            return;
130af69d88dSmrg         }
131af69d88dSmrg
1327ec681f3Smrg         FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE | _NEW_FF_VERT_PROGRAM,
1337ec681f3Smrg                        GL_TEXTURE_BIT);
1344a49301eSmrg         texgen->Mode = mode;
1354a49301eSmrg         texgen->_ModeBit = bit;
1364a49301eSmrg      }
1374a49301eSmrg      break;
1384a49301eSmrg
1394a49301eSmrg   case GL_OBJECT_PLANE:
1404a49301eSmrg      {
141af69d88dSmrg         if (ctx->API != API_OPENGL_COMPAT) {
142af69d88dSmrg            _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
143af69d88dSmrg            return;
144af69d88dSmrg         }
1457ec681f3Smrg         if (TEST_EQ_4V(unit->ObjectPlane[index], params))
1464a49301eSmrg            return;
1477ec681f3Smrg         FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE, GL_TEXTURE_BIT);
1487ec681f3Smrg         COPY_4FV(unit->ObjectPlane[index], params);
1494a49301eSmrg      }
1504a49301eSmrg      break;
1514a49301eSmrg
1524a49301eSmrg   case GL_EYE_PLANE:
1534a49301eSmrg      {
1544a49301eSmrg         GLfloat tmp[4];
155af69d88dSmrg
156af69d88dSmrg         if (ctx->API != API_OPENGL_COMPAT) {
157af69d88dSmrg            _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
158af69d88dSmrg            return;
159af69d88dSmrg         }
160af69d88dSmrg
1614a49301eSmrg         /* Transform plane equation by the inverse modelview matrix */
1624a49301eSmrg         if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) {
1634a49301eSmrg            _math_matrix_analyse(ctx->ModelviewMatrixStack.Top);
1644a49301eSmrg         }
1654a49301eSmrg         _mesa_transform_vector(tmp, params,
1664a49301eSmrg                                ctx->ModelviewMatrixStack.Top->inv);
1677ec681f3Smrg         if (TEST_EQ_4V(unit->EyePlane[index], tmp))
1684a49301eSmrg            return;
1697ec681f3Smrg         FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE, GL_TEXTURE_BIT);
1707ec681f3Smrg         COPY_4FV(unit->EyePlane[index], tmp);
1714a49301eSmrg      }
1724a49301eSmrg      break;
1734a49301eSmrg
1744a49301eSmrg   default:
1754a49301eSmrg      _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
1764a49301eSmrg      return;
177c1f859d4Smrg   }
178c1f859d4Smrg
179c1f859d4Smrg   if (ctx->Driver.TexGen)
180c1f859d4Smrg      ctx->Driver.TexGen( ctx, coord, pname, params );
181c1f859d4Smrg}
182c1f859d4Smrg
183c1f859d4Smrg
1847ec681f3Smrg/* Helper for glGetTexGendv / glGetMultiTexGendvEXT */
1857ec681f3Smrgstatic void
1867ec681f3Smrggettexgendv( GLuint texunitIndex, GLenum coord, GLenum pname,
1877ec681f3Smrg             GLdouble *params, const char* caller)
1887ec681f3Smrg{
1897ec681f3Smrg   struct gl_texgen *texgen;
1907ec681f3Smrg   GET_CURRENT_CONTEXT(ctx);
1917ec681f3Smrg
1927ec681f3Smrg   texgen = get_texgen(ctx, texunitIndex, coord, caller);
1937ec681f3Smrg   if (!texgen) {
1947ec681f3Smrg      _mesa_error(ctx, GL_INVALID_ENUM, "%s(coord)", caller);
1957ec681f3Smrg      return;
1967ec681f3Smrg   }
1977ec681f3Smrg
1987ec681f3Smrg   struct gl_fixedfunc_texture_unit *unit = &ctx->Texture.FixedFuncUnit[texunitIndex];
1997ec681f3Smrg   int index = coord == GL_TEXTURE_GEN_STR_OES ? 0 : (coord - GL_S);
2007ec681f3Smrg
2017ec681f3Smrg   switch (pname) {
2027ec681f3Smrg   case GL_TEXTURE_GEN_MODE:
2037ec681f3Smrg      params[0] = ENUM_TO_DOUBLE(texgen->Mode);
2047ec681f3Smrg      break;
2057ec681f3Smrg   case GL_OBJECT_PLANE:
2067ec681f3Smrg      COPY_4V(params, unit->ObjectPlane[index]);
2077ec681f3Smrg      break;
2087ec681f3Smrg   case GL_EYE_PLANE:
2097ec681f3Smrg      COPY_4V(params, unit->EyePlane[index]);
2107ec681f3Smrg      break;
2117ec681f3Smrg   default:
2127ec681f3Smrg      _mesa_error( ctx, GL_INVALID_ENUM, "%s(pname)", caller );
2137ec681f3Smrg   }
2147ec681f3Smrg}
2157ec681f3Smrg
2167ec681f3Smrg
2177ec681f3Smrg/* Helper for glGetTexGenfv / glGetMultiTexGenfvEXT */
2187ec681f3Smrgstatic void
2197ec681f3Smrggettexgenfv( GLenum texunitIndex, GLenum coord, GLenum pname,
2207ec681f3Smrg             GLfloat *params, const char* caller )
2217ec681f3Smrg{
2227ec681f3Smrg   struct gl_texgen *texgen;
2237ec681f3Smrg   GET_CURRENT_CONTEXT(ctx);
2247ec681f3Smrg
2257ec681f3Smrg   texgen = get_texgen(ctx, texunitIndex, coord, caller);
2267ec681f3Smrg   if (!texgen) {
2277ec681f3Smrg      _mesa_error(ctx, GL_INVALID_ENUM, "%s(coord)", caller);
2287ec681f3Smrg      return;
2297ec681f3Smrg   }
2307ec681f3Smrg
2317ec681f3Smrg   struct gl_fixedfunc_texture_unit *unit = &ctx->Texture.FixedFuncUnit[texunitIndex];
2327ec681f3Smrg   int index = coord == GL_TEXTURE_GEN_STR_OES ? 0 : (coord - GL_S);
2337ec681f3Smrg
2347ec681f3Smrg   switch (pname) {
2357ec681f3Smrg   case GL_TEXTURE_GEN_MODE:
2367ec681f3Smrg      params[0] = ENUM_TO_FLOAT(texgen->Mode);
2377ec681f3Smrg      break;
2387ec681f3Smrg   case GL_OBJECT_PLANE:
2397ec681f3Smrg      if (ctx->API != API_OPENGL_COMPAT) {
2407ec681f3Smrg         _mesa_error( ctx, GL_INVALID_ENUM, "%s(param)", caller );
2417ec681f3Smrg         return;
2427ec681f3Smrg      }
2437ec681f3Smrg      COPY_4V(params, unit->ObjectPlane[index]);
2447ec681f3Smrg      break;
2457ec681f3Smrg   case GL_EYE_PLANE:
2467ec681f3Smrg      if (ctx->API != API_OPENGL_COMPAT) {
2477ec681f3Smrg         _mesa_error( ctx, GL_INVALID_ENUM, "%s(param)", caller );
2487ec681f3Smrg         return;
2497ec681f3Smrg      }
2507ec681f3Smrg      COPY_4V(params, unit->EyePlane[index]);
2517ec681f3Smrg      break;
2527ec681f3Smrg   default:
2537ec681f3Smrg      _mesa_error( ctx, GL_INVALID_ENUM, "%s(pname)", caller );
2547ec681f3Smrg   }
2557ec681f3Smrg}
2567ec681f3Smrg
2577ec681f3Smrg
2587ec681f3Smrg/* Helper for glGetTexGeniv / glGetMultiTexGenivEXT */
2597ec681f3Smrgstatic void
2607ec681f3Smrggettexgeniv( GLenum texunitIndex, GLenum coord, GLenum pname,
2617ec681f3Smrg             GLint *params, const char* caller)
2627ec681f3Smrg{
2637ec681f3Smrg   struct gl_texgen *texgen;
2647ec681f3Smrg   GET_CURRENT_CONTEXT(ctx);
2657ec681f3Smrg
2667ec681f3Smrg   texgen = get_texgen(ctx, texunitIndex, coord, caller);
2677ec681f3Smrg   if (!texgen) {
2687ec681f3Smrg      _mesa_error(ctx, GL_INVALID_ENUM, "%s(coord)", caller);
2697ec681f3Smrg      return;
2707ec681f3Smrg   }
2717ec681f3Smrg
2727ec681f3Smrg   struct gl_fixedfunc_texture_unit *unit = &ctx->Texture.FixedFuncUnit[texunitIndex];
2737ec681f3Smrg   int index = coord == GL_TEXTURE_GEN_STR_OES ? 0 : (coord - GL_S);
2747ec681f3Smrg
2757ec681f3Smrg   switch (pname) {
2767ec681f3Smrg   case GL_TEXTURE_GEN_MODE:
2777ec681f3Smrg      params[0] = texgen->Mode;
2787ec681f3Smrg      break;
2797ec681f3Smrg   case GL_OBJECT_PLANE:
2807ec681f3Smrg      if (ctx->API != API_OPENGL_COMPAT) {
2817ec681f3Smrg         _mesa_error( ctx, GL_INVALID_ENUM, "%s(param)" , caller);
2827ec681f3Smrg         return;
2837ec681f3Smrg      }
2847ec681f3Smrg      params[0] = (GLint) unit->ObjectPlane[index][0];
2857ec681f3Smrg      params[1] = (GLint) unit->ObjectPlane[index][1];
2867ec681f3Smrg      params[2] = (GLint) unit->ObjectPlane[index][2];
2877ec681f3Smrg      params[3] = (GLint) unit->ObjectPlane[index][3];
2887ec681f3Smrg      break;
2897ec681f3Smrg   case GL_EYE_PLANE:
2907ec681f3Smrg      if (ctx->API != API_OPENGL_COMPAT) {
2917ec681f3Smrg         _mesa_error( ctx, GL_INVALID_ENUM, "%s(param)" , caller);
2927ec681f3Smrg         return;
2937ec681f3Smrg      }
2947ec681f3Smrg      params[0] = (GLint) unit->EyePlane[index][0];
2957ec681f3Smrg      params[1] = (GLint) unit->EyePlane[index][1];
2967ec681f3Smrg      params[2] = (GLint) unit->EyePlane[index][2];
2977ec681f3Smrg      params[3] = (GLint) unit->EyePlane[index][3];
2987ec681f3Smrg      break;
2997ec681f3Smrg   default:
3007ec681f3Smrg      _mesa_error( ctx, GL_INVALID_ENUM, "%s(pname)" , caller);
3017ec681f3Smrg   }
3027ec681f3Smrg}
3037ec681f3Smrg
3047ec681f3Smrg
3057ec681f3Smrgvoid GLAPIENTRY
3067ec681f3Smrg_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
3077ec681f3Smrg{
3087ec681f3Smrg   GET_CURRENT_CONTEXT(ctx);
3097ec681f3Smrg   texgenfv(ctx->Texture.CurrentUnit, coord, pname, params, "glTexGenfv");
3107ec681f3Smrg}
3117ec681f3Smrg
3127ec681f3Smrg
3137ec681f3Smrgvoid GLAPIENTRY
3147ec681f3Smrg_mesa_MultiTexGenfvEXT( GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params )
3157ec681f3Smrg{
3167ec681f3Smrg   texgenfv(texunit - GL_TEXTURE0, coord, pname, params, "glMultiTexGenfvEXT");
3177ec681f3Smrg}
3187ec681f3Smrg
3197ec681f3Smrg
320af69d88dSmrgvoid GLAPIENTRY
321c1f859d4Smrg_mesa_TexGeniv(GLenum coord, GLenum pname, const GLint *params )
3227ec681f3Smrg{
3237ec681f3Smrg   GET_CURRENT_CONTEXT(ctx);
3247ec681f3Smrg   GLfloat p[4];
3257ec681f3Smrg   p[0] = (GLfloat) params[0];
3267ec681f3Smrg   if (pname == GL_TEXTURE_GEN_MODE) {
3277ec681f3Smrg      p[1] = p[2] = p[3] = 0.0F;
3287ec681f3Smrg   }
3297ec681f3Smrg   else {
3307ec681f3Smrg      p[1] = (GLfloat) params[1];
3317ec681f3Smrg      p[2] = (GLfloat) params[2];
3327ec681f3Smrg      p[3] = (GLfloat) params[3];
3337ec681f3Smrg   }
3347ec681f3Smrg   texgenfv(ctx->Texture.CurrentUnit, coord, pname, p, "glTexGeniv");
3357ec681f3Smrg}
3367ec681f3Smrg
3377ec681f3Smrgvoid GLAPIENTRY
3387ec681f3Smrg_mesa_MultiTexGenivEXT(GLenum texunit, GLenum coord, GLenum pname, const GLint *params )
339c1f859d4Smrg{
340c1f859d4Smrg   GLfloat p[4];
341c1f859d4Smrg   p[0] = (GLfloat) params[0];
342c1f859d4Smrg   if (pname == GL_TEXTURE_GEN_MODE) {
343c1f859d4Smrg      p[1] = p[2] = p[3] = 0.0F;
344c1f859d4Smrg   }
345c1f859d4Smrg   else {
346c1f859d4Smrg      p[1] = (GLfloat) params[1];
347c1f859d4Smrg      p[2] = (GLfloat) params[2];
348c1f859d4Smrg      p[3] = (GLfloat) params[3];
349c1f859d4Smrg   }
3507ec681f3Smrg   texgenfv(texunit - GL_TEXTURE0, coord, pname, p, "glMultiTexGenivEXT");
351c1f859d4Smrg}
352c1f859d4Smrg
353c1f859d4Smrg
354af69d88dSmrgvoid GLAPIENTRY
355c1f859d4Smrg_mesa_TexGend(GLenum coord, GLenum pname, GLdouble param )
356c1f859d4Smrg{
3577ec681f3Smrg   GET_CURRENT_CONTEXT(ctx);
3584a49301eSmrg   GLfloat p[4];
3594a49301eSmrg   p[0] = (GLfloat) param;
3604a49301eSmrg   p[1] = p[2] = p[3] = 0.0F;
3617ec681f3Smrg   texgenfv(ctx->Texture.CurrentUnit, coord, pname, p, "glTexGend");
362c1f859d4Smrg}
363c1f859d4Smrg
3643464ebd5Sriastradh
3657ec681f3Smrgvoid GLAPIENTRY
3667ec681f3Smrg_mesa_MultiTexGendEXT(GLenum texunit, GLenum coord, GLenum pname, GLdouble param )
3677ec681f3Smrg{
3687ec681f3Smrg   GLfloat p[4];
3697ec681f3Smrg   p[0] = (GLfloat) param;
3707ec681f3Smrg   p[1] = p[2] = p[3] = 0.0F;
3717ec681f3Smrg   texgenfv(texunit - GL_TEXTURE0, coord, pname, p, "glMultiTexGendEXT");
3727ec681f3Smrg}
3737ec681f3Smrg
3743464ebd5Sriastradhvoid GLAPIENTRY
3753464ebd5Sriastradh_es_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params)
3763464ebd5Sriastradh{
3773464ebd5Sriastradh   _mesa_GetTexGenfv(GL_S, pname, params);
3783464ebd5Sriastradh}
3793464ebd5Sriastradh
3803464ebd5Sriastradh
3813464ebd5Sriastradhvoid GLAPIENTRY
3823464ebd5Sriastradh_es_TexGenf(GLenum coord, GLenum pname, GLfloat param)
3833464ebd5Sriastradh{
384af69d88dSmrg   if (coord != GL_TEXTURE_GEN_STR_OES) {
385af69d88dSmrg      GET_CURRENT_CONTEXT(ctx);
386af69d88dSmrg      _mesa_error( ctx, GL_INVALID_ENUM, "glTexGen[fx](pname)" );
387af69d88dSmrg      return;
388af69d88dSmrg   }
3893464ebd5Sriastradh   /* set S, T, and R at the same time */
3903464ebd5Sriastradh   _mesa_TexGenf(GL_S, pname, param);
3913464ebd5Sriastradh   _mesa_TexGenf(GL_T, pname, param);
3923464ebd5Sriastradh   _mesa_TexGenf(GL_R, pname, param);
3933464ebd5Sriastradh}
3943464ebd5Sriastradh
3953464ebd5Sriastradh
3963464ebd5Sriastradhvoid GLAPIENTRY
3973464ebd5Sriastradh_es_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params)
3983464ebd5Sriastradh{
399af69d88dSmrg   if (coord != GL_TEXTURE_GEN_STR_OES) {
400af69d88dSmrg      GET_CURRENT_CONTEXT(ctx);
401af69d88dSmrg      _mesa_error( ctx, GL_INVALID_ENUM, "glTexGen[fx]v(pname)" );
402af69d88dSmrg      return;
403af69d88dSmrg   }
4043464ebd5Sriastradh   /* set S, T, and R at the same time */
4053464ebd5Sriastradh   _mesa_TexGenfv(GL_S, pname, params);
4063464ebd5Sriastradh   _mesa_TexGenfv(GL_T, pname, params);
4073464ebd5Sriastradh   _mesa_TexGenfv(GL_R, pname, params);
4083464ebd5Sriastradh}
4093464ebd5Sriastradh
410c1f859d4Smrg
411af69d88dSmrgvoid GLAPIENTRY
412c1f859d4Smrg_mesa_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
4137ec681f3Smrg{
4147ec681f3Smrg   GET_CURRENT_CONTEXT(ctx);
4157ec681f3Smrg   GLfloat p[4];
4167ec681f3Smrg   p[0] = (GLfloat) params[0];
4177ec681f3Smrg   if (pname == GL_TEXTURE_GEN_MODE) {
4187ec681f3Smrg      p[1] = p[2] = p[3] = 0.0F;
4197ec681f3Smrg   }
4207ec681f3Smrg   else {
4217ec681f3Smrg      p[1] = (GLfloat) params[1];
4227ec681f3Smrg      p[2] = (GLfloat) params[2];
4237ec681f3Smrg      p[3] = (GLfloat) params[3];
4247ec681f3Smrg   }
4257ec681f3Smrg   texgenfv(ctx->Texture.CurrentUnit, coord, pname, p, "glTexGendv");
4267ec681f3Smrg}
4277ec681f3Smrg
4287ec681f3Smrg
4297ec681f3Smrgvoid GLAPIENTRY
4307ec681f3Smrg_mesa_MultiTexGendvEXT(GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params )
431c1f859d4Smrg{
432c1f859d4Smrg   GLfloat p[4];
433c1f859d4Smrg   p[0] = (GLfloat) params[0];
434c1f859d4Smrg   if (pname == GL_TEXTURE_GEN_MODE) {
435c1f859d4Smrg      p[1] = p[2] = p[3] = 0.0F;
436c1f859d4Smrg   }
437c1f859d4Smrg   else {
438c1f859d4Smrg      p[1] = (GLfloat) params[1];
439c1f859d4Smrg      p[2] = (GLfloat) params[2];
440c1f859d4Smrg      p[3] = (GLfloat) params[3];
441c1f859d4Smrg   }
4427ec681f3Smrg   texgenfv(texunit - GL_TEXTURE0, coord, pname, p, "glMultiTexGendvEXT");
443c1f859d4Smrg}
444c1f859d4Smrg
445c1f859d4Smrg
446cdc920a0Smrgvoid GLAPIENTRY
447c1f859d4Smrg_mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param )
448c1f859d4Smrg{
4497ec681f3Smrg   GET_CURRENT_CONTEXT(ctx);
4504a49301eSmrg   GLfloat p[4];
4514a49301eSmrg   p[0] = param;
4524a49301eSmrg   p[1] = p[2] = p[3] = 0.0F;
4537ec681f3Smrg   texgenfv(ctx->Texture.CurrentUnit, coord, pname, p, "glTexGenf");
4547ec681f3Smrg}
4557ec681f3Smrg
4567ec681f3Smrg
4577ec681f3Smrgvoid GLAPIENTRY
4587ec681f3Smrg_mesa_MultiTexGenfEXT( GLenum texunit, GLenum coord, GLenum pname, GLfloat param )
4597ec681f3Smrg{
4607ec681f3Smrg   GLfloat p[4];
4617ec681f3Smrg   p[0] = param;
4627ec681f3Smrg   p[1] = p[2] = p[3] = 0.0F;
4637ec681f3Smrg   texgenfv(texunit - GL_TEXTURE0, coord, pname, p, "glMultiTexGenfEXT");
464c1f859d4Smrg}
465c1f859d4Smrg
466c1f859d4Smrg
467c1f859d4Smrgvoid GLAPIENTRY
468c1f859d4Smrg_mesa_TexGeni( GLenum coord, GLenum pname, GLint param )
469c1f859d4Smrg{
4704a49301eSmrg   GLint p[4];
4714a49301eSmrg   p[0] = param;
4724a49301eSmrg   p[1] = p[2] = p[3] = 0;
4734a49301eSmrg   _mesa_TexGeniv( coord, pname, p );
474c1f859d4Smrg}
475c1f859d4Smrg
476c1f859d4Smrg
4777ec681f3Smrgvoid GLAPIENTRY
4787ec681f3Smrg_mesa_MultiTexGeniEXT( GLenum texunit, GLenum coord, GLenum pname, GLint param )
4797ec681f3Smrg{
4807ec681f3Smrg   GLint p[4];
4817ec681f3Smrg   p[0] = param;
4827ec681f3Smrg   p[1] = p[2] = p[3] = 0;
4837ec681f3Smrg   _mesa_MultiTexGenivEXT( texunit, coord, pname, p );
4847ec681f3Smrg}
4857ec681f3Smrg
486c1f859d4Smrg
487af69d88dSmrgvoid GLAPIENTRY
488c1f859d4Smrg_mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
489c1f859d4Smrg{
490c1f859d4Smrg   GET_CURRENT_CONTEXT(ctx);
4917ec681f3Smrg   gettexgendv(ctx->Texture.CurrentUnit, coord, pname, params, "glGetTexGendv");
4927ec681f3Smrg}
493c1f859d4Smrg
4944a49301eSmrg
4957ec681f3Smrgvoid GLAPIENTRY
4967ec681f3Smrg_mesa_GetMultiTexGendvEXT( GLenum texunit, GLenum coord, GLenum pname, GLdouble *params )
4977ec681f3Smrg{
4987ec681f3Smrg   gettexgendv(texunit - GL_TEXTURE0, coord, pname, params, "glGetMultiTexGendvEXT");
499c1f859d4Smrg}
500c1f859d4Smrg
501c1f859d4Smrg
502cdc920a0Smrgvoid GLAPIENTRY
503c1f859d4Smrg_mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
504c1f859d4Smrg{
505c1f859d4Smrg   GET_CURRENT_CONTEXT(ctx);
5067ec681f3Smrg   gettexgenfv(ctx->Texture.CurrentUnit, coord, pname, params, "glGetTexGenfv");
5077ec681f3Smrg}
508c1f859d4Smrg
5094a49301eSmrg
5107ec681f3Smrgvoid GLAPIENTRY
5117ec681f3Smrg_mesa_GetMultiTexGenfvEXT( GLenum texunit, GLenum coord, GLenum pname, GLfloat *params )
5127ec681f3Smrg{
5137ec681f3Smrg   gettexgenfv(texunit - GL_TEXTURE0, coord, pname, params, "glGetMultiTexGenfvEXT");
514c1f859d4Smrg}
515c1f859d4Smrg
516c1f859d4Smrg
517af69d88dSmrgvoid GLAPIENTRY
518c1f859d4Smrg_mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params )
519c1f859d4Smrg{
520c1f859d4Smrg   GET_CURRENT_CONTEXT(ctx);
5217ec681f3Smrg   gettexgeniv(ctx->Texture.CurrentUnit, coord, pname, params, "glGetTexGeniv");
5227ec681f3Smrg}
523c1f859d4Smrg
524c1f859d4Smrg
5257ec681f3Smrgvoid GLAPIENTRY
5267ec681f3Smrg_mesa_GetMultiTexGenivEXT( GLenum texunit, GLenum coord, GLenum pname, GLint *params )
5277ec681f3Smrg{
5287ec681f3Smrg   gettexgeniv(texunit - GL_TEXTURE0, coord, pname, params, "glGetTexGenivEXT");
5294a49301eSmrg}
530