From d24702795465f4a24b069354446da76cd54840ac Mon Sep 17 00:00:00 2001 From: Ragnvald Maartmann-Moe IV Date: Sun, 23 Sep 2001 03:24:23 +0000 Subject: [PATCH] Use a callback for gl_multitexture which sets gl_mtex_active (now a qboolean, rather than a macro). 0.6-1.0% speedup. --- include/QF/GL/qf_vid.h | 8 +++----- libs/video/targets/vid_common_gl.c | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/QF/GL/qf_vid.h b/include/QF/GL/qf_vid.h index a8cd5e03e..9c909c6d5 100644 --- a/include/QF/GL/qf_vid.h +++ b/include/QF/GL/qf_vid.h @@ -44,13 +44,11 @@ // Multitexturing extern QF_glActiveTextureARB qglActiveTexture; extern QF_glMultiTexCoord2fARB qglMultiTexCoord2f; +extern qboolean gl_mtex_active; extern qboolean gl_mtex_capable; extern GLenum gl_mtex_enum; -// convenience check -#define gl_mtex_active (gl_mtex_capable && gl_multitexture->int_val) - -extern int texture_extension_number; -extern float gldepthmin, gldepthmax; +extern float gldepthmin, gldepthmax; +extern int texture_extension_number; void GL_EndRendering (void); void GL_BeginRendering (int *x, int *y, int *width, int *height); diff --git a/libs/video/targets/vid_common_gl.c b/libs/video/targets/vid_common_gl.c index c24d15838..f160bb3e9 100644 --- a/libs/video/targets/vid_common_gl.c +++ b/libs/video/targets/vid_common_gl.c @@ -81,6 +81,7 @@ const char *gl_version; const char *gl_extensions; // ARB Multitexture +qboolean gl_mtex_active = false; qboolean gl_mtex_capable = false; GLenum gl_mtex_enum = GL_TEXTURE0_ARB; @@ -93,13 +94,21 @@ extern byte gammatable[256]; extern qboolean GLF_Init (); +static void +gl_multitexture_f (cvar_t *var) +{ + if (var) + gl_mtex_active = gl_mtex_capable && var->int_val; +} + void GL_Common_Init_Cvars (void) { vid_use8bit = Cvar_Get ("vid_use8bit", "0", CVAR_ROM, NULL, "Use 8-bit " "shared palettes."); - gl_multitexture = Cvar_Get ("gl_multitexture", "0", CVAR_ARCHIVE, NULL, - "Use multitexture when available"); + gl_multitexture = Cvar_Get ("gl_multitexture", "0", CVAR_ARCHIVE, + gl_multitexture_f, "Use multitexture when " + "available"); } /* @@ -223,8 +232,6 @@ VID_SetPalette (unsigned char *palette) void GL_Init_Common (void) { - GL_Common_Init_Cvars (); - if (!GLF_Init()) { Sys_Error("Can't init video.\n"); return; @@ -262,6 +269,7 @@ GL_Init_Common (void) qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); CheckMultiTextureExtensions (); + GL_Common_Init_Cvars (); } void