Uniform blocks and Uniform buffer objects

Started by
0 comments, last by Laval B 10 years, 10 months ago

Hello everyone.

I'm thinking about how i would implement a parameter system using OpenGL 3.2+ (core profile) and GLSL. I'm talking about uniform (not including samplers) and not vertex attributes. I'm leaning toward using UBOs and uniform blocks in shaders. Here are a few of points i'm not sure about.

  1. I'm planning to use only one big UBO which will contain all the parameters for all uniform blocks in all programs, specific parameters being updated using an appropriate call to glBufferSubData. So, all uniform blocks a program uses would be associated to the same uniform binding point, let's say 0, using glUniformBlockBinding and glBindBufferRange. Another interesting thing about using only one UBO is that i can bind this UBO at load time and keep it bound during rendering (no need to bind an UBO every time i need to update a parameter). Is it that correct and is there any problem with this method ?
  2. Since association happens only at initialization time, the uniform block index returned by glGetUniformBlockIndex doesn't need to be kept into a variable assuming this association doesn't change, correct ?
We think in generalities, but we live in details.
- Alfred North Whitehead
Advertisement

Ok, i think i figured it out. I can't use only one binding point, i need to have one for each uniform block. But i can use only one ubo and bind different part of the ubo to each uniform block using glBindBufferRange.

I still have one question though, must i call glGetUniformBlockIndex and glUniformBlockBinding after the program has been linked ?

We think in generalities, but we live in details.
- Alfred North Whitehead

This topic is closed to new replies.

Advertisement