/* * R_SelectTexture */ void R_SelectTexture(r_texunit_t *texunit) { if (texunit == r_state.active_texunit) return; r_state.active_texunit = texunit; qglActiveTexture(texunit->texture); qglClientActiveTexture(texunit->texture); }
/** * @brief Dumps OpenGL state for debugging - typically every capability set with glEnable(). */ void R_DumpOpenGlState (void) { #define CAPABILITY( X ) {GL_ ## X, # X} /* List taken from here: http://www.khronos.org/opengles/sdk/1.1/docs/man/glIsEnabled.xml */ const struct { GLenum idx; const char * text; } openGLCaps[] = { CAPABILITY(ALPHA_TEST), CAPABILITY(BLEND), CAPABILITY(COLOR_ARRAY), CAPABILITY(COLOR_LOGIC_OP), CAPABILITY(COLOR_MATERIAL), CAPABILITY(CULL_FACE), CAPABILITY(DEPTH_TEST), CAPABILITY(DITHER), CAPABILITY(FOG), CAPABILITY(LIGHTING), CAPABILITY(LINE_SMOOTH), CAPABILITY(MULTISAMPLE), CAPABILITY(NORMAL_ARRAY), CAPABILITY(NORMALIZE), CAPABILITY(POINT_SMOOTH), CAPABILITY(POLYGON_OFFSET_FILL), CAPABILITY(RESCALE_NORMAL), CAPABILITY(SAMPLE_ALPHA_TO_COVERAGE), CAPABILITY(SAMPLE_ALPHA_TO_ONE), CAPABILITY(SAMPLE_COVERAGE), CAPABILITY(SCISSOR_TEST), CAPABILITY(STENCIL_TEST), CAPABILITY(VERTEX_ARRAY) }; #undef CAPABILITY char s[1024] = ""; GLint i; GLint maxTexUnits = 0; GLint activeTexUnit = 0; GLint activeClientTexUnit = 0; GLint activeTexId = 0; GLfloat texEnvMode = 0; const char * texEnvModeStr = "UNKNOWN"; GLfloat color[4]; for (int i = 0; i < lengthof(openGLCaps); i++) { if (glIsEnabled(openGLCaps[i].idx)) { Q_strcat(s, openGLCaps[i].text, sizeof(s)); Q_strcat(s, " ", sizeof(s)); } } glGetFloatv(GL_CURRENT_COLOR, color); Com_Printf("OpenGL enabled caps: %s color %f %f %f %f \n", s, color[0], color[1], color[2], color[3]); glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTexUnit); glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &activeClientTexUnit); glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTexUnits); for (i = GL_TEXTURE0; i < GL_TEXTURE0 + maxTexUnits; i++) { qglActiveTexture(i); qglClientActiveTexture(i); strcpy(s, ""); if (glIsEnabled (GL_TEXTURE_2D)) strcat(s, "enabled, "); if (glIsEnabled (GL_TEXTURE_COORD_ARRAY)) strcat(s, "with texcoord array, "); if (i == activeTexUnit) strcat(s, "active, "); if (i == activeClientTexUnit) strcat(s, "client active, "); glGetIntegerv(GL_TEXTURE_BINDING_2D, &activeTexId); glGetTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &texEnvMode); if (fabs(texEnvMode - GL_ADD) < 0.1f) texEnvModeStr = "ADD"; if (fabs(texEnvMode - GL_MODULATE) < 0.1f) texEnvModeStr = "MODULATE"; if (fabs(texEnvMode - GL_DECAL) < 0.1f) texEnvModeStr = "DECAL"; if (fabs(texEnvMode - GL_BLEND) < 0.1f) texEnvModeStr = "BLEND"; if (fabs(texEnvMode - GL_REPLACE) < 0.1f) texEnvModeStr = "REPLACE"; if (fabs(texEnvMode - GL_COMBINE) < 0.1f) texEnvModeStr = "COMBINE"; Com_Printf("Texunit: %d texID %d %s texEnv mode %s\n", i - GL_TEXTURE0, activeTexId, s, texEnvModeStr); } qglActiveTexture(activeTexUnit); qglClientActiveTexture(activeClientTexUnit); }