I have a question for you. Does anyone have good examples with using UBO buffers? I checked LearnOpenGL.com but it does not have some examples with UBOs. I need them for multi-light sources setup because each uniform location are too complicated for many uniform variabes like multi-ligtht sources. I am using core profile v4.5. For example:
it gets a bit complicated when want to put structs into uniform blocks, see “std140” layout
then, you either need to “pad out” your cpp struct or you have to query memory alignments
you can bind a certain buffer to an “uniform block index” with: glBindBufferBase(…)
For more detail and examples, see an OpenGL tutorial describing buffer layouts, the OpenGL Spec, or the GLSL Spec. For instance, here’s a page link in the LearnOpenGL tutorial that describes it with examples (search down to std140):