# GLSL associating multiple uniform samplerBuffers

At the moment I'm not sure how my VBO and TBO associate with a specific uniform samplerBuffer in my shader, I have not linked them using the location or the vbo/tbo together. It seems to still work though, but now that I am using multiple samplerBuffers, how do I establish to link between a specific TBO and the uniform. Do I need to use glUniformX?

For VBOs you don't use uniforms, but to deference them you use shader attributes instead.

Regarding Texture buffer objects (TBO) you can bind their uniform location in the shader,

layout (binding = 0) uniform sampler2D tex_object;


You can also get its location using glGetUniformLocation and then set the TBO uniform value using glUniformi( location, tbo).

Inorder to tie VBO and TBO together use glTexBuffer

// Attach the VBO to TBO.
glGenTextures(1, &tbo);
glBindTexture(GL_TEXTURE_BUFFER, tbo);
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, vbo);

• Yes, I was wondering how the uniform knows which TBO to use, so glUniformi using the TBO as the id makes sense to me now, thanks! – Luka Mar 4 '14 at 12:35
• Actually, using TBO (for glUniform1i) seems to break it. Is it because I'm not doing something properly? – Luka Mar 4 '14 at 12:54
• I usually use layout (binding = 0) you can also use glGetUniformLocation to make sure it's the correct location. glUniformi should work for samples, I am not sure what is wrong. – concept3d Mar 4 '14 at 12:57