From fef9b30bd7602eff06d8b85737d6ca427719bc26 Mon Sep 17 00:00:00 2001 From: Ragnvald Maartmann-Moe IV Date: Sun, 15 Feb 2004 00:02:04 +0000 Subject: [PATCH] QF, now complete with underbrights, thanks to Grievre. Play with gl_overbright and gl_doublebright. That's an order. --- include/QF/GL/extensions.h | 40 ++++++ include/QF/GL/qf_vid.h | 1 + include/r_cvar.h | 4 + libs/video/renderer/gl/gl_lightmap.c | 195 ++++++++++++++++++++++---- libs/video/renderer/gl/gl_rsurf.c | 113 +++++++++------ libs/video/renderer/r_cvar.c | 5 + libs/video/renderer/sw/sw_rmain.c | 5 + libs/video/renderer/sw32/sw32_rmain.c | 5 + libs/video/targets/vid_common_gl.c | 31 ++++ 9 files changed, 330 insertions(+), 69 deletions(-) diff --git a/include/QF/GL/extensions.h b/include/QF/GL/extensions.h index 5f8eb80ce..8e8a4ec07 100644 --- a/include/QF/GL/extensions.h +++ b/include/QF/GL/extensions.h @@ -145,6 +145,46 @@ # define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C #endif +#ifndef GL_ARB_texture_env_combine +# define GL_ARB_texture_env_combine +# define GL_COMBINE_ARB 0x8570 +# define GL_COMBINE_RGB_ARB 0x8571 +# define GL_COMBINE_ALPHA_ARB 0x8572 +# define GL_RGB_SCALE_ARB 0x8573 +# define GL_SOURCE0_RGB_ARB 0x8580 +# define GL_SOURCE1_RGB_ARB 0x8581 +# define GL_SOURCE2_RGB_ARB 0x8582 +# define GL_SOURCE0_ALPHA_ARB 0x8588 +# define GL_SOURCE1_ALPHA_ARB 0x8589 +# define GL_SOURCE2_ALPHA_ARB 0x858A +# define GL_OPERAND0_RGB_ARB 0x8590 +# define GL_OPERAND1_RGB_ARB 0x8591 +# define GL_OPERAND2_RGB_ARB 0x8592 +# define GL_OPERAND0_ALPHA_ARB 0x8598 +# define GL_OPERAND1_ALPHA_ARB 0x8599 +# define GL_OPERAND2_ALPHA_ARB 0x859A +# define GL_RGB_SCALE_ARB 0x8573 +# define GL_ADD_SIGNED_ARB 0x8574 +# define GL_INTERPOLATE_ARB 0x8575 +# define GL_SUBTRACT_ARB 0x84E7 +# define GL_CONSTANT_ARB 0x8576 +# define GL_PRIMARY_COLOR_ARB 0x8577 +# define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_dot3 +# define GL_DOT3_RGB_ARB 0x86AE +# define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_depth_texture +# define GL_DEPTH_COMPONENT16_ARB 0x81A5 +# define GL_DEPTH_COMPONENT24_ARB 0x81A6 +# define GL_DEPTH_COMPONENT32_ARB 0x81A7 +# define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +# define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + /* Standard OpenGL external function defs */ typedef void (GLAPIENTRY *QF_glBlendColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); typedef void (GLAPIENTRY *QF_glBlendEquation) (GLenum mode); diff --git a/include/QF/GL/qf_vid.h b/include/QF/GL/qf_vid.h index 2fd934e94..3bcde65c7 100644 --- a/include/QF/GL/qf_vid.h +++ b/include/QF/GL/qf_vid.h @@ -45,6 +45,7 @@ extern float gldepthmin, gldepthmax; extern int texture_extension_number; extern int tess; extern qboolean gl_feature_mach64; +extern qboolean gl_combine_capable; void GL_EndRendering (void); void GL_BeginRendering (int *x, int *y, int *width, int *height); diff --git a/include/r_cvar.h b/include/r_cvar.h index 0c9c2e661..aefa08c6f 100644 --- a/include/r_cvar.h +++ b/include/r_cvar.h @@ -2,6 +2,8 @@ extern struct cvar_s *easter_eggs; extern void r_easter_eggs_f (cvar_t *var); extern void r_particles_style_f (cvar_t *var); +extern void gl_overbright_f (cvar_t *cvar); + extern struct cvar_s *cl_crossx; extern struct cvar_s *cl_crossy; extern struct cvar_s *cl_verstring; @@ -17,6 +19,7 @@ extern struct cvar_s *gl_conspin; extern struct cvar_s *gl_constretch; extern struct cvar_s *gl_dlight_polyblend; extern struct cvar_s *gl_dlight_smooth; +extern struct cvar_s *gl_doublebright; extern struct cvar_s *gl_fb_bmodels; extern struct cvar_s *gl_fb_models; extern struct cvar_s *gl_keeptjunctions; @@ -27,6 +30,7 @@ extern struct cvar_s *gl_lightmap_subimage; extern struct cvar_s *gl_max_size; extern struct cvar_s *gl_multitexture; extern struct cvar_s *gl_nocolors; +extern struct cvar_s *gl_overbright; extern struct cvar_s *gl_particle_mip; extern struct cvar_s *gl_particle_size; extern struct cvar_s *gl_picmip; diff --git a/libs/video/renderer/gl/gl_lightmap.c b/libs/video/renderer/gl/gl_lightmap.c index 49d612942..9c93142aa 100644 --- a/libs/video/renderer/gl/gl_lightmap.c +++ b/libs/video/renderer/gl/gl_lightmap.c @@ -71,8 +71,8 @@ byte *lightmaps[MAX_LIGHTMAPS]; unsigned int blocklights[34 * 34 * 3]; //FIXME make dynamic int allocated[MAX_LIGHTMAPS][BLOCK_WIDTH]; -glpoly_t *lightmap_modified[MAX_GLTEXTURES]; -glpoly_t *lightmap_polys[MAX_LIGHTMAPS]; +qboolean lightmap_modified[MAX_GLTEXTURES]; +glpoly_t *lightmap_polys[MAX_LIGHTMAPS]; glRect_t lightmap_rectchange[MAX_LIGHTMAPS]; void (*R_BuildLightMap) (msurface_t *surf); @@ -111,8 +111,8 @@ R_AddDynamicLights_1 (msurface_t *surf) float dist; int maxdist, maxdist2, maxdist3, smax, smax_bytes, tmax, grey, s, t; - unsigned int lnum, i, j; - unsigned int sdtable[18], td; + unsigned int lnum, td, i, j; + unsigned int sdtable[18]; unsigned int *bl; vec3_t impact, local; @@ -176,8 +176,8 @@ R_AddDynamicLights_3 (msurface_t *surf) float dist; int maxdist, maxdist2, maxdist3, smax, smax_bytes, tmax, red, green, blue, s, t; - unsigned int lnum, i, j; - unsigned int sdtable[18], td; + unsigned int lnum, td, i, j; + unsigned int sdtable[18]; unsigned int *bl; vec3_t impact, local; @@ -289,11 +289,32 @@ R_BuildLightMap_1 (msurface_t *surf) dest = lightmaps[surf->lightmaptexturenum] + (surf->light_t * BLOCK_WIDTH + surf->light_s) * lightmap_bytes; - for (i = 0; i < tmax; i++, dest += stride) { - for (j = smax; j; j--) { - *dest++ = 255 - min (*bl >> 8, 255); - bl++; + + switch (gl_overbright->int_val) { + case 1: + for (i = 0; i < tmax; i++, dest += stride) { + for (j = smax; j; j--) { + *dest++ = min ((*bl >> 9) + (*bl >> 10), 255); + bl++; + } } + break; + case 2: + for (i = 0; i < tmax; i++, dest += stride) { + for (j = smax; j; j--) { + *dest++ = min (*bl >> 9, 255); + bl++; + } + } + break; + default: + for (i = 0; i < tmax; i++, dest += stride) { + for (j = smax; j; j--) { + *dest++ = min (*bl >> 8, 255); + bl++; + } + } + break; } } @@ -347,15 +368,44 @@ R_BuildLightMap_3 (msurface_t *surf) dest = lightmaps[surf->lightmaptexturenum] + (surf->light_t * BLOCK_WIDTH + surf->light_s) * lightmap_bytes; - for (i = 0; i < tmax; i++, dest += stride) { - for (j = 0; j < smax; j++) { - *dest++ = 255 - min (*bl >> 8, 255); - bl++; - *dest++ = 255 - min (*bl >> 8, 255); - bl++; - *dest++ = 255 - min (*bl >> 8, 255); - bl++; + + switch (gl_overbright->int_val) { + case 1: + for (i = 0; i < tmax; i++, dest += stride) { + for (j = 0; j < smax; j++) { + *dest++ = min ((*bl >> 9) + (*bl >> 10), 255); + bl++; + *dest++ = min ((*bl >> 9) + (*bl >> 10), 255); + bl++; + *dest++ = min ((*bl >> 9) + (*bl >> 10), 255); + bl++; + } } + break; + case 2: + for (i = 0; i < tmax; i++, dest += stride) { + for (j = 0; j < smax; j++) { + *dest++ = min (*bl >> 9, 255); + bl++; + *dest++ = min (*bl >> 9, 255); + bl++; + *dest++ = min (*bl >> 9, 255); + bl++; + } + } + break; + default: + for (i = 0; i < tmax; i++, dest += stride) { + for (j = 0; j < smax; j++) { + *dest++ = min (*bl >> 8, 255); + bl++; + *dest++ = min (*bl >> 8, 255); + bl++; + *dest++ = min (*bl >> 8, 255); + bl++; + } + } + break; } } @@ -409,16 +459,47 @@ R_BuildLightMap_4 (msurface_t *surf) dest = lightmaps[surf->lightmaptexturenum] + (surf->light_t * BLOCK_WIDTH + surf->light_s) * lightmap_bytes; - for (i = 0; i < tmax; i++, dest += stride) { - for (j = 0; j < smax; j++) { - *dest++ = 255 - min (*bl >> 8, 255); - bl++; - *dest++ = 255 - min (*bl >> 8, 255); - bl++; - *dest++ = 255 - min (*bl >> 8, 255); - bl++; - *dest++ = 255; + + switch (gl_overbright->int_val) { + case 1: + for (i = 0; i < tmax; i++, dest += stride) { + for (j = 0; j < smax; j++) { + *dest++ = min ((*bl >> 9) + (*bl >> 10), 255); + bl++; + *dest++ = min ((*bl >> 9) + (*bl >> 10), 255); + bl++; + *dest++ = min ((*bl >> 9) + (*bl >> 10), 255); + bl++; + *dest++ = 0; + } } + break; + case 2: + for (i = 0; i < tmax; i++, dest += stride) { + for (j = 0; j < smax; j++) { + *dest++ = min (*bl >> 9, 255); + bl++; + *dest++ = min (*bl >> 9, 255); + bl++; + *dest++ = min (*bl >> 9, 255); + bl++; + *dest++ = 0; + } + } + break; + default: + for (i = 0; i < tmax; i++, dest += stride) { + for (j = 0; j < smax; j++) { + *dest++ = min (*bl >> 8, 255); + bl++; + *dest++ = min (*bl >> 8, 255); + bl++; + *dest++ = min (*bl >> 8, 255); + bl++; + *dest++ = 0; + } + } + break; } } @@ -478,7 +559,11 @@ R_BlendLightmaps (void) glpoly_t *p; qfglDepthMask (GL_FALSE); // don't bother writing Z - qfglBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_COLOR); + + if (gl_doublebright->int_val) + qfglBlendFunc (GL_DST_COLOR, GL_SRC_COLOR); + else + qfglBlendFunc (GL_ZERO, GL_SRC_COLOR); for (i = 0; i < MAX_LIGHTMAPS; i++) { p = lightmap_polys[i]; @@ -501,6 +586,55 @@ R_BlendLightmaps (void) qfglDepthMask (GL_TRUE); // back to normal Z buffering } +void +gl_overbright_f (cvar_t *var) +{ + int num, i, j; + model_t *m; + msurface_t *fa; + + if (R_BuildLightMap == 0) + return; + + for (i = 0; i < r_numvisedicts; i++) { + m = r_visedicts[i]->model; + + if (m->type != mod_brush) + continue; + if (m->name[0] == '*') + continue; + + for (j = 0, fa = m->surfaces; j < m->numsurfaces; j++, fa++) { + if (fa->flags & (SURF_DRAWTURB | SURF_DRAWSKY)) + continue; + num = fa->lightmaptexturenum; + + lightmap_modified[num] = true; + lightmap_rectchange[num].l = 0; + lightmap_rectchange[num].t = 0; + lightmap_rectchange[num].w = BLOCK_WIDTH; + lightmap_rectchange[num].h = BLOCK_HEIGHT; + R_BuildLightMap (fa); + } + } + + m = r_worldentity.model; + + for (i = 0, fa = m->surfaces; i < m->numsurfaces; i++, fa++) { + if (fa->flags & (SURF_DRAWTURB | SURF_DRAWSKY)) + continue; + + num = fa->lightmaptexturenum; + lightmap_modified[num] = true; + lightmap_rectchange[num].l = 0; + lightmap_rectchange[num].t = 0; + lightmap_rectchange[num].w = BLOCK_WIDTH; + lightmap_rectchange[num].h = BLOCK_HEIGHT; + + R_BuildLightMap (fa); + } +} + void R_CalcAndBlendLightmaps (void) { @@ -509,7 +643,10 @@ R_CalcAndBlendLightmaps (void) glpoly_t *p; qfglDepthMask (GL_FALSE); // don't bother writing Z - qfglBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_COLOR); + if (gl_doublebright->int_val) + qfglBlendFunc (GL_DST_COLOR, GL_SRC_COLOR); + else + qfglBlendFunc (GL_ZERO, GL_SRC_COLOR); for (i = 0; i < MAX_LIGHTMAPS; i++) { p = lightmap_polys[i]; diff --git a/libs/video/renderer/gl/gl_rsurf.c b/libs/video/renderer/gl/gl_rsurf.c index b30d8cb94..8d9a8e4a0 100644 --- a/libs/video/renderer/gl/gl_rsurf.c +++ b/libs/video/renderer/gl/gl_rsurf.c @@ -261,6 +261,24 @@ DrawTextureChains (void) texture_t *tex; if (gl_mtex_active) { + // Fullbrights + if (gl_mtex_fullbright) { + qglActiveTexture (gl_mtex_enum + 2); + qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + } + + // Lightmaps + qglActiveTexture (gl_mtex_enum +1); + if (gl_combine_capable && gl_doublebright->int_val) { + qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); + qfglTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); + qfglTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.0); + } else { + qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } + qfglEnable (GL_TEXTURE_2D); // I hope this can go here... + + // Base texture qglActiveTexture (gl_mtex_enum + 0); qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); } else { @@ -272,40 +290,38 @@ DrawTextureChains (void) if (!tex) continue; + if (gl_mtex_active) + qglActiveTexture (gl_mtex_enum + 0); + qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum); - if (gl_mtex_fullbright&& gl_fb_bmodels->int_val && tex->gl_fb_texturenum) { + if (gl_mtex_fullbright && gl_fb_bmodels->int_val + && tex->gl_fb_texturenum) { qglActiveTexture (gl_mtex_enum + 2); qfglBindTexture (GL_TEXTURE_2D, tex->gl_fb_texturenum); - qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); qfglEnable (GL_TEXTURE_2D); } if (gl_mtex_active) { + qglActiveTexture (gl_mtex_enum + 1); + for (s = tex->texturechain; s; s = s->texturechain) { - qglActiveTexture (gl_mtex_enum + 1); qfglBindTexture (GL_TEXTURE_2D, lightmap_textures + - s->lightmaptexturenum); - qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND); - qfglEnable (GL_TEXTURE_2D); + s->lightmaptexturenum); R_RenderBrushPoly (s); - - qfglDisable (GL_TEXTURE_2D); } } else { for (s = tex->texturechain; s; s = s->texturechain) R_RenderBrushPoly (s); } - if (gl_mtex_fullbright && gl_fb_bmodels->int_val && tex->gl_fb_texturenum) { + if (gl_mtex_fullbright && gl_fb_bmodels->int_val + && tex->gl_fb_texturenum) { qglActiveTexture (gl_mtex_enum + 2); qfglDisable (GL_TEXTURE_2D); } - if (gl_mtex_active) - qglActiveTexture (gl_mtex_enum + 0); - tex->texturechain = NULL; tex->texturechain_tail = &tex->texturechain; } @@ -313,9 +329,14 @@ DrawTextureChains (void) tex->texturechain = NULL; tex->texturechain_tail = &tex->texturechain; - if (!gl_mtex_active) + if (!gl_mtex_active) { qfglEnable (GL_BLEND); - else { + } else { + // Turn off lightmaps for other entities + qglActiveTexture (gl_mtex_enum + 1); + qfglDisable (GL_TEXTURE_2D); + + // Rest mode for default TMU qglActiveTexture (gl_mtex_enum + 0); qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } @@ -401,9 +422,32 @@ R_DrawBrushModel (entity_t *e) for (i = 0; i < model->nummodelsurfaces; i++, psurf++) R_AddToLightmapChain(psurf); - R_CalcLightmaps (); + if (gl_mtex_active) { + R_CalcLightmaps (); + psurf = &model->surfaces[model->firstmodelsurface]; - psurf = &model->surfaces[model->firstmodelsurface]; + // Fullbrights + if (gl_mtex_fullbright) { + qglActiveTexture (gl_mtex_enum + 2); + qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + } + + // Lightmaps + qglActiveTexture (gl_mtex_enum + 1); + if (gl_doublebright->int_val && gl_combine_capable) { + qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); + qfglTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); + qfglTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2.0); + } else { + qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } + qfglEnable (GL_TEXTURE_2D); + + // Regular texture (DON'T GL_REPLACE!) + qglActiveTexture (gl_mtex_enum + 0); + } else { + psurf = &model->surfaces[model->firstmodelsurface]; + } // draw texture for (i = 0; i < model->nummodelsurfaces; i++, psurf++) { @@ -440,15 +484,8 @@ R_DrawBrushModel (entity_t *e) tex = psurf->texinfo->texture; else tex = R_TextureAnimation (psurf); - - if (gl_mtex_active) { - qglActiveTexture (gl_mtex_enum + 0); - qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum); - qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, - GL_REPLACE); - } else { - qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum); - } + + qfglBindTexture (GL_TEXTURE_2D, tex->gl_texturenum); qfglColor4fv (color); @@ -456,26 +493,17 @@ R_DrawBrushModel (entity_t *e) && tex->gl_fb_texturenum > 0) { qglActiveTexture (gl_mtex_enum + 2); qfglBindTexture (GL_TEXTURE_2D, tex->gl_fb_texturenum); - qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, - GL_DECAL); qfglEnable (GL_TEXTURE_2D); } if (gl_mtex_active) { qglActiveTexture (gl_mtex_enum + 1); qfglBindTexture (GL_TEXTURE_2D, lightmap_textures + - psurf->lightmaptexturenum); - qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, - GL_BLEND); - qfglEnable (GL_TEXTURE_2D); + psurf->lightmaptexturenum); } R_RenderBrushPoly (psurf); - if (gl_mtex_active) { - qfglDisable (GL_TEXTURE_2D); - } - if (gl_fb_bmodels->int_val && gl_mtex_fullbright && tex->gl_fb_texturenum > 0) { qglActiveTexture (gl_mtex_enum + 2); @@ -484,13 +512,12 @@ R_DrawBrushModel (entity_t *e) if (gl_mtex_active) { qglActiveTexture (gl_mtex_enum + 0); - qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, - GL_MODULATE); } qfglColor3ubv (color_white); - if (tex->gl_fb_texturenum > 0 && gl_fb_bmodels->int_val) { + if (tex->gl_fb_texturenum > 0 && gl_fb_bmodels->int_val + && !gl_mtex_fullbright) { psurf->polys->fb_chain = fullbright_polys[tex->gl_fb_texturenum]; fullbright_polys[tex->gl_fb_texturenum] = psurf->polys; @@ -499,8 +526,14 @@ R_DrawBrushModel (entity_t *e) } } - if (!gl_mtex_active) - R_BlendLightmaps (); + if (gl_mtex_active) { + // Go away, lightmap + qglActiveTexture (gl_mtex_enum + 1); + qfglDisable (GL_TEXTURE_2D); + qglActiveTexture (gl_mtex_enum + 0); + } else { + R_CalcAndBlendLightmaps (); + } if (gl_fb_bmodels->int_val && !gl_mtex_fullbright) R_RenderFullbrights (); diff --git a/libs/video/renderer/r_cvar.c b/libs/video/renderer/r_cvar.c index 50e86fa85..775ca1b3a 100644 --- a/libs/video/renderer/r_cvar.c +++ b/libs/video/renderer/r_cvar.c @@ -70,6 +70,7 @@ cvar_t *gl_lerp_anim; cvar_t *gl_lightmap_align; cvar_t *gl_lightmap_subimage; cvar_t *gl_nocolors; +cvar_t *gl_overbright; cvar_t *gl_particle_mip; cvar_t *gl_particle_size; cvar_t *gl_picmip; @@ -285,6 +286,10 @@ R_Init_Cvars (void) "entire lightmap."); gl_nocolors = Cvar_Get ("gl_nocolors", "0", CVAR_NONE, NULL, "Set to 1, turns off all player colors"); + gl_overbright = Cvar_Get ("gl_overbright", "1", CVAR_NONE, + gl_overbright_f, "Darken lightmaps so that " + "dynamic lights can be overbright. 1 = 0.75 " + "brightness, 2 = 0.5 brightness."); gl_particle_mip = Cvar_Get ("gl_particle_mip", "0", CVAR_NONE, NULL, "Toggles particle texture mipmapping."); gl_particle_size = Cvar_Get ("gl_particle_size", "5", CVAR_NONE, NULL, diff --git a/libs/video/renderer/sw/sw_rmain.c b/libs/video/renderer/sw/sw_rmain.c index 831fd44da..570c5ca04 100644 --- a/libs/video/renderer/sw/sw_rmain.c +++ b/libs/video/renderer/sw/sw_rmain.c @@ -1206,3 +1206,8 @@ R_RenderViewFishEye (void) r_refdef.viewangles[ROLL] = roll; renderlookup (offs, scrbufs); } + +void +gl_overbright_f (cvar_t *un) +{ +} diff --git a/libs/video/renderer/sw32/sw32_rmain.c b/libs/video/renderer/sw32/sw32_rmain.c index 522ce1da8..257cf0a4a 100644 --- a/libs/video/renderer/sw32/sw32_rmain.c +++ b/libs/video/renderer/sw32/sw32_rmain.c @@ -927,3 +927,8 @@ R_InitTurb (void) // AMP2 not 20 } } + +void +gl_overbright_f (cvar_t *un) +{ +} diff --git a/libs/video/targets/vid_common_gl.c b/libs/video/targets/vid_common_gl.c index d7995e798..ea826a3e5 100644 --- a/libs/video/targets/vid_common_gl.c +++ b/libs/video/targets/vid_common_gl.c @@ -91,6 +91,9 @@ qboolean gl_mtex_fullbright = false; GLenum gl_mtex_enum = GL_TEXTURE0_ARB; +// ARB Combine +qboolean gl_combine_capable = false; + QF_glColorTableEXT qglColorTableEXT = NULL; qboolean is8bit = false; @@ -100,6 +103,7 @@ qboolean gl_feature_mach64 = false; qboolean TruForm; GLint tess, tess_max; +cvar_t *gl_doublebright; cvar_t *gl_max_size; cvar_t *gl_multitexture; cvar_t *gl_tessellate; @@ -110,6 +114,15 @@ cvar_t *vid_use8bit; static int gl_mtex_tmus = 0; + +static void +gl_doublebright_f (cvar_t *var) +{ + if (!gl_combine_capable) + Con_Printf ("Warning: doublebright will have no effect without " + "GL_COMBINE_ARB unless multitexture is disabled.\n"); +} + static void gl_max_size_f (cvar_t *var) { @@ -173,6 +186,10 @@ GL_Common_Init_Cvars (void) { vid_use8bit = Cvar_Get ("vid_use8bit", "0", CVAR_ROM, NULL, "Use 8-bit " "shared palettes."); + gl_doublebright = Cvar_Get ("gl_doublebright", "1", CVAR_ARCHIVE, + gl_doublebright_f, "Use different lighting " + "algorithm to increase brightness of map " + "surfaces."); gl_max_size = Cvar_Get ("gl_max_size", "0", CVAR_NONE, gl_max_size_f, "Texture dimension"); gl_multitexture = Cvar_Get ("gl_multitexture", "0", CVAR_ARCHIVE, @@ -193,6 +210,19 @@ GL_Common_Init_Cvars (void) "limit, -1 disables use of vertex arrays."); } +static void +CheckCombineExtensions (void) +{ + if (QFGL_ExtensionPresent ("GL_ARB_texture_env_combine")) { + gl_combine_capable = true; + Con_Printf ("COMBINE_ARB active, multitextured doublebright " + "enabled.\n"); + } else { + Con_Printf ("GL_ARB_texture_env_combine not found. gl_doublebright " + "will have no effect with gl_multitexture on.\n"); + } +} + /* CheckMultiTextureExtensions @@ -390,6 +420,7 @@ GL_Init_Common (void) qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); CheckMultiTextureExtensions (); + CheckCombineExtensions (); CheckTruFormExtensions (); GL_Common_Init_Cvars (); CheckVertexArraySize ();