proper glUniform use

Started by
9 comments, last by krienie 12 years, 7 months ago

[quote name='phantom' timestamp='1314227924' post='4853441']
[quote name='Murdocki' timestamp='1314209993' post='4853319']
[font="Arial"]You probably misinterpreted the "not changing frequently" part, uniforms are described as not changing frequently because they're the same for the whole draw call unlike vertex attributes which change every vertex. [/font]


The term 'not changing frequently' applies just as well to something you set once during all your draw calls in a scene as it would to per-object.

In fact if your MVP matrix is only set once and never update during a scene/frame render setting it multiple times per scene/frame is wasteful and something which should be avoided (CPU time and GPU time overhead).

Now, I'm not saying there IS a way to use GLSL like that, although I hope there is because if not then that's a *facepalm* right there, but there really should be a way of doing it. My GLSL is just too rusty right now to point out that method if it exists :)
[/quote]

Of course there is. UBO = Uniform buffer object
Which is basically a VBO for uniform values.
You need to make a GL 3.1 context to use it. Just shuv a GL_UNIFORM_BUFFER into your VBO function calls and get the location from your shader object.
http://www.opengl.or...entation/specs/

and you update the whole fucking uniform block inluding your MVP matrix in one go.
[/quote]


Now this is interesting! I'm totally going to check this out. Thank you very much! :)

This topic is closed to new replies.

Advertisement