diff options
author | Brian Paul <[email protected]> | 2012-05-08 11:41:03 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2012-05-11 16:13:14 -0600 |
commit | 1bc16bf98a1b5a4cca0c0ae2a80ba7982c6e4651 (patch) | |
tree | c66295b3f10537f9543ffea9afb08fef8eaddb92 /src/mesa/vbo/vbo_save_api.c | |
parent | f2724905469bbcde820b9ece2e4f44a610a75a65 (diff) |
mesa: fix glMaterial / dlist bug
When glColorMaterial() is used to latch glColor commands to a material
attribute, glMaterial calls to change that material should become no-ops.
This failed to work properly when the glMaterial call was inside a
display list.
This removes the Material function from the vbo_attrib_tmp.h template
file. We have separate/different implementations for the "save" and
"exec" cases now.
NOTE: This is a candidate for the 8.0 branch.
Diffstat (limited to 'src/mesa/vbo/vbo_save_api.c')
-rw-r--r-- | src/mesa/vbo/vbo_save_api.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index 74f5dc9ce68..f202375caa4 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -724,6 +724,63 @@ do { \ +#define MAT( ATTR, N, face, params ) \ +do { \ + if (face != GL_BACK) \ + MAT_ATTR( ATTR, N, params ); /* front */ \ + if (face != GL_FRONT) \ + MAT_ATTR( ATTR + 1, N, params ); /* back */ \ +} while (0) + + +/** + * Save a glMaterial call found between glBegin/End. + * glMaterial calls outside Begin/End are handled in dlist.c. + */ +static void GLAPIENTRY +_save_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_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(face)"); + return; + } + + switch (pname) { + case GL_EMISSION: + MAT(VBO_ATTRIB_MAT_FRONT_EMISSION, 4, face, params); + break; + case GL_AMBIENT: + MAT(VBO_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params); + break; + case GL_DIFFUSE: + MAT(VBO_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params); + break; + case GL_SPECULAR: + MAT(VBO_ATTRIB_MAT_FRONT_SPECULAR, 4, face, params); + break; + case GL_SHININESS: + if (*params < 0 || *params > ctx->Const.MaxShininess) { + _mesa_compile_error(ctx, GL_INVALID_VALUE, "glMaterial(shininess)"); + } + else { + MAT(VBO_ATTRIB_MAT_FRONT_SHININESS, 1, face, params); + } + break; + case GL_COLOR_INDEXES: + MAT(VBO_ATTRIB_MAT_FRONT_INDEXES, 3, face, params); + break; + case GL_AMBIENT_AND_DIFFUSE: + MAT(VBO_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params); + MAT(VBO_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params); + break; + default: + _mesa_compile_error(ctx, GL_INVALID_ENUM, "glMaterial(pname)"); + return; + } +} + /* Cope with EvalCoord/CallList called within a begin/end object: * -- Flush current buffer |