summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/enable.c
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2011-09-25 11:55:41 -0700
committerPaul Berry <[email protected]>2011-09-27 10:36:38 -0700
commitb565e62a4499aad445bdbc0ba3a8bbc1c61e68ab (patch)
tree4d9950bae6334679b510e59a44bb905b723d1a47 /src/mesa/main/enable.c
parent4c84fbea9d496567d706468113d63cd8f0faeb7f (diff)
mesa: Make enable.c and get.c properly range check clip flags.
This is a follow-up to commit 2d686fe911a89fa477ee3848da41ebfb100500bf, which added decoding of GL_CLIP_DISTANCE[67] to the _mesa_set_enable() function. This patch makes the following additional fixes: - Uses GL_CLIP_DISTANCEi enums consistently within enable.c rather than the deprecated GL_CLIP_PLANEi enums. - Generates an error if the user tries to access a clip flag that is unsupported by the hardware. - Applies the same change to _mesa_IsEnabled(), so that querying clip flags using glIsEnabled() works properly. - Applies corresponding changes to get.c, so that querying clip flags using glGet*() works properly. Fixes piglit test clip-flag-behavior. Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main/enable.c')
-rw-r--r--src/mesa/main/enable.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 23b6a948055..689dc8a99ec 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -304,7 +304,10 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
case GL_CLIP_DISTANCE6:
case GL_CLIP_DISTANCE7:
{
- const GLuint p = cap - GL_CLIP_PLANE0;
+ const GLuint p = cap - GL_CLIP_DISTANCE0;
+
+ if (p >= ctx->Const.MaxClipPlanes)
+ goto invalid_enum_error;
if ((ctx->Transform.ClipPlanesEnabled & (1 << p))
== ((GLuint) state << p))
@@ -1084,13 +1087,21 @@ _mesa_IsEnabled( GLenum cap )
return ctx->Eval.AutoNormal;
case GL_BLEND:
return ctx->Color.BlendEnabled & 1; /* return state for buffer[0] */
- case GL_CLIP_PLANE0:
- case GL_CLIP_PLANE1:
- case GL_CLIP_PLANE2:
- case GL_CLIP_PLANE3:
- case GL_CLIP_PLANE4:
- case GL_CLIP_PLANE5:
- return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1;
+ case GL_CLIP_DISTANCE0:
+ case GL_CLIP_DISTANCE1:
+ case GL_CLIP_DISTANCE2:
+ case GL_CLIP_DISTANCE3:
+ case GL_CLIP_DISTANCE4:
+ case GL_CLIP_DISTANCE5:
+ case GL_CLIP_DISTANCE6:
+ case GL_CLIP_DISTANCE7: {
+ const GLuint p = cap - GL_CLIP_DISTANCE0;
+
+ if (p >= ctx->Const.MaxClipPlanes)
+ goto invalid_enum_error;
+
+ return (ctx->Transform.ClipPlanesEnabled >> p) & 1;
+ }
case GL_COLOR_MATERIAL:
return ctx->Light.ColorMaterialEnabled;
case GL_CULL_FACE: