I faced this problem for the first time a year ago, while working for my parallax mapping demo, and I met it again these days, in which I’m busy to fine tune my depth of field demo to permit keyboard driven parameters tweaking.
The issue I’m talking about is quite seriuos, on my machine it is impossible to pass a float uniform variable to a shader, and I’m not the only one reporting it:
- glUniform*f seems to… not work.
- Problem with glUniform1f in 100.14.11 on 8800GTS
- GLSL Vertex Sh. uniform aren’t set (OGL 2.0)
The first link is a forum thread from GameDev written by a girl whose applications suffer from this annoying issue, he has written a proof of concept which works perfectly on my box, i.e. float uniforms are NOT passed. 🙂
But it has been the third one which made me think about how to fix the problem: it has been reported that, after calling glewInit(), glUniform*f() functions work again.
The first thing I did, of course, was to download and investigate inside GLEW sources to see what was happening inside that magic function. What it does, actually, is redefining all the GL function pointers calling glXGetProcAddress() for everyone of them, I thought it would have been a good thing to try to replicate this behaviour in my programs, and I was right! 😀
This is what I added to my sources for the incriminated function to work:
PFNGLUNIFORM1FPROC glUniform1f = NULL; glUniform1f = (PFNGLUNIFORM1FPROC)glXGetProcAddress((const GLubyte*)"glUniform1f");
This also seems to explain why my Python shader demo didn’t suffer from all of this, I think that PyOpenGL initializes itself retrieving the addresses for all the GL functions it needs.
IMPORTANT UPDATE
M3xican, the shader master came with THE solution, just add -DGL_GLEXT_PROTOTYPES to CFLAGS.
Hail to the master! 😀
In GLSL we trust… 😎
May the shader be with you! 😀
Oh, that’s cool! A fix!
(Another fix is to not use Quadros, apparently.)
Not to nitpick, but I wrote that post, and I’m definitely not a guy. :p
I’m glad to see that you have found a solution reading my post. 🙂
I’ve also corrected it, now refers correctly to a forum thread written by a girl. 😉
Hey, thank you for this post, I was fighting with this problem all day 😛
Thank you very much!