From c565551f39d2c1f8d8ca137eca8dd8523fe80a5d Mon Sep 17 00:00:00 2001 From: divverent Date: Sun, 13 Mar 2011 17:19:18 +0000 Subject: [PATCH] properly detect glsl 1.3 support git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10919 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=33d128230bf1e9c329eb21c831b97ca9cf0f7477 --- gl_backend.c | 2 +- gl_rmain.c | 5 ++--- vid.h | 1 + vid_shared.c | 16 +++++++++++++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/gl_backend.c b/gl_backend.c index 68067aff..8ad6989c 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -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)) diff --git a/gl_rmain.c b/gl_rmain.c index 790dbca4..a4467e58 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -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 2ef6c80e..30327583 100644 --- 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; diff --git a/vid_shared.c b/vid_shared.c index 43d5e698..b092f487 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -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); -- 2.39.2