1
\$\begingroup\$

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?

\$\endgroup\$
1
\$\begingroup\$

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);
\$\endgroup\$
  • \$\begingroup\$ 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! \$\endgroup\$ – Luka Mar 4 '14 at 12:35
  • \$\begingroup\$ Actually, using TBO (for glUniform1i) seems to break it. Is it because I'm not doing something properly? \$\endgroup\$ – Luka Mar 4 '14 at 12:54
  • \$\begingroup\$ 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. \$\endgroup\$ – concept3d Mar 4 '14 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.