summaryrefslogtreecommitdiff
path: root/src/mesa/main/enable.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-01-02 16:32:26 -0700
committerBrian Paul <brianp@vmware.com>2009-01-02 16:32:26 -0700
commit0815ebccfc0a12d8f3e831928f1c4210b7f75ad8 (patch)
tree1e7db7e1d44e741215e5b4b11d33df91fe5b39a0 /src/mesa/main/enable.c
parenteb9bbc5265562cb6f93688fc027ea76f91601e37 (diff)
parent1fad6ccb756ae33ca3115f59c99ca8abbeb0321e (diff)
Merge commit 'origin/master' into gallium-0.2
Conflicts: src/mesa/main/ffvertex_prog.c src/mesa/main/texenvprogram.c
Diffstat (limited to 'src/mesa/main/enable.c')
-rw-r--r--src/mesa/main/enable.c148
1 files changed, 92 insertions, 56 deletions
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 248df1badc..72ed50808c 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -201,6 +201,26 @@ _mesa_DisableClientState( GLenum cap )
}
+
+/**
+ * Return pointer to current texture unit for setting/getting coordinate
+ * state.
+ * Note that we'll set GL_INVALID_OPERATION if the active texture unit is
+ * higher than the number of supported coordinate units. And we'll return NULL.
+ */
+static struct gl_texture_unit *
+get_texcoord_unit(GLcontext *ctx)
+{
+ if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glEnable/Disable(texcoord unit)");
+ return NULL;
+ }
+ else {
+ return &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ }
+}
+
+
/**
* Helper function to enable or disable a texture target.
*/
@@ -612,54 +632,62 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
return;
}
break;
- case GL_TEXTURE_GEN_Q: {
- GLuint unit = ctx->Texture.CurrentUnit;
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
- GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT;
- if (state)
- newenabled |= Q_BIT;
- if (texUnit->TexGenEnabled == newenabled)
- return;
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->TexGenEnabled = newenabled;
+ case GL_TEXTURE_GEN_Q:
+ {
+ struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+ if (texUnit) {
+ GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT;
+ if (state)
+ newenabled |= Q_BIT;
+ if (texUnit->TexGenEnabled == newenabled)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->TexGenEnabled = newenabled;
+ }
+ }
break;
- }
- case GL_TEXTURE_GEN_R: {
- GLuint unit = ctx->Texture.CurrentUnit;
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
- GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT;
- if (state)
- newenabled |= R_BIT;
- if (texUnit->TexGenEnabled == newenabled)
- return;
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->TexGenEnabled = newenabled;
+ case GL_TEXTURE_GEN_R:
+ {
+ struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+ if (texUnit) {
+ GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT;
+ if (state)
+ newenabled |= R_BIT;
+ if (texUnit->TexGenEnabled == newenabled)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->TexGenEnabled = newenabled;
+ }
+ }
break;
- }
- case GL_TEXTURE_GEN_S: {
- GLuint unit = ctx->Texture.CurrentUnit;
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
- GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT;
- if (state)
- newenabled |= S_BIT;
- if (texUnit->TexGenEnabled == newenabled)
- return;
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->TexGenEnabled = newenabled;
+ case GL_TEXTURE_GEN_S:
+ {
+ struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+ if (texUnit) {
+ GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT;
+ if (state)
+ newenabled |= S_BIT;
+ if (texUnit->TexGenEnabled == newenabled)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->TexGenEnabled = newenabled;
+ }
+ }
break;
- }
- case GL_TEXTURE_GEN_T: {
- GLuint unit = ctx->Texture.CurrentUnit;
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
- GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT;
- if (state)
- newenabled |= T_BIT;
- if (texUnit->TexGenEnabled == newenabled)
- return;
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->TexGenEnabled = newenabled;
+ case GL_TEXTURE_GEN_T:
+ {
+ struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+ if (texUnit) {
+ GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT;
+ if (state)
+ newenabled |= T_BIT;
+ if (texUnit->TexGenEnabled == newenabled)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->TexGenEnabled = newenabled;
+ }
+ }
break;
- }
/*
* CLIENT STATE!!!
@@ -1155,28 +1183,36 @@ _mesa_IsEnabled( GLenum cap )
return is_texture_enabled(ctx, TEXTURE_3D_BIT);
case GL_TEXTURE_GEN_Q:
{
- const struct gl_texture_unit *texUnit;
- texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
+ const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+ if (texUnit) {
+ return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
+ }
}
+ return GL_FALSE;
case GL_TEXTURE_GEN_R:
{
- const struct gl_texture_unit *texUnit;
- texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
+ const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+ if (texUnit) {
+ return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
+ }
}
+ return GL_FALSE;
case GL_TEXTURE_GEN_S:
{
- const struct gl_texture_unit *texUnit;
- texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
+ const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+ if (texUnit) {
+ return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
+ }
}
+ return GL_FALSE;
case GL_TEXTURE_GEN_T:
{
- const struct gl_texture_unit *texUnit;
- texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
+ const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+ if (texUnit) {
+ return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
+ }
}
+ return GL_FALSE;
/*
* CLIENT STATE!!!