PDA

View Full Version : Setting GLSL binding "layout(binding=x) uniform.." from program



jonasstrandstedt
11-28-2014, 06:42 AM
Hi,

I have tried figuring out if it is possible to get or redefine the binding position for uniforms in shaders? According to https://www.opengl.org/wiki/Layout_Qualifier_%28GLSL%29#Binding_points it sounds like it could be redefined.
This only sets the initial value; source code can modify it later.

The reason I want to do it is because before the current shader there might be different amounts of binded textures and it would be easier to either use layout without binding and bind to the first available position or simply setting from the program without having to remember what was specified in the shader.



// compute shader
layout (rgba32f, binding=1) writeonly uniform image2D out_image;




// opengl binding
glUniformBlockBinding(*shader, uniform_position, 0); // I have tried this to set the binding position, not working
glShaderStorageBlockBinding(*shader, uniform_position, 0); // I have tried this to set the binding position, not working
glBindImageTexture(0, *_outputTexture, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F); // If I unit change to 1 it is working, in other words, it has not been changed.