]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
properly detect glsl 1.3 support
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 13 Mar 2011 17:19:18 +0000 (17:19 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 13 Mar 2011 17:19:18 +0000 (17:19 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10919 d7cf8633-e32d-0410-b094-e92efae38249

gl_backend.c
gl_rmain.c
vid.h
vid_shared.c

index 68067aff7f399c810c3624cf557c3e40af23bc49..8ad6989c46f15d6e5d65a2dbc12b119abe5a4787 100644 (file)
@@ -2419,7 +2419,7 @@ unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **ver
        qglBindAttribLocation(programobject, GLSLATTRIB_TEXCOORD5, "Attrib_TexCoord5");
        qglBindAttribLocation(programobject, GLSLATTRIB_TEXCOORD6, "Attrib_TexCoord6");
        qglBindAttribLocation(programobject, GLSLATTRIB_TEXCOORD7, "Attrib_TexCoord7");
-       if(qglBindFragDataLocation)
+       if(vid.support.gl20shaders130)
                qglBindFragDataLocation(programobject, 0, "dp_FragColor");
 
        if (vertexstrings_count && !GL_Backend_CompileShader(programobject, GL_VERTEX_SHADER, "vertex", vertexstrings_count, vertexstrings_list))
index 790dbca4ad9457461078fbeb72658556c3836c50..a4467e58a57f1809ccbc320602893d7bf9cf214b 100644 (file)
@@ -980,9 +980,8 @@ static void R_GLSL_CompilePermutation(r_glsl_permutation_t *p, unsigned int mode
 
        strlcat(permutationname, modeinfo->vertexfilename, sizeof(permutationname));
 
-       // the first pretext is which type of shader to compile as
-       // (later these will all be bound together as a program object)
-       if(qglBindFragDataLocation && (permutation & SHADERPERMUTATION_OFFSETMAPPING)) // we use textureGrad() which is glsl 1.30
+       // if we can do #version 130, we should (this improves quality of offset/reliefmapping thanks to textureGrad)
+       if(vid.support.gl20shaders130)
        {
                vertstrings_list[vertstrings_count++] = "#version 130\n";
                geomstrings_list[geomstrings_count++] = "#version 130\n";
diff --git a/vid.h b/vid.h
index 2ef6c80ed7c7479251e5758f84625c7774ac01af..30327583636ea6cfa93e1b8cb5ad204f3fbf5853 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -44,6 +44,7 @@ renderpath_t;
 typedef struct viddef_support_s
 {
        qboolean gl20shaders;
+       qboolean gl20shaders130;
        qboolean amd_texture_texture4;
        qboolean arb_depth_texture;
        qboolean arb_draw_buffers;
index 43d5e698683f8de6a10ee6ae4c525669ea76ca10..b092f4872aa28f94f8e570a81b4ef5627a267b3a 100644 (file)
@@ -835,13 +835,23 @@ void VID_CheckExtensions(void)
                Sys_Error("OpenGL 1.1.0 functions not found");
        vid.support.gl20shaders = GL_CheckExtension("2.0", gl20shaderfuncs, "-noshaders", false);
 
-       // this one is purely optional, needed for GLSL 1.3 support (#version 130), so we don't even check the return value of GL_CheckExtension
-       GL_CheckExtension("2.0", glsl130funcs, "-noglsl130", false);
-
        CHECKGLERROR
 
        Con_DPrint("Checking OpenGL extensions...\n");
 
+       // this one is purely optional, needed for GLSL 1.3 support (#version 130), so we don't even check the return value of GL_CheckExtension
+       vid.support.gl20shaders130 = GL_CheckExtension("2.0", glsl130funcs, "-noglsl130", false);
+       if(vid.support.gl20shaders130)
+       {
+               char *s = (char *) qglGetString(GL_SHADING_LANGUAGE_VERSION);
+               if(!s || atof(s) < 1.30 - 0.00001)
+                       vid.support.gl20shaders130 = 0;
+       }
+       if(vid.support.gl20shaders130)
+               Con_DPrintf("Using GLSL 1.30\n");
+       else
+               Con_DPrintf("Using GLSL 1.00\n");
+
        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);