mojoshader_opengl.c
branchtrunk
changeset 276 1d7437469c94
parent 262 0f1531ac2578
child 277 49a6571cac6d
--- a/mojoshader_opengl.c	Sat May 03 13:40:55 2008 -0400
+++ b/mojoshader_opengl.c	Sat May 03 13:42:47 2008 -0400
@@ -78,7 +78,8 @@
 };
 
 // Entry points in base OpenGL that lack function pointer prototypes...
-typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC) (GLenum name);
+typedef WINGDIAPI void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params);
+typedef WINGDIAPI const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC) (GLenum name);
 
 struct MOJOSHADER_glContext
 {
@@ -112,6 +113,7 @@
 
     // Entry points...
     PFNGLGETSTRINGPROC glGetString;
+    PFNGLGETINTEGERVPROC glGetIntegerv;
     PFNGLDELETEOBJECTARBPROC glDeleteObject;
     PFNGLATTACHOBJECTARBPROC glAttachObject;
     PFNGLCOMPILESHADERARBPROC glCompileShader;
@@ -199,6 +201,7 @@
 {
     #define DO_LOOKUP(ext, typ, fn) ctx->fn = (typ) loadsym(lookup, #fn, &ctx->have_##ext)
     DO_LOOKUP(base_opengl, PFNGLGETSTRINGPROC, glGetString);
+    DO_LOOKUP(base_opengl, PFNGLGETINTEGERVPROC, glGetIntegerv);
     DO_LOOKUP(GL_ARB_shader_objects, PFNGLDELETEOBJECTARBPROC, glDeleteObject);
     DO_LOOKUP(GL_ARB_shader_objects, PFNGLATTACHOBJECTARBPROC, glAttachObject);
     DO_LOOKUP(GL_ARB_shader_objects, PFNGLCOMPILESHADERARBPROC, glCompileShader);
@@ -413,6 +416,22 @@
 } // MOJOSHADER_glMakeContextCurrent
 
 
+int MOJOSHADER_glMaxUniforms(MOJOSHADER_shaderType shader_type)
+{
+    GLenum pname = GL_NONE;
+    GLint val = 0;
+    if (shader_type == MOJOSHADER_TYPE_VERTEX)
+        pname = GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB;
+    else if (shader_type == MOJOSHADER_TYPE_PIXEL)
+        pname = GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB;
+    else
+        return -1;
+
+    ctx->glGetIntegerv(pname, &val);
+    return (int) val;
+} // MOJOSHADER_glMaxUniforms
+
+
 MOJOSHADER_glShader *MOJOSHADER_glCompileShader(const unsigned char *tokenbuf,
                                                 const unsigned int bufsize)
 {