From 6a15287daff66025beeff47d3371ebb2c4bed0ec Mon Sep 17 00:00:00 2001 From: divverent Date: Thu, 20 Oct 2011 17:40:37 +0000 Subject: [PATCH] make the sRGB fallback cvar controlled (and off by default) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11451 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=2a5f7fd6fcc9616626358aab8207a123cdad9018 --- gl_rsurf.c | 3 ++- model_brush.c | 5 +++-- vid_shared.c | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/gl_rsurf.c b/gl_rsurf.c index 8d9ad756..0331e2be 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -32,6 +32,7 @@ cvar_t r_useportalculling = {0, "r_useportalculling", "2", "improve framerate wi cvar_t r_usesurfaceculling = {0, "r_usesurfaceculling", "1", "skip off-screen surfaces (1 = cull surfaces if the map is likely to benefit, 2 = always cull surfaces)"}; cvar_t r_q3bsp_renderskydepth = {0, "r_q3bsp_renderskydepth", "0", "draws sky depth masking in q3 maps (as in q1 maps), this means for example that sky polygons can hide other things"}; extern cvar_t vid_sRGB; +extern cvar_t vid_sRGB_fallback; /* =============== @@ -122,7 +123,7 @@ void R_BuildLightMap (const entity_render_t *ent, msurface_t *surface) } } - if(vid_sRGB.integer && !vid.sRGBcapable3D) + if(vid_sRGB.integer && vid_sRGB_fallback.integer && !vid.sRGB3D) Image_MakesRGBColorsFromLinear_Lightmap(templight, templight, size); R_UpdateTexture(surface->lightmaptexture, templight, surface->lightmapinfo->lightmaporigin[0], surface->lightmapinfo->lightmaporigin[1], 0, smax, tmax, 1); diff --git a/model_brush.c b/model_brush.c index aed624c9..401af957 100644 --- a/model_brush.c +++ b/model_brush.c @@ -58,6 +58,7 @@ cvar_t mod_q1bsp_polygoncollisions = {0, "mod_q1bsp_polygoncollisions", "0", "di cvar_t mod_collision_bih = {0, "mod_collision_bih", "1", "enables use of generated Bounding Interval Hierarchy tree instead of compiled bsp tree in collision code"}; cvar_t mod_recalculatenodeboxes = {0, "mod_recalculatenodeboxes", "1", "enables use of generated node bounding boxes based on BSP tree portal reconstruction, rather than the node boxes supplied by the map compiler"}; extern cvar_t vid_sRGB; +extern cvar_t vid_sRGB_fallback; static texture_t mod_q1bsp_texture_solid; static texture_t mod_q1bsp_texture_sky; @@ -4724,7 +4725,7 @@ static void Mod_Q3BSP_LoadVertices(lump_t *l) loadmodel->brushq3.data_texcoordlightmap2f[i * 2 + 0] = LittleFloat(in->lightmap2f[0]); loadmodel->brushq3.data_texcoordlightmap2f[i * 2 + 1] = LittleFloat(in->lightmap2f[1]); // svector/tvector are calculated later in face loading - if(vid_sRGB.integer && !vid.sRGBcapable3D) + if(vid_sRGB.integer && vid_sRGB_fallback.integer && !vid.sRGB3D) { loadmodel->brushq3.data_color4f[i * 4 + 0] = Image_sRGBFloatFromLinear_Lightmap(in->color4ub[0]); loadmodel->brushq3.data_color4f[i * 4 + 1] = Image_sRGBFloatFromLinear_Lightmap(in->color4ub[1]); @@ -5020,7 +5021,7 @@ static void Mod_Q3BSP_LoadLightmaps(lump_t *l, lump_t *faceslump) loadmodel->brushq3.data_deluxemaps[lightmapindex] = R_LoadTexture2D(loadmodel->texturepool, va("deluxemap%04i", lightmapindex), mergedwidth, mergedheight, mergeddeluxepixels, TEXTYPE_BGRA, TEXF_FORCELINEAR | (gl_texturecompression_q3bspdeluxemaps.integer ? TEXF_COMPRESS : 0), -1, NULL); else { - if(vid_sRGB.integer && !vid.sRGBcapable3D) + if(vid_sRGB.integer && vid_sRGB_fallback.integer && !vid.sRGB3D) Image_MakesRGBColorsFromLinear_Lightmap(mergedpixels, mergedpixels, mergedwidth * mergedheight); loadmodel->brushq3.data_lightmaps [lightmapindex] = R_LoadTexture2D(loadmodel->texturepool, va("lightmap%04i", lightmapindex), mergedwidth, mergedheight, mergedpixels, TEXTYPE_BGRA, TEXF_FORCELINEAR | (gl_texturecompression_q3bsplightmaps.integer ? TEXF_COMPRESS : 0), -1, NULL); } diff --git a/vid_shared.c b/vid_shared.c index d251e7a9..6f7af37a 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -177,6 +177,7 @@ cvar_t vid_gl13 = {0, "vid_gl13", "1", "enables faster rendering using OpenGL 1. cvar_t vid_gl20 = {0, "vid_gl20", "1", "enables faster rendering using OpenGL 2.0 features (such as GL_ARB_fragment_shader extension)"}; cvar_t gl_finish = {0, "gl_finish", "0", "make the cpu wait for the graphics processor at the end of each rendered frame (can help with strange input or video lag problems on some machines)"}; cvar_t vid_sRGB = {CVAR_SAVE, "vid_sRGB", "0", "if hardware is capable, modify rendering to be gamma corrected for the sRGB color standard (computer monitors, TVs), recommended"}; +cvar_t vid_sRGB_fallback = {CVAR_SAVE, "vid_sRGB_fallback", "0", "do an approximate sRGB fallback if not properly supported by hardware (2: always use the fallback even if sRGB is supported)"}; cvar_t vid_touchscreen = {0, "vid_touchscreen", "0", "Use touchscreen-style input (no mouse grab, track mouse motion only while button is down, screen areas for mimicing joystick axes and buttons"}; cvar_t vid_stick_mouse = {CVAR_SAVE, "vid_stick_mouse", "0", "have the mouse stuck in the center of the screen" }; @@ -1686,6 +1687,7 @@ void VID_Shared_Init(void) Cvar_RegisterVariable(&vid_gl20); Cvar_RegisterVariable(&gl_finish); Cvar_RegisterVariable(&vid_sRGB); + Cvar_RegisterVariable(&vid_sRGB_fallback); Cvar_RegisterVariable(&joy_active); #ifdef WIN32 @@ -1770,8 +1772,8 @@ int VID_Mode(int fullscreen, int width, int height, int bpp, float refreshrate, vid.userefreshrate = vid.mode.userefreshrate; vid.stereobuffer = vid.mode.stereobuffer; vid.stencil = vid.mode.bitsperpixel > 16; - vid.sRGB2D = vid_sRGB.integer >= 1 && vid.sRGBcapable2D; - vid.sRGB3D = vid_sRGB.integer >= 1 && vid.sRGBcapable3D; + vid.sRGB2D = vid_sRGB.integer >= 1 && vid_sRGB_fallback.integer <= 1 && vid.sRGBcapable2D; + vid.sRGB3D = vid_sRGB.integer >= 1 && vid_sRGB_fallback.integer <= 1 && vid.sRGBcapable3D; if(vid.samples != vid.mode.samples) Con_Printf("NOTE: requested %dx AA, got %dx AA\n", vid.mode.samples, vid.samples); -- 2.39.2