I have a generic GLSLShader class which has protected functions which make the Allegro API calls to set various uniforms for shaders:
I then call these functions from the constructor and/or render method of a subclass that composites a specific shader's source code and compiled shader object:
Shader source:
These function wrappers work fine and my bitmap is rendered correctly when I use the wrapper functions where the uniforms are passed in to Allegro's shader API calls by pointer, however all functions like set_shader_float where the uniforms are passed by value fail with the runtime error. I'm having trouble figuring out what specifically is going wrong because the output from the shader's log seems to be empty. Any suggestions as to what could be going wrong here?
In general, the API seems to work in one of Allegro's examples. Can you verify that you're actually using the correct shader source (e.g. if you change it to output a constant color it is correctly reflected in the outoput)?
Hi, sorry for the delay in my reply. I haven't had much time to work on my Allegro project this week but I think I've traced the bug down to a thread safety issue - the "render" method shown here is held by an object in one thread but is being called through a reference from another thread and I think that's why setting the uniforms is giving strange behavior - clearly OpenGL calls would not be thread safe. I'll try locking/mutexing this section for now and see if that works; ideally calls that alter the pipleline would not be made across threads at all but that's a TODO...:P