Jump to content

  • Log In with Google      Sign In   
  • Create Account


Uniform blocks and Uniform buffer objects


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Laval B   Crossbones+   -  Reputation: 4296

Like
0Likes
Like

Posted 04 July 2013 - 10:45 AM

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 ?

Edited by Laval B, 04 July 2013 - 10:47 AM.

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

Sponsor:

#2 Laval B   Crossbones+   -  Reputation: 4296

Like
2Likes
Like

Posted 04 July 2013 - 03:10 PM

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 ?


Edited by Laval B, 04 July 2013 - 03:11 PM.

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS