]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
make the sRGB fallback cvar controlled (and off by default)
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 20 Oct 2011 17:40:37 +0000 (17:40 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 20 Oct 2011 17:40:37 +0000 (17:40 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11451 d7cf8633-e32d-0410-b094-e92efae38249

gl_rsurf.c
model_brush.c
vid_shared.c

index 8d9ad7563558e12714c61a7878d922feb638f5c2..0331e2be08d6fec75a0dc1925950e52cfec33afc 100644 (file)
@@ -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;
 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);
 
                Image_MakesRGBColorsFromLinear_Lightmap(templight, templight, size);
        R_UpdateTexture(surface->lightmaptexture, templight, surface->lightmapinfo->lightmaporigin[0], surface->lightmapinfo->lightmaporigin[1], 0, smax, tmax, 1);
 
index aed624c912120b501efe643f8c15a4472256cf96..401af9579e94b5f4c4fc6701358aa1765941e78a 100644 (file)
@@ -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;
 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;
 
 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
                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]);
                {
                        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
                        {
                                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);
                        }
                                        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);
                        }
index d251e7a9fc7f72a051aba5883cfafe47d59ecf35..6f7af37aeda84e369d6e95f14dd087de70bef01e 100644 (file)
@@ -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_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" };
 
 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_gl20);
        Cvar_RegisterVariable(&gl_finish);
        Cvar_RegisterVariable(&vid_sRGB);
+       Cvar_RegisterVariable(&vid_sRGB_fallback);
 
        Cvar_RegisterVariable(&joy_active);
 #ifdef WIN32
 
        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.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);
 
                if(vid.samples != vid.mode.samples)
                        Con_Printf("NOTE: requested %dx AA, got %dx AA\n", vid.mode.samples, vid.samples);