Well it took me about a week to get to the bottom of that.
Lat week I found that if I uploaded a raster to the graphics card and saved it in a buffer, then I set a single uniform float variable to request the zoom level I wanted on rendering, the render was blank. Was the buffer corrupting the uniform variables? Was something overwriting the uniform variables? Was the shader failing to compile and not bothering to tell me? After about a week of looking at absolutely everything and wondering how one render could possibly bugger up another completely separate render, it turned out that in these circumstances setting the zoom level as a simple uniform float variable was being ignored by the shader altogether and it was always setting the zoom to zero. Apparently glUniform1f
doesn’t always work and apparently this has been known for years. Well not to me it wasn’t.
So, if you ever find that you’re setting of a single float uniform variable is being ignored by your shader, this is what you do. Get a bunch of your float-typed uniforms and stick them in a vector or matrix. As it happens I am setting the datum in a vec2
so I bolted the zoom factor onto this making a vec3
. You set this using glUniform3f
which for some reason behaves.
Bonkers.