diff options
author | Yuanhan Liu <[email protected]> | 2011-09-20 13:32:50 +0800 |
---|---|---|
committer | Brian Paul <[email protected]> | 2011-09-20 08:05:34 -0600 |
commit | a11b4c1e7aa0958e6128bbfae2173e289b2cce8f (patch) | |
tree | a7cb52729b66958ab3f90c5473bdc57b385a5c12 | |
parent | a5f8d37be141fac5c4ac605163a552ac64324e15 (diff) |
mesa: fix error handling for glMaterial*
Trigger GL_INVALID_ENUM error if the face paramter is not a valid value.
Trigger GL_INVALID_VALUE error if the GL_SHININESS value is out side
[0, ctx->Constant.MaxShiniess].
v2: fix the max shininess value.
v3: suggested by Brian, move the face check into glMaterialfv function
to reduce code duplicate. Also, refactor the error message.
Signed-off-by: Yuanhan Liu <[email protected]>
Signed-off-by: Brian Paul <[email protected]>
-rw-r--r-- | src/mesa/vbo/vbo_attrib_tmp.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h index 65717eb456b..e1023834a93 100644 --- a/src/mesa/vbo/vbo_attrib_tmp.h +++ b/src/mesa/vbo/vbo_attrib_tmp.h @@ -809,6 +809,12 @@ TAG(Materialfv)(GLenum face, GLenum pname, const GLfloat * params) { GET_CURRENT_CONTEXT(ctx); + + if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) { + _mesa_error(ctx, GL_INVALID_ENUM, "glMaterial(invalid face)"); + return; + } + switch (pname) { case GL_EMISSION: MAT(VBO_ATTRIB_MAT_FRONT_EMISSION, 4, face, params); @@ -823,7 +829,12 @@ TAG(Materialfv)(GLenum face, GLenum pname, MAT(VBO_ATTRIB_MAT_FRONT_SPECULAR, 4, face, params); break; case GL_SHININESS: - MAT(VBO_ATTRIB_MAT_FRONT_SHININESS, 1, face, params); + if (*params < 0 || *params > ctx->Const.MaxShininess) + _mesa_error(ctx, GL_INVALID_VALUE, + "glMaterial(invalid shininess: %f out range [0, %f])", + *params, ctx->Const.MaxShininess); + else + MAT(VBO_ATTRIB_MAT_FRONT_SHININESS, 1, face, params); break; case GL_COLOR_INDEXES: MAT(VBO_ATTRIB_MAT_FRONT_INDEXES, 3, face, params); |