I’m in the process of creating a GUI system in openGL that makes use of vertexes to create a flat rectangle on which to render my interface boxes.
I am attempting to work towards openGL 3.1 compliance by using VBOs however have a question. Which method of updating rectangle positions would you think is more efficient/correct?
When a parent box moves containing child boxes, should the parent box update a translate matrix and upload it to the shader program via glUniform (I think I’m correct in saying this is how it works in ogl3.1)
Should I update the VBOs of the child boxes to contain the new absolute co-ordinates?
IMO (2) is reasonable. Transform your 2D scene graph on the CPU. Unless your UI is really complex this usually amounts to a single, parent-relative translation, which you can simply fold into your vertex buffer as you go.
In general lots of shader variable updates are going to put a hurt on your perf.
I was thinking that may be the case but was unsure, many thanks.
On a side note then how were matrices implemented in OGL2.1? Most people translate between models, were they just implemented as uniforms underneath or is there a faster method. Would storing them in a general buffer be faster - or does it take longer to read those… I’m guessing uniforms are cached closer to the shader cores.