]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_shared.c
properly detect glsl 1.3 support
[xonotic/darkplaces.git] / vid_shared.c
index 8eda95e58fcf1822f99edbd788668770de54c1c2..b092f4872aa28f94f8e570a81b4ef5627a267b3a 100644 (file)
@@ -335,6 +335,7 @@ void (GLAPIENTRY *qglVertexAttribPointer)(GLuint index, GLint size, GLenum type,
 void (GLAPIENTRY *qglEnableVertexAttribArray)(GLuint index);
 void (GLAPIENTRY *qglDisableVertexAttribArray)(GLuint index);
 void (GLAPIENTRY *qglBindAttribLocation)(GLuint programObj, GLuint index, const GLchar *name);
+void (GLAPIENTRY *qglBindFragDataLocation)(GLuint programObj, GLuint index, const GLchar *name);
 void (GLAPIENTRY *qglGetActiveAttrib)(GLuint programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
 GLint (GLAPIENTRY *qglGetAttribLocation)(GLuint programObj, const GLchar *name);
 void (GLAPIENTRY *qglGetVertexAttribdv)(GLuint index, GLenum pname, GLdouble *params);
@@ -726,6 +727,12 @@ static dllfunction_t gl20shaderfuncs[] =
        {NULL, NULL}
 };
 
+static dllfunction_t glsl130funcs[] =
+{
+       {"glBindFragDataLocation", (void **) &qglBindFragDataLocation},
+       {NULL, NULL}
+};
+
 static dllfunction_t vbofuncs[] =
 {
        {"glBindBufferARB"    , (void **) &qglBindBufferARB},
@@ -832,6 +839,19 @@ void VID_CheckExtensions(void)
 
        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);