summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2000-06-27 21:42:13 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2000-06-27 21:42:13 +0000
commit24507ff6ab91a85f98da60745bd6585499968b60 (patch)
tree8789749ef7730137f5e5085296d9fdaa25c1666f
parent92009554ce2e4c38c5abd4f09365ee8211570d4c (diff)
added GL_EXT_texture_env_combine (Holger Waechtler)
-rw-r--r--src/mesa/drivers/osmesa/osmesa.c3
-rw-r--r--src/mesa/main/context.c19
-rw-r--r--src/mesa/main/drawpix.c9
-rw-r--r--src/mesa/main/enums.c27
-rw-r--r--src/mesa/main/extensions.c4
-rw-r--r--src/mesa/main/texstate.c463
6 files changed, 469 insertions, 56 deletions
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index 081dbc4e190..56059607118 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -1,4 +1,4 @@
-/* $Id: osmesa.c,v 1.18 2000/05/26 16:17:00 brianp Exp $ */
+/* $Id: osmesa.c,v 1.19 2000/06/27 21:42:14 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -226,6 +226,7 @@ OSMesaCreateContext( GLenum format, OSMesaContext sharelist )
}
gl_extensions_enable(&(osmesa->gl_ctx),"GL_HP_occlusion_test");
gl_extensions_enable(&(osmesa->gl_ctx), "GL_ARB_texture_cube_map");
+ gl_extensions_enable(&(osmesa->gl_ctx), "GL_EXT_texture_env_combine");
osmesa->gl_buffer = gl_create_framebuffer( osmesa->gl_visual,
osmesa->gl_visual->DepthBits > 0,
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index d17897a7dff..7ed7f12425f 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.71 2000/06/27 04:29:22 brianp Exp $ */
+/* $Id: context.c,v 1.72 2000/06/27 21:42:13 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -594,6 +594,23 @@ init_texture_unit( GLcontext *ctx, GLuint unit )
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
texUnit->EnvMode = GL_MODULATE;
+ texUnit->CombineModeRGB = GL_MODULATE;
+ texUnit->CombineModeA = GL_MODULATE;
+ texUnit->CombineSourceRGB[0] = GL_TEXTURE;
+ texUnit->CombineSourceRGB[1] = GL_PREVIOUS_EXT;
+ texUnit->CombineSourceRGB[2] = GL_CONSTANT_EXT;
+ texUnit->CombineSourceA[0] = GL_TEXTURE;
+ texUnit->CombineSourceA[1] = GL_PREVIOUS_EXT;
+ texUnit->CombineSourceA[2] = GL_CONSTANT_EXT;
+ texUnit->CombineOperandRGB[0] = GL_SRC_COLOR;
+ texUnit->CombineOperandRGB[1] = GL_SRC_COLOR;
+ texUnit->CombineOperandRGB[2] = GL_SRC_ALPHA;
+ texUnit->CombineOperandA[0] = GL_SRC_ALPHA;
+ texUnit->CombineOperandA[1] = GL_SRC_ALPHA;
+ texUnit->CombineOperandA[2] = GL_SRC_ALPHA;
+ texUnit->CombineScaleShiftRGB = 0;
+ texUnit->CombineScaleShiftA = 0;
+
ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 );
texUnit->TexGenEnabled = 0;
texUnit->GenModeS = GL_EYE_LINEAR;
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index a7f309029d6..36e8af3b939 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -1,4 +1,4 @@
-/* $Id: drawpix.c,v 1.23 2000/06/27 04:32:16 brianp Exp $ */
+/* $Id: drawpix.c,v 1.24 2000/06/27 21:42:13 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -658,12 +658,17 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) {
GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH];
+ GLubyte primary_rgba[MAX_WIDTH][4];
GLuint unit;
/* XXX not sure how multitexture is supposed to work here */
+
+ MEMCPY(primary_rgba, rgba, 4 * width * sizeof(GLubyte));
+
for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++) {
_mesa_pixeltexgen(ctx, width, (const GLubyte (*)[4]) rgba,
s, t, r, q);
- gl_texture_pixels(ctx, unit, width, s, t, r, NULL, rgba);
+ gl_texture_pixels(ctx, unit, width, s, t, r, NULL,
+ primary_rgba, rgba);
}
}
diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c
index 417a76bf3e8..bdf247fecf9 100644
--- a/src/mesa/main/enums.c
+++ b/src/mesa/main/enums.c
@@ -1,4 +1,4 @@
-/* $Id: enums.c,v 1.8 2000/03/28 16:59:39 rjfrank Exp $ */
+/* $Id: enums.c,v 1.9 2000/06/27 21:42:13 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -805,7 +805,30 @@ enum_elt all_enums[] =
{ "GL_ARRAY_ELEMENT_LOCK_COUNT_EXT", 0x81A9},
/* GL_EXT_clip_volume_hint */
- { "GL_CLIP_VOLUME_CLIPPING_HINT_EXT", 0x80F0}
+ { "GL_CLIP_VOLUME_CLIPPING_HINT_EXT", 0x80F0},
+
+ /* GL_EXT_texture_env_combine */
+ { "GL_COMBINE_EXT", 0x8570 },
+ { "GL_COMBINE_RGB_EXT", 0x8571 },
+ { "GL_COMBINE_ALPHA_EXT", 0x8572 },
+ { "GL_SOURCE0_RGB_EXT", 0x8580 },
+ { "GL_SOURCE1_RGB_EXT", 0x8581 },
+ { "GL_SOURCE2_RGB_EXT", 0x8582 },
+ { "GL_SOURCE0_ALPHA_EXT", 0x8588 },
+ { "GL_SOURCE1_ALPHA_EXT", 0x8589 },
+ { "GL_SOURCE2_ALPHA_EXT", 0x858A },
+ { "GL_OPERAND0_RGB_EXT", 0x8590 },
+ { "GL_OPERAND1_RGB_EXT", 0x8591 },
+ { "GL_OPERAND2_RGB_EXT", 0x8592 },
+ { "GL_OPERAND0_ALPHA_EXT", 0x8598 },
+ { "GL_OPERAND1_ALPHA_EXT", 0x8599 },
+ { "GL_OPERAND2_ALPHA_EXT", 0x859A },
+ { "GL_RGB_SCALE_EXT", 0x8573 },
+ { "GL_ADD_SIGNED_EXT", 0x8574 },
+ { "GL_INTERPOLATE_EXT", 0x8575 },
+ { "GL_CONSTANT_EXT", 0x8576 },
+ { "GL_PRIMARY_COLOR_EXT", 0x8577 },
+ { "GL_PREVIOUS_EXT", 0x8578 }
};
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 32af093bac1..5d4ad1bb9e4 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -1,4 +1,4 @@
-/* $Id: extensions.c,v 1.31 2000/06/08 22:47:24 brianp Exp $ */
+/* $Id: extensions.c,v 1.32 2000/06/27 21:42:13 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -75,6 +75,7 @@ static struct { int enabled; const char *name; } default_extensions[] = {
{ DEFAULT_OFF, "GL_EXT_texture_compression_s3tc" },
{ DEFAULT_OFF, "GL_EXT_texture_env" },
{ DEFAULT_ON, "GL_EXT_texture_env_add" },
+ { DEFAULT_OFF, "GL_EXT_texture_env_combine" },
{ ALWAYS_ENABLED, "GL_EXT_texture_object" },
{ DEFAULT_ON, "GL_EXT_texture_lod_bias" },
{ ALWAYS_ENABLED, "GL_EXT_vertex_array" },
@@ -103,6 +104,7 @@ update_extension_flags( GLcontext *ctx )
{
/* Update flags */
ctx->Extensions.HaveTextureEnvAdd = gl_extension_is_enabled(ctx, "GL_EXT_texture_env_add");
+ ctx->Extensions.HaveTextureEnvCombine = gl_extension_is_enabled(ctx, "GL_EXT_texture_env_combine");
ctx->Extensions.HaveTextureLodBias = gl_extension_is_enabled(ctx, "GL_EXT_texture_lod_bias");
ctx->Extensions.HaveHpOcclusionTest = gl_extension_is_enabled(ctx, "GL_HP_occlusion_test");
ctx->Extensions.HaveTextureCubeMap = gl_extension_is_enabled(ctx, "GL_ARB_texture_cube_map");
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 32ce6005630..64df9016dc9 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.13 2000/05/23 20:10:50 brianp Exp $ */
+/* $Id: texstate.c,v 1.14 2000/06/27 21:42:13 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -71,64 +71,287 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexEnv");
if (target==GL_TEXTURE_ENV) {
-
- if (pname==GL_TEXTURE_ENV_MODE) {
- GLenum mode = (GLenum) (GLint) *param;
- switch (mode) {
- case GL_ADD:
- if (!ctx->Extensions.HaveTextureEnvAdd) {
- gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(param)");
- return;
- }
- /* FALL-THROUGH */
- case GL_MODULATE:
- case GL_BLEND:
- case GL_DECAL:
- case GL_REPLACE:
- /* A small optimization for drivers */
- if (texUnit->EnvMode == mode)
- return;
-
- if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_TEXTURE))
- fprintf(stderr, "glTexEnv: old mode %s, new mode %s\n",
- gl_lookup_enum_by_nr(texUnit->EnvMode),
- gl_lookup_enum_by_nr(mode));
-
- texUnit->EnvMode = mode;
- ctx->NewState |= NEW_TEXTURE_ENV;
- break;
- default:
- gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
- return;
- }
- }
- else if (pname==GL_TEXTURE_ENV_COLOR) {
- texUnit->EnvColor[0] = CLAMP( param[0], 0.0F, 1.0F );
- texUnit->EnvColor[1] = CLAMP( param[1], 0.0F, 1.0F );
- texUnit->EnvColor[2] = CLAMP( param[2], 0.0F, 1.0F );
- texUnit->EnvColor[3] = CLAMP( param[3], 0.0F, 1.0F );
- }
- else {
- gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
- return;
+ switch (pname) {
+ case GL_TEXTURE_ENV_MODE:
+ {
+ GLenum mode = (GLenum) (GLint) *param;
+ switch (mode) {
+ case GL_MODULATE:
+ case GL_BLEND:
+ case GL_DECAL:
+ case GL_REPLACE:
+ case GL_ADD:
+ case GL_COMBINE_EXT:
+ if (mode == GL_ADD &&
+ !ctx->Extensions.HaveTextureEnvAdd) {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(param)");
+ return;
+ }
+ if (mode == GL_COMBINE_EXT &&
+ !ctx->Extensions.HaveTextureEnvCombine) {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(param)");
+ return;
+ }
+ if (texUnit->EnvMode == mode)
+ return; /* no change */
+ texUnit->EnvMode = mode;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
+ return;
+ }
+ }
+ break;
+ case GL_TEXTURE_ENV_COLOR:
+ texUnit->EnvColor[0] = CLAMP( param[0], 0.0F, 1.0F );
+ texUnit->EnvColor[1] = CLAMP( param[1], 0.0F, 1.0F );
+ texUnit->EnvColor[2] = CLAMP( param[2], 0.0F, 1.0F );
+ texUnit->EnvColor[3] = CLAMP( param[3], 0.0F, 1.0F );
+ break;
+ case GL_COMBINE_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ GLenum mode = (GLenum) (GLint) *param;
+ switch (mode) {
+ case GL_REPLACE:
+ case GL_MODULATE:
+ case GL_ADD:
+ case GL_ADD_SIGNED_EXT:
+ case GL_INTERPOLATE_EXT:
+ if (texUnit->CombineModeRGB == mode)
+ return; /* no change */
+ texUnit->CombineModeRGB = mode;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_COMBINE_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ GLenum mode = (GLenum) (GLint) *param;
+ switch (mode) {
+ case GL_REPLACE:
+ case GL_MODULATE:
+ case GL_ADD:
+ case GL_ADD_SIGNED_EXT:
+ case GL_INTERPOLATE_EXT:
+ if (texUnit->CombineModeA == mode)
+ return; /* no change */
+ texUnit->CombineModeA = mode;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_SOURCE0_RGB_EXT:
+ case GL_SOURCE1_RGB_EXT:
+ case GL_SOURCE2_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ GLenum source = (GLenum) (GLint) *param;
+ GLuint s = pname - GL_SOURCE0_RGB_EXT;
+ switch (source) {
+ case GL_TEXTURE:
+ case GL_CONSTANT_EXT:
+ case GL_PRIMARY_COLOR_EXT:
+ case GL_PREVIOUS_EXT:
+ if (texUnit->CombineSourceRGB[s] == source)
+ return; /* no change */
+ texUnit->CombineSourceRGB[s] = source;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_SOURCE0_ALPHA_EXT:
+ case GL_SOURCE1_ALPHA_EXT:
+ case GL_SOURCE2_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ GLenum source = (GLenum) (GLint) *param;
+ GLuint s = pname - GL_SOURCE0_ALPHA_EXT;
+ switch (source) {
+ case GL_TEXTURE:
+ case GL_CONSTANT_EXT:
+ case GL_PRIMARY_COLOR_EXT:
+ case GL_PREVIOUS_EXT:
+ if (texUnit->CombineSourceA[s] == source) return;
+ texUnit->CombineSourceA[s] = source;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_OPERAND0_RGB_EXT:
+ case GL_OPERAND1_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ GLenum operand = (GLenum) (GLint) *param;
+ GLuint s = pname - GL_OPERAND0_RGB_EXT;
+ switch (operand) {
+ case GL_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_COLOR:
+ texUnit->CombineOperandRGB[s] = operand;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ break;
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ texUnit->CombineOperandA[s] = operand;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_OPERAND0_ALPHA_EXT:
+ case GL_OPERAND1_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ GLenum operand = (GLenum) (GLint) *param;
+ switch (operand) {
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ texUnit->CombineOperandA[pname-GL_OPERAND0_ALPHA_EXT]
+ = operand;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_OPERAND2_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ if ((GLenum) (GLint) *param == GL_SRC_ALPHA) {
+ texUnit->CombineOperandRGB[2] = (GLenum) (GLint) *param;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_OPERAND2_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ if ((GLenum) (GLint) *param == GL_SRC_ALPHA) {
+ texUnit->CombineOperandA[2] = (GLenum) (GLint) *param;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_RGB_SCALE_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ if (*param == 1.0) {
+ texUnit->CombineScaleShiftRGB = 0;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else if (*param == 2.0) {
+ texUnit->CombineScaleShiftRGB = 1;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else if (*param == 4.0) {
+ texUnit->CombineScaleShiftRGB = 2;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else {
+ gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ case GL_ALPHA_SCALE:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ if (*param == 1.0) {
+ texUnit->CombineScaleShiftA = 0;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else if (*param == 2.0) {
+ texUnit->CombineScaleShiftA = 1;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else if (*param == 4.0) {
+ texUnit->CombineScaleShiftA = 2;
+ ctx->NewState |= NEW_TEXTURE_ENV;
+ }
+ else {
+ gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
+ return;
+ }
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(pname)");
+ return;
+ }
+ break;
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
+ return;
}
-
}
else if (target==GL_TEXTURE_FILTER_CONTROL_EXT) {
-
if (!ctx->Extensions.HaveTextureLodBias) {
gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
return;
}
-
- if (pname==GL_TEXTURE_LOD_BIAS_EXT) {
+ if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
texUnit->LodBias = param[0];
}
else {
gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
return;
}
-
}
else {
gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(target)" );
@@ -184,7 +407,7 @@ void
_mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexEnvfv");
@@ -192,6 +415,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" );
return;
}
+
switch (pname) {
case GL_TEXTURE_ENV_MODE:
*params = ENUM_TO_FLOAT(texUnit->EnvMode);
@@ -199,6 +423,34 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_TEXTURE_ENV_COLOR:
COPY_4FV( params, texUnit->EnvColor );
break;
+ case GL_RGB_SCALE_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ if (texUnit->CombineScaleShiftRGB == 0)
+ *params = 1.0;
+ else if (texUnit->CombineScaleShiftRGB == 1)
+ *params = 2.0;
+ else
+ *params = 4.0;
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ return;
+ }
+ break;
+ case GL_ALPHA_SCALE:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ if (texUnit->CombineScaleShiftA == 0)
+ *params = 1.0;
+ else if (texUnit->CombineScaleShiftA == 1)
+ *params = 2.0;
+ else
+ *params = 4.0;
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ return;
+ }
+ break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" );
}
@@ -209,14 +461,15 @@ void
_mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexEnviv");
- if (target!=GL_TEXTURE_ENV) {
+ if (target != GL_TEXTURE_ENV) {
gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" );
return;
}
+
switch (pname) {
case GL_TEXTURE_ENV_MODE:
*params = (GLint) texUnit->EnvMode;
@@ -226,6 +479,118 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] );
params[2] = FLOAT_TO_INT( texUnit->EnvColor[2] );
params[3] = FLOAT_TO_INT( texUnit->EnvColor[3] );
+ break;
+ case GL_COMBINE_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineModeRGB;
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_COMBINE_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineModeA;
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE0_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineSourceRGB[0];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE1_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineSourceRGB[1];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE2_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineSourceRGB[2];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE0_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineSourceA[0];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE1_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineSourceA[1];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE2_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineSourceA[2];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND0_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineOperandRGB[0];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND1_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineOperandRGB[1];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND2_RGB_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineOperandRGB[2];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND0_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineOperandA[0];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND1_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineOperandA[1];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND2_ALPHA_EXT:
+ if (ctx->Extensions.HaveTextureEnvCombine) {
+ *params = (GLint) texUnit->CombineOperandA[2];
+ }
+ else {
+ gl_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" );