|
|
@@ -1,4 +1,4 @@ |
|
|
|
/* $Id: texstate.c,v 1.43 2001/04/16 21:06:54 brianp Exp $ */ |
|
|
|
/* $Id: texstate.c,v 1.44 2001/04/17 21:25:53 brianp Exp $ */ |
|
|
|
|
|
|
|
/* |
|
|
|
* Mesa 3-D graphics library |
|
|
@@ -68,6 +68,10 @@ |
|
|
|
#define GL_CLAMP_TO_BORDER_ARB 0x812D |
|
|
|
#endif |
|
|
|
|
|
|
|
#ifndef GL_SUBTRACT_ARB |
|
|
|
#define GL_SUBTRACT_ARB 0x84E7 |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/ |
|
|
|
/* Texture Environment */ |
|
|
@@ -101,7 +105,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_COMBINE_EXT: |
|
|
|
if (!ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (!ctx->Extensions.EXT_texture_env_combine && |
|
|
|
!ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); |
|
|
|
return; |
|
|
|
} |
|
|
@@ -135,20 +140,33 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) |
|
|
|
break; |
|
|
|
} |
|
|
|
case GL_COMBINE_RGB_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
GLenum mode = (GLenum) (GLint) *param; |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
const 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: |
|
|
|
/* OK */ |
|
|
|
break; |
|
|
|
case GL_SUBTRACT_ARB: |
|
|
|
if (!ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); |
|
|
|
return; |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_DOT3_RGB_EXT: |
|
|
|
case GL_DOT3_RGBA_EXT: |
|
|
|
if (!ctx->Extensions.EXT_texture_env_dot3) { |
|
|
|
ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); |
|
|
|
return; |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_DOT3_RGB_ARB: |
|
|
|
case GL_DOT3_RGBA_ARB: |
|
|
|
if (!ctx->Extensions.EXT_texture_env_dot3) { |
|
|
|
if (!ctx->Extensions.ARB_texture_env_dot3) { |
|
|
|
ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); |
|
|
|
return; |
|
|
|
} |
|
|
@@ -168,23 +186,31 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_COMBINE_ALPHA_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
GLenum mode = (GLenum) (GLint) *param; |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
const 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; |
|
|
|
FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
|
|
|
texUnit->CombineModeA = mode; |
|
|
|
/* OK */ |
|
|
|
break; |
|
|
|
case GL_SUBTRACT_ARB: |
|
|
|
if (!ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); |
|
|
|
return; |
|
|
|
} |
|
|
|
break; |
|
|
|
default: |
|
|
|
ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (texUnit->CombineModeA == mode) |
|
|
|
return; |
|
|
|
FLUSH_VERTICES(ctx, _NEW_TEXTURE); |
|
|
|
texUnit->CombineModeA = mode; |
|
|
|
} |
|
|
|
else { |
|
|
|
ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname); |
|
|
@@ -194,7 +220,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) |
|
|
|
case GL_SOURCE0_RGB_EXT: |
|
|
|
case GL_SOURCE1_RGB_EXT: |
|
|
|
case GL_SOURCE2_RGB_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
GLenum source = (GLenum) (GLint) *param; |
|
|
|
GLuint s = pname - GL_SOURCE0_RGB_EXT; |
|
|
|
switch (source) { |
|
|
@@ -220,7 +247,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) |
|
|
|
case GL_SOURCE0_ALPHA_EXT: |
|
|
|
case GL_SOURCE1_ALPHA_EXT: |
|
|
|
case GL_SOURCE2_ALPHA_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
GLenum source = (GLenum) (GLint) *param; |
|
|
|
GLuint s = pname - GL_SOURCE0_ALPHA_EXT; |
|
|
|
switch (source) { |
|
|
@@ -244,7 +272,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) |
|
|
|
break; |
|
|
|
case GL_OPERAND0_RGB_EXT: |
|
|
|
case GL_OPERAND1_RGB_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
GLenum operand = (GLenum) (GLint) *param; |
|
|
|
GLuint s = pname - GL_OPERAND0_RGB_EXT; |
|
|
|
switch (operand) { |
|
|
@@ -269,7 +298,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) |
|
|
|
break; |
|
|
|
case GL_OPERAND0_ALPHA_EXT: |
|
|
|
case GL_OPERAND1_ALPHA_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
GLenum operand = (GLenum) (GLint) *param; |
|
|
|
switch (operand) { |
|
|
|
case GL_SRC_ALPHA: |
|
|
@@ -291,7 +321,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_OPERAND2_RGB_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
GLenum operand = (GLenum) (GLint) *param; |
|
|
|
switch (operand) { |
|
|
|
case GL_SRC_COLOR: /* ARB combine only */ |
|
|
@@ -313,7 +344,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_OPERAND2_ALPHA_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
GLenum operand = (GLenum) (GLint) *param; |
|
|
|
switch (operand) { |
|
|
|
case GL_SRC_ALPHA: |
|
|
@@ -334,7 +366,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_RGB_SCALE_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
GLuint newshift; |
|
|
|
if (*param == 1.0) { |
|
|
|
newshift = 0; |
|
|
@@ -361,7 +394,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_ALPHA_SCALE: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
GLuint newshift; |
|
|
|
if (*param == 1.0) { |
|
|
|
newshift = 0; |
|
|
@@ -478,7 +512,8 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) |
|
|
|
COPY_4FV( params, texUnit->EnvColor ); |
|
|
|
break; |
|
|
|
case GL_RGB_SCALE_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
if (texUnit->CombineScaleShiftRGB == 0) |
|
|
|
*params = 1.0; |
|
|
|
else if (texUnit->CombineScaleShiftRGB == 1) |
|
|
@@ -492,7 +527,8 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_ALPHA_SCALE: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
if (texUnit->CombineScaleShiftA == 0) |
|
|
|
*params = 1.0; |
|
|
|
else if (texUnit->CombineScaleShiftA == 1) |
|
|
@@ -534,7 +570,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) |
|
|
|
params[3] = FLOAT_TO_INT( texUnit->EnvColor[3] ); |
|
|
|
break; |
|
|
|
case GL_COMBINE_RGB_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
*params = (GLint) texUnit->CombineModeRGB; |
|
|
|
} |
|
|
|
else { |
|
|
@@ -542,7 +579,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_COMBINE_ALPHA_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
*params = (GLint) texUnit->CombineModeA; |
|
|
|
} |
|
|
|
else { |
|
|
@@ -550,7 +588,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_SOURCE0_RGB_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
*params = (GLint) texUnit->CombineSourceRGB[0]; |
|
|
|
} |
|
|
|
else { |
|
|
@@ -558,7 +597,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_SOURCE1_RGB_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
*params = (GLint) texUnit->CombineSourceRGB[1]; |
|
|
|
} |
|
|
|
else { |
|
|
@@ -566,7 +606,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_SOURCE2_RGB_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
*params = (GLint) texUnit->CombineSourceRGB[2]; |
|
|
|
} |
|
|
|
else { |
|
|
@@ -574,7 +615,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_SOURCE0_ALPHA_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
*params = (GLint) texUnit->CombineSourceA[0]; |
|
|
|
} |
|
|
|
else { |
|
|
@@ -582,7 +624,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_SOURCE1_ALPHA_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
*params = (GLint) texUnit->CombineSourceA[1]; |
|
|
|
} |
|
|
|
else { |
|
|
@@ -590,7 +633,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_SOURCE2_ALPHA_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
*params = (GLint) texUnit->CombineSourceA[2]; |
|
|
|
} |
|
|
|
else { |
|
|
@@ -598,7 +642,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_OPERAND0_RGB_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
*params = (GLint) texUnit->CombineOperandRGB[0]; |
|
|
|
} |
|
|
|
else { |
|
|
@@ -606,7 +651,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_OPERAND1_RGB_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
*params = (GLint) texUnit->CombineOperandRGB[1]; |
|
|
|
} |
|
|
|
else { |
|
|
@@ -614,7 +660,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_OPERAND2_RGB_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
*params = (GLint) texUnit->CombineOperandRGB[2]; |
|
|
|
} |
|
|
|
else { |
|
|
@@ -622,7 +669,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_OPERAND0_ALPHA_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
*params = (GLint) texUnit->CombineOperandA[0]; |
|
|
|
} |
|
|
|
else { |
|
|
@@ -630,7 +678,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_OPERAND1_ALPHA_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
*params = (GLint) texUnit->CombineOperandA[1]; |
|
|
|
} |
|
|
|
else { |
|
|
@@ -638,7 +687,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params ) |
|
|
|
} |
|
|
|
break; |
|
|
|
case GL_OPERAND2_ALPHA_EXT: |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine) { |
|
|
|
if (ctx->Extensions.EXT_texture_env_combine || |
|
|
|
ctx->Extensions.ARB_texture_env_combine) { |
|
|
|
*params = (GLint) texUnit->CombineOperandA[2]; |
|
|
|
} |
|
|
|
else { |