]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_shared.c
implemented support for GL_EXT_texture_sRGB to preserve precision if
[xonotic/darkplaces.git] / vid_shared.c
index b2e2636ec7acba5c47b9ae4b685506d7b0ed6bea..81f6feefaafddf4bcc634db19dd902a804e628c9 100644 (file)
@@ -92,7 +92,7 @@ cvar_t v_color_white_g = {CVAR_SAVE, "v_color_white_g", "1", "desired color of w
 cvar_t v_color_white_b = {CVAR_SAVE, "v_color_white_b", "1", "desired color of white"};
 cvar_t v_hwgamma = {CVAR_SAVE, "v_hwgamma", "1", "enables use of hardware gamma correction ramps if available (note: does not work very well on Windows2000 and above), values are 0 = off, 1 = attempt to use hardware gamma, 2 = use hardware gamma whether it works or not"};
 cvar_t v_glslgamma = {CVAR_SAVE, "v_glslgamma", "0", "enables use of GLSL to apply gamma correction ramps if available (note: overrides v_hwgamma)"};
-cvar_t v_psycho = {0, "v_psycho", "0", "easter egg (does not work on Windows2000 or above)"};
+cvar_t v_psycho = {0, "v_psycho", "0", "easter egg"};
 
 // brand of graphics chip
 const char *gl_vendor;
@@ -857,6 +857,9 @@ void VID_CheckExtensions(void)
        else
                Con_DPrintf("Using GLSL 1.00\n");
 
+       // GL drivers generally prefer GL_BGRA
+       vid.forcetextype = GL_BGRA;
+
        vid.support.amd_texture_texture4 = GL_CheckExtension("GL_AMD_texture_texture4", NULL, "-notexture4", false);
        vid.support.arb_depth_texture = GL_CheckExtension("GL_ARB_depth_texture", NULL, "-nodepthtexture", false);
        vid.support.arb_draw_buffers = GL_CheckExtension("GL_ARB_draw_buffers", drawbuffersfuncs, "-nodrawbuffers", false);
@@ -879,6 +882,7 @@ void VID_CheckExtensions(void)
        vid.support.ext_texture_compression_s3tc = GL_CheckExtension("GL_EXT_texture_compression_s3tc", NULL, "-nos3tc", false);
        vid.support.ext_texture_edge_clamp = GL_CheckExtension("GL_EXT_texture_edge_clamp", NULL, "-noedgeclamp", false) || GL_CheckExtension("GL_SGIS_texture_edge_clamp", NULL, "-noedgeclamp", false);
        vid.support.ext_texture_filter_anisotropic = GL_CheckExtension("GL_EXT_texture_filter_anisotropic", NULL, "-noanisotropy", false);
+       vid.support.ext_texture_srgb = GL_CheckExtension("GL_EXT_texture_sRGB", NULL, "-nosrgb", false);
 // COMMANDLINEOPTION: GL: -noshaders disables use of OpenGL 2.0 shaders (which allow pixel shader effects, can improve per pixel lighting performance and capabilities)
 // COMMANDLINEOPTION: GL: -noanisotropy disables GL_EXT_texture_filter_anisotropic (allows higher quality texturing)
 // COMMANDLINEOPTION: GL: -noblendminmax disables GL_EXT_blend_minmax
@@ -902,6 +906,7 @@ void VID_CheckExtensions(void)
 // COMMANDLINEOPTION: GL: -notexturegather disables GL_ARB_texture_gather (which provides fetch4 sampling)
 // COMMANDLINEOPTION: GL: -notexturenonpoweroftwo disables GL_ARB_texture_non_power_of_two (which saves video memory if it is supported, but crashes on some buggy drivers)
 // COMMANDLINEOPTION: GL: -novbo disables GL_ARB_vertex_buffer_object (which accelerates rendering)
+// COMMANDLINEOPTION: GL: -nosrgb disables GL_EXT_texture_sRGB (which is used for higher quality non-linear texture gamma)
 
        if (vid.support.arb_draw_buffers)
                qglGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, (GLint*)&vid.maxdrawbuffers);
@@ -1290,6 +1295,7 @@ int VID_Mode(int fullscreen, int width, int height, int bpp, float refreshrate,
                vid.stereobuffer   = vid.mode.stereobuffer;
                vid.samples        = vid.mode.samples;
                vid.stencil        = vid.mode.bitsperpixel > 16;
+
                Con_Printf("Video Mode: %s %dx%dx%dx%.2fhz%s%s\n", mode.fullscreen ? "fullscreen" : "window", mode.width, mode.height, mode.bitsperpixel, mode.refreshrate, mode.stereobuffer ? " stereo" : "", mode.samples > 1 ? va(" (%ix AA)", mode.samples) : "");
 
                Cvar_SetValueQuick(&vid_fullscreen, vid.mode.fullscreen);
@@ -1492,6 +1498,9 @@ void VID_Soft_SharedSetup(void)
        memset(&vid.support, 0, sizeof(vid.support));
        Cvar_SetQuick(&gl_info_extensions, "");
 
+       // DPSOFTRAST requires BGRA
+       vid.forcetextype = TEXTYPE_BGRA;
+
        vid.forcevbo = false;
        vid.support.arb_depth_texture = true;
        vid.support.arb_draw_buffers = true;
@@ -1508,6 +1517,7 @@ void VID_Soft_SharedSetup(void)
        //vid.support.ext_texture_compression_s3tc = true;
        vid.support.ext_texture_filter_anisotropic = true;
        vid.support.ati_separate_stencil = true;
+       vid.support.ext_texture_srgb = false;
 
        vid.maxtexturesize_2d = 16384;
        vid.maxtexturesize_3d = 512;