fixed bug added support for Programiv
[libgliar] / src / gliar.c
index e83d5cd..23164d5 100644 (file)
@@ -42,6 +42,7 @@ static const GLubyte* (*gl_get_string)(GLenum);
 static const GLubyte* (*gl_get_stringi)(GLenum, GLuint);
 static void (*gl_get_integerv)(GLenum, GLint*);
 static void (*gl_get_programiv)(GLuint, GLenum, GLint*);
+static void *(*glx_get_proc_address)(const unsigned char*);
 
 /*static const void* (*gl_get_booleanv)(GLenum, GLboolean*);
 static const void* (*gl_get_doublev)(GLenum, GLdouble*);
@@ -65,6 +66,7 @@ static int init(void)
        gl_get_stringi = dlsym(RTLD_NEXT, "glGetStringi");
        gl_get_integerv = dlsym(RTLD_NEXT, "glGetIntegerv");
        gl_get_programiv = dlsym(RTLD_NEXT, "glGetProgramivARB");
+       glx_get_proc_address = dlsym(RTLD_NEXT, "glXGetProcAddress");
 
        if(init_valid_extensions() == -1) {
                fprintf(stderr, "GLIAR: failed to initialize the valid extension list, might end up with unavailable extensions!\n");
@@ -325,7 +327,7 @@ void glGetProgramivARB(GLuint program, GLenum pname, GLint *params)
        init();
 
        if(!gl_get_programiv) {
-               fprintf(stderr, "Unable to fake the %s function. It is not supported by your OpenGL implementation.\n", __func__);
+               fprintf(stderr, "GLIAR: Unable to fake the %s function. It is not supported by your OpenGL implementation.\n", __func__);
                return;
        }
 
@@ -398,11 +400,38 @@ void glGetProgramivARB(GLuint program, GLenum pname, GLint *params)
                key = 0;
        }
 
-       if(key && (option = gliar_find_opt(cfglist, key)) && option->type == GLIAR_NUMBER) {
-               *params = option->num_val;
-               return;
+       if(key) {
+               char buf[256];
+               if(program == GL_VERTEX_PROGRAM_ARB) {
+                       sprintf(buf, "v %s", key);
+               }
+               else if(program == GL_FRAGMENT_PROGRAM_ARB) {
+                       sprintf(buf, "f %s", key);
+               }
+               key = buf;
+
+               if((option = gliar_find_opt(cfglist, key)) && option->type == GLIAR_NUMBER) {
+                       *params = option->num_val;
+                       return;
+               }
        }
 
        gl_get_programiv(program, pname, params);
 
 }
+
+void *glXGetProcAddress(const unsigned char *procname)
+{
+       init();
+
+       if(!strcmp((char*)procname, "glGetProgramivARB") || !strcmp((char*)procname, "glGetProgramiv")) {
+               return glGetProgramivARB;
+       }
+
+       return glx_get_proc_address(procname);
+}
+
+void *glXGetProcAddressARB(const unsigned char *procname)
+{
+       return glXGetProcAddress(procname);
+}