(mode == GL_MODELVIEW1_ARB) ? 3 + NB_MAX_TEXTURES : \
(mode >= GL_MODELVIEW2_ARB && mode <= GL_MODELVIEW31_ARB) ? 4 + NB_MAX_TEXTURES + mode - GL_MODELVIEW2_ARB : -1)
-static int maxTextureSize = -1; /* optimization for ppracer */
-static int maxTextureUnits = -1;
+#define MAXIMUM_VALUE_DECL(val) static int max_##val = -1;
+#define MAXIMUM_VALUE_CASE(val) case val:\
+ if (max_##val == -1) max_##val = _glGetIntegerv(pname); *params = max_##val;\
+ if (debug_gl) fprintf(stderr, "returning %d for %s\n", max_##val, #val);\
+ break;
+
+MAXIMUM_VALUE_DECL(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB);
+MAXIMUM_VALUE_DECL(GL_MAX_TEXTURE_SIZE);
+MAXIMUM_VALUE_DECL(GL_MAX_TEXTURE_UNITS_ARB);
static int _glGetIntegerv(GLenum pname)
{
} \
case GL_ARRAY_BUFFER_BINDING: *params = state->arrayBuffer; break; \
case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: *params = state->elementArrayBuffer; break; \
- case GL_MAX_TEXTURE_SIZE: if (maxTextureSize == -1) maxTextureSize = _glGetIntegerv(pname); *params = maxTextureSize; break; \
- case GL_MAX_TEXTURE_UNITS_ARB: if (maxTextureUnits == -1) maxTextureUnits = _glGetIntegerv(pname); *params = maxTextureUnits; break; \
+ MAXIMUM_VALUE_CASE(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB);\
+ MAXIMUM_VALUE_CASE(GL_MAX_TEXTURE_SIZE);\
+ MAXIMUM_VALUE_CASE(GL_MAX_TEXTURE_UNITS_ARB);\
case GL_MODELVIEW_MATRIX: \
case GL_PROJECTION_MATRIX: \
case GL_TEXTURE_MATRIX: AFFECT_N(params, state->matrix[pname - GL_MODELVIEW_MATRIX].current.val, 16); break; \