From 27049189d6221fefe43eb55846efaa51742dcdf4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 11 Jun 2008 19:48:01 -0600 Subject: mesa: refactor: move glTexGen-related functions into new texgen.c file --- src/mesa/main/texgen.c | 605 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 605 insertions(+) create mode 100644 src/mesa/main/texgen.c (limited to 'src/mesa/main/texgen.c') diff --git a/src/mesa/main/texgen.c b/src/mesa/main/texgen.c new file mode 100644 index 0000000000..1018c3037b --- /dev/null +++ b/src/mesa/main/texgen.c @@ -0,0 +1,605 @@ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file texgen.c + * + * glTexGen-related functions + */ + + +#include "main/glheader.h" +#include "main/context.h" +#include "main/enums.h" +#include "main/macros.h" +#include "main/texgen.h" +#include "math/m_xform.h" + + +#define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X)) +#define ENUM_TO_DOUBLE(X) ((GLdouble)(GLint)(X)) + + + +void GLAPIENTRY +_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *texUnit; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE)) + _mesa_debug(ctx, "glTexGen %s %s %.1f(%s)...\n", + _mesa_lookup_enum_by_nr(coord), + _mesa_lookup_enum_by_nr(pname), + *params, + _mesa_lookup_enum_by_nr((GLenum) (GLint) *params)); + + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glTexGen(current unit)"); + return; + } + + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + + switch (coord) { + case GL_S: + if (pname==GL_TEXTURE_GEN_MODE) { + GLenum mode = (GLenum) (GLint) *params; + GLbitfield bits; + switch (mode) { + case GL_OBJECT_LINEAR: + bits = TEXGEN_OBJ_LINEAR; + break; + case GL_EYE_LINEAR: + bits = TEXGEN_EYE_LINEAR; + break; + case GL_REFLECTION_MAP_NV: + bits = TEXGEN_REFLECTION_MAP_NV; + break; + case GL_NORMAL_MAP_NV: + bits = TEXGEN_NORMAL_MAP_NV; + break; + case GL_SPHERE_MAP: + bits = TEXGEN_SPHERE_MAP; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); + return; + } + if (texUnit->GenModeS == mode) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->GenModeS = mode; + texUnit->_GenBitS = bits; + } + else if (pname==GL_OBJECT_PLANE) { + if (TEST_EQ_4V(texUnit->ObjectPlaneS, params)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texUnit->ObjectPlaneS, params); + } + else if (pname==GL_EYE_PLANE) { + GLfloat tmp[4]; + /* Transform plane equation by the inverse modelview matrix */ + if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { + _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); + } + _mesa_transform_vector( tmp, params, ctx->ModelviewMatrixStack.Top->inv ); + if (TEST_EQ_4V(texUnit->EyePlaneS, tmp)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texUnit->EyePlaneS, tmp); + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); + return; + } + break; + case GL_T: + if (pname==GL_TEXTURE_GEN_MODE) { + GLenum mode = (GLenum) (GLint) *params; + GLbitfield bitt; + switch (mode) { + case GL_OBJECT_LINEAR: + bitt = TEXGEN_OBJ_LINEAR; + break; + case GL_EYE_LINEAR: + bitt = TEXGEN_EYE_LINEAR; + break; + case GL_REFLECTION_MAP_NV: + bitt = TEXGEN_REFLECTION_MAP_NV; + break; + case GL_NORMAL_MAP_NV: + bitt = TEXGEN_NORMAL_MAP_NV; + break; + case GL_SPHERE_MAP: + bitt = TEXGEN_SPHERE_MAP; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); + return; + } + if (texUnit->GenModeT == mode) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->GenModeT = mode; + texUnit->_GenBitT = bitt; + } + else if (pname==GL_OBJECT_PLANE) { + if (TEST_EQ_4V(texUnit->ObjectPlaneT, params)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texUnit->ObjectPlaneT, params); + } + else if (pname==GL_EYE_PLANE) { + GLfloat tmp[4]; + /* Transform plane equation by the inverse modelview matrix */ + if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { + _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); + } + _mesa_transform_vector( tmp, params, ctx->ModelviewMatrixStack.Top->inv ); + if (TEST_EQ_4V(texUnit->EyePlaneT, tmp)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texUnit->EyePlaneT, tmp); + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); + return; + } + break; + case GL_R: + if (pname==GL_TEXTURE_GEN_MODE) { + GLenum mode = (GLenum) (GLint) *params; + GLbitfield bitr; + switch (mode) { + case GL_OBJECT_LINEAR: + bitr = TEXGEN_OBJ_LINEAR; + break; + case GL_REFLECTION_MAP_NV: + bitr = TEXGEN_REFLECTION_MAP_NV; + break; + case GL_NORMAL_MAP_NV: + bitr = TEXGEN_NORMAL_MAP_NV; + break; + case GL_EYE_LINEAR: + bitr = TEXGEN_EYE_LINEAR; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); + return; + } + if (texUnit->GenModeR == mode) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->GenModeR = mode; + texUnit->_GenBitR = bitr; + } + else if (pname==GL_OBJECT_PLANE) { + if (TEST_EQ_4V(texUnit->ObjectPlaneR, params)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texUnit->ObjectPlaneR, params); + } + else if (pname==GL_EYE_PLANE) { + GLfloat tmp[4]; + /* Transform plane equation by the inverse modelview matrix */ + if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { + _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); + } + _mesa_transform_vector( tmp, params, ctx->ModelviewMatrixStack.Top->inv ); + if (TEST_EQ_4V(texUnit->EyePlaneR, tmp)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texUnit->EyePlaneR, tmp); + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); + return; + } + break; + case GL_Q: + if (pname==GL_TEXTURE_GEN_MODE) { + GLenum mode = (GLenum) (GLint) *params; + GLbitfield bitq; + switch (mode) { + case GL_OBJECT_LINEAR: + bitq = TEXGEN_OBJ_LINEAR; + break; + case GL_EYE_LINEAR: + bitq = TEXGEN_EYE_LINEAR; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); + return; + } + if (texUnit->GenModeQ == mode) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->GenModeQ = mode; + texUnit->_GenBitQ = bitq; + } + else if (pname==GL_OBJECT_PLANE) { + if (TEST_EQ_4V(texUnit->ObjectPlaneQ, params)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texUnit->ObjectPlaneQ, params); + } + else if (pname==GL_EYE_PLANE) { + GLfloat tmp[4]; + /* Transform plane equation by the inverse modelview matrix */ + if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { + _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); + } + _mesa_transform_vector( tmp, params, ctx->ModelviewMatrixStack.Top->inv ); + if (TEST_EQ_4V(texUnit->EyePlaneQ, tmp)) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + COPY_4FV(texUnit->EyePlaneQ, tmp); + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" ); + return; + } + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(coord)" ); + return; + } + + if (ctx->Driver.TexGen) + ctx->Driver.TexGen( ctx, coord, pname, params ); +} + + +void GLAPIENTRY +_mesa_TexGeniv(GLenum coord, GLenum pname, const GLint *params ) +{ + GLfloat p[4]; + p[0] = (GLfloat) params[0]; + if (pname == GL_TEXTURE_GEN_MODE) { + p[1] = p[2] = p[3] = 0.0F; + } + else { + p[1] = (GLfloat) params[1]; + p[2] = (GLfloat) params[2]; + p[3] = (GLfloat) params[3]; + } + _mesa_TexGenfv(coord, pname, p); +} + + +void GLAPIENTRY +_mesa_TexGend(GLenum coord, GLenum pname, GLdouble param ) +{ + GLfloat p = (GLfloat) param; + _mesa_TexGenfv( coord, pname, &p ); +} + + +void GLAPIENTRY +_mesa_TexGendv(GLenum coord, GLenum pname, const GLdouble *params ) +{ + GLfloat p[4]; + p[0] = (GLfloat) params[0]; + if (pname == GL_TEXTURE_GEN_MODE) { + p[1] = p[2] = p[3] = 0.0F; + } + else { + p[1] = (GLfloat) params[1]; + p[2] = (GLfloat) params[2]; + p[3] = (GLfloat) params[3]; + } + _mesa_TexGenfv( coord, pname, p ); +} + + +void GLAPIENTRY +_mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param ) +{ + _mesa_TexGenfv(coord, pname, ¶m); +} + + +void GLAPIENTRY +_mesa_TexGeni( GLenum coord, GLenum pname, GLint param ) +{ + _mesa_TexGeniv( coord, pname, ¶m ); +} + + + +void GLAPIENTRY +_mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) +{ + const struct gl_texture_unit *texUnit; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGendv(current unit)"); + return; + } + + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + + switch (coord) { + case GL_S: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_DOUBLE(texUnit->GenModeS); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, texUnit->ObjectPlaneS ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, texUnit->EyePlaneS ); + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); + return; + } + break; + case GL_T: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_DOUBLE(texUnit->GenModeT); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, texUnit->ObjectPlaneT ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, texUnit->EyePlaneT ); + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); + return; + } + break; + case GL_R: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_DOUBLE(texUnit->GenModeR); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, texUnit->ObjectPlaneR ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, texUnit->EyePlaneR ); + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); + return; + } + break; + case GL_Q: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_DOUBLE(texUnit->GenModeQ); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, texUnit->ObjectPlaneQ ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, texUnit->EyePlaneQ ); + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" ); + return; + } + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(coord)" ); + return; + } +} + + + +void GLAPIENTRY +_mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) +{ + const struct gl_texture_unit *texUnit; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGenfv(current unit)"); + return; + } + + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + + switch (coord) { + case GL_S: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_FLOAT(texUnit->GenModeS); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, texUnit->ObjectPlaneS ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, texUnit->EyePlaneS ); + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); + return; + } + break; + case GL_T: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_FLOAT(texUnit->GenModeT); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, texUnit->ObjectPlaneT ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, texUnit->EyePlaneT ); + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); + return; + } + break; + case GL_R: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_FLOAT(texUnit->GenModeR); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, texUnit->ObjectPlaneR ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, texUnit->EyePlaneR ); + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); + return; + } + break; + case GL_Q: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = ENUM_TO_FLOAT(texUnit->GenModeQ); + } + else if (pname==GL_OBJECT_PLANE) { + COPY_4V( params, texUnit->ObjectPlaneQ ); + } + else if (pname==GL_EYE_PLANE) { + COPY_4V( params, texUnit->EyePlaneQ ); + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" ); + return; + } + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(coord)" ); + return; + } +} + + + +void GLAPIENTRY +_mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) +{ + const struct gl_texture_unit *texUnit; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexGeniv(current unit)"); + return; + } + + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + + switch (coord) { + case GL_S: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = texUnit->GenModeS; + } + else if (pname==GL_OBJECT_PLANE) { + params[0] = (GLint) texUnit->ObjectPlaneS[0]; + params[1] = (GLint) texUnit->ObjectPlaneS[1]; + params[2] = (GLint) texUnit->ObjectPlaneS[2]; + params[3] = (GLint) texUnit->ObjectPlaneS[3]; + } + else if (pname==GL_EYE_PLANE) { + params[0] = (GLint) texUnit->EyePlaneS[0]; + params[1] = (GLint) texUnit->EyePlaneS[1]; + params[2] = (GLint) texUnit->EyePlaneS[2]; + params[3] = (GLint) texUnit->EyePlaneS[3]; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); + return; + } + break; + case GL_T: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = texUnit->GenModeT; + } + else if (pname==GL_OBJECT_PLANE) { + params[0] = (GLint) texUnit->ObjectPlaneT[0]; + params[1] = (GLint) texUnit->ObjectPlaneT[1]; + params[2] = (GLint) texUnit->ObjectPlaneT[2]; + params[3] = (GLint) texUnit->ObjectPlaneT[3]; + } + else if (pname==GL_EYE_PLANE) { + params[0] = (GLint) texUnit->EyePlaneT[0]; + params[1] = (GLint) texUnit->EyePlaneT[1]; + params[2] = (GLint) texUnit->EyePlaneT[2]; + params[3] = (GLint) texUnit->EyePlaneT[3]; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); + return; + } + break; + case GL_R: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = texUnit->GenModeR; + } + else if (pname==GL_OBJECT_PLANE) { + params[0] = (GLint) texUnit->ObjectPlaneR[0]; + params[1] = (GLint) texUnit->ObjectPlaneR[1]; + params[2] = (GLint) texUnit->ObjectPlaneR[2]; + params[3] = (GLint) texUnit->ObjectPlaneR[3]; + } + else if (pname==GL_EYE_PLANE) { + params[0] = (GLint) texUnit->EyePlaneR[0]; + params[1] = (GLint) texUnit->EyePlaneR[1]; + params[2] = (GLint) texUnit->EyePlaneR[2]; + params[3] = (GLint) texUnit->EyePlaneR[3]; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); + return; + } + break; + case GL_Q: + if (pname==GL_TEXTURE_GEN_MODE) { + params[0] = texUnit->GenModeQ; + } + else if (pname==GL_OBJECT_PLANE) { + params[0] = (GLint) texUnit->ObjectPlaneQ[0]; + params[1] = (GLint) texUnit->ObjectPlaneQ[1]; + params[2] = (GLint) texUnit->ObjectPlaneQ[2]; + params[3] = (GLint) texUnit->ObjectPlaneQ[3]; + } + else if (pname==GL_EYE_PLANE) { + params[0] = (GLint) texUnit->EyePlaneQ[0]; + params[1] = (GLint) texUnit->EyePlaneQ[1]; + params[2] = (GLint) texUnit->EyePlaneQ[2]; + params[3] = (GLint) texUnit->EyePlaneQ[3]; + } + else { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" ); + return; + } + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(coord)" ); + return; + } +} + + -- cgit v1.2.3 From 222c80893a738b964dc75796d47545d88e6a6973 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 11 Jun 2008 20:13:07 -0600 Subject: mesa: refactor: move various ENUM_TO_x macros into macros.h --- src/mesa/main/get.c | 56 ++++++++++++++++++++++++++++++++++++++++++------ src/mesa/main/get_gen.py | 4 ---- src/mesa/main/macros.h | 7 ++++++ src/mesa/main/texenv.c | 2 -- src/mesa/main/texgen.c | 4 ---- src/mesa/main/texparam.c | 3 --- src/mesa/main/texstate.c | 3 --- 7 files changed, 57 insertions(+), 22 deletions(-) (limited to 'src/mesa/main/texgen.c') diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index ee48b78318..ac437a86e2 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -19,10 +19,6 @@ #define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) -#define ENUM_TO_BOOLEAN(E) ( (E) ? GL_TRUE : GL_FALSE ) -#define ENUM_TO_INT(E) ( (GLint) (E) ) -#define ENUM_TO_FLOAT(E) ( (GLfloat) (E) ) - #define BOOLEAN_TO_INT(B) ( (GLint) (B) ) #define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F ) @@ -870,6 +866,14 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) case GL_TEXTURE_3D: params[0] = _mesa_IsEnabled(GL_TEXTURE_3D); break; + case GL_TEXTURE_1D_ARRAY_EXT: + CHECK_EXT1(MESA_texture_array, "GetBooleanv"); + params[0] = _mesa_IsEnabled(GL_TEXTURE_1D_ARRAY_EXT); + break; + case GL_TEXTURE_2D_ARRAY_EXT: + CHECK_EXT1(MESA_texture_array, "GetBooleanv"); + params[0] = _mesa_IsEnabled(GL_TEXTURE_2D_ARRAY_EXT); + break; case GL_TEXTURE_BINDING_1D: params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current1D->Name); break; @@ -879,6 +883,14 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) case GL_TEXTURE_BINDING_3D: params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current3D->Name); break; + case GL_TEXTURE_BINDING_1D_ARRAY_EXT: + CHECK_EXT1(MESA_texture_array, "GetBooleanv"); + params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current1DArray->Name); + break; + case GL_TEXTURE_BINDING_2D_ARRAY_EXT: + CHECK_EXT1(MESA_texture_array, "GetBooleanv"); + params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current2DArray->Name); + break; case GL_TEXTURE_ENV_COLOR: { const GLfloat *color = ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvColor; @@ -2124,7 +2136,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) params[0] = (GLfloat)(ctx->DrawBuffer->Visual.depthBits); break; case GL_DEPTH_CLEAR_VALUE: - params[0] = (GLfloat)ctx->Depth.Clear; + params[0] = ctx->Depth.Clear; break; case GL_DEPTH_FUNC: params[0] = ENUM_TO_FLOAT(ctx->Depth.Func); @@ -2701,6 +2713,14 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) case GL_TEXTURE_3D: params[0] = BOOLEAN_TO_FLOAT(_mesa_IsEnabled(GL_TEXTURE_3D)); break; + case GL_TEXTURE_1D_ARRAY_EXT: + CHECK_EXT1(MESA_texture_array, "GetFloatv"); + params[0] = BOOLEAN_TO_FLOAT(_mesa_IsEnabled(GL_TEXTURE_1D_ARRAY_EXT)); + break; + case GL_TEXTURE_2D_ARRAY_EXT: + CHECK_EXT1(MESA_texture_array, "GetFloatv"); + params[0] = BOOLEAN_TO_FLOAT(_mesa_IsEnabled(GL_TEXTURE_2D_ARRAY_EXT)); + break; case GL_TEXTURE_BINDING_1D: params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current1D->Name); break; @@ -2710,6 +2730,14 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) case GL_TEXTURE_BINDING_3D: params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current3D->Name); break; + case GL_TEXTURE_BINDING_1D_ARRAY_EXT: + CHECK_EXT1(MESA_texture_array, "GetFloatv"); + params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current1DArray->Name); + break; + case GL_TEXTURE_BINDING_2D_ARRAY_EXT: + CHECK_EXT1(MESA_texture_array, "GetFloatv"); + params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current2DArray->Name); + break; case GL_TEXTURE_ENV_COLOR: { const GLfloat *color = ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvColor; @@ -2914,7 +2942,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE); ASSERT(n <= 100); for (i = 0; i < n; i++) - params[i] = (GLfloat)(ENUM_TO_INT(formats[i])); + params[i] = ENUM_TO_INT(formats[i]); } break; case GL_ARRAY_ELEMENT_LOCK_FIRST_EXT: @@ -4532,6 +4560,14 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) case GL_TEXTURE_3D: params[0] = BOOLEAN_TO_INT(_mesa_IsEnabled(GL_TEXTURE_3D)); break; + case GL_TEXTURE_1D_ARRAY_EXT: + CHECK_EXT1(MESA_texture_array, "GetIntegerv"); + params[0] = BOOLEAN_TO_INT(_mesa_IsEnabled(GL_TEXTURE_1D_ARRAY_EXT)); + break; + case GL_TEXTURE_2D_ARRAY_EXT: + CHECK_EXT1(MESA_texture_array, "GetIntegerv"); + params[0] = BOOLEAN_TO_INT(_mesa_IsEnabled(GL_TEXTURE_2D_ARRAY_EXT)); + break; case GL_TEXTURE_BINDING_1D: params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current1D->Name; break; @@ -4541,6 +4577,14 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) case GL_TEXTURE_BINDING_3D: params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current3D->Name; break; + case GL_TEXTURE_BINDING_1D_ARRAY_EXT: + CHECK_EXT1(MESA_texture_array, "GetIntegerv"); + params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current1DArray->Name; + break; + case GL_TEXTURE_BINDING_2D_ARRAY_EXT: + CHECK_EXT1(MESA_texture_array, "GetIntegerv"); + params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current2DArray->Name; + break; case GL_TEXTURE_ENV_COLOR: { const GLfloat *color = ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvColor; diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index 9055433281..c307058da6 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -1127,10 +1127,6 @@ def EmitHeader(): #define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) -#define ENUM_TO_BOOLEAN(E) ( (E) ? GL_TRUE : GL_FALSE ) -#define ENUM_TO_INT(E) ( (GLint) (E) ) -#define ENUM_TO_FLOAT(E) ( (GLfloat) (E) ) - #define BOOLEAN_TO_INT(B) ( (GLint) (B) ) #define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F ) diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index fbbcd4e269..2630855a0e 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -657,4 +657,11 @@ do { \ #define LEN_SQUARED_2FV( V ) ((V)[0]*(V)[0]+(V)[1]*(V)[1]) +/** casts to silence warnings with some compilers */ +#define ENUM_TO_INT(E) ((GLint)(E)) +#define ENUM_TO_FLOAT(E) ((GLfloat)(GLint)(E)) +#define ENUM_TO_DOUBLE(E) ((GLdouble)(GLint)(E)) +#define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE) + + #endif diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c index 2b5b15524e..e072cea136 100644 --- a/src/mesa/main/texenv.c +++ b/src/mesa/main/texenv.c @@ -37,8 +37,6 @@ #include "math/m_xform.h" -#define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X)) - void GLAPIENTRY _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) diff --git a/src/mesa/main/texgen.c b/src/mesa/main/texgen.c index 1018c3037b..244c7aaafc 100644 --- a/src/mesa/main/texgen.c +++ b/src/mesa/main/texgen.c @@ -37,10 +37,6 @@ #include "math/m_xform.h" -#define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X)) -#define ENUM_TO_DOUBLE(X) ((GLdouble)(GLint)(X)) - - void GLAPIENTRY _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index 10ad0ef1d8..af288c4e18 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -39,9 +39,6 @@ #include "main/teximage.h" -#define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X)) - - /** * Check if a coordinate wrap mode is supported for the texture target. * \return GL_TRUE if legal, GL_FALSE otherwise diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index dbd769d740..421f912849 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -45,9 +45,6 @@ #include "math/m_xform.h" -#define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X)) -#define ENUM_TO_DOUBLE(X) ((GLdouble)(GLint)(X)) - /** * Default texture combine environment state. This is used to initialize -- cgit v1.2.3