3
\$\begingroup\$

I'm doing a small direct3d11 project for "fun". I know d3d11 quite well but not really any opengl. My program is designed for d3d11 but I would like it to be easy to port to opengl at some point so I'm trying to keep to abstractions that are somewhat portable. The concepts of vertex buffer, index buffers, vertex shaders, pixel shaders, and some form of input layout structures all seem to map pretty well.

But what about constant buffers? all of the examples I see of opengl shaders have code getting "pointers" to named variables in the shader and setting them whereas my code for d3d11 just creates a big c++ struct and copies it into a constant buffer. This then maps directly to a cbuffer in the shader.

Does the same concept exist in opengl? I've been unable to find it with any quick searches. Or do I have to set named variables only?

\$\endgroup\$
  • 1
    \$\begingroup\$ Could this be it? opengl.org/wiki/Uniform_Buffer_Object \$\endgroup\$ – teodron Sep 3 '13 at 8:02
  • \$\begingroup\$ That looks exactly like it, thank you. The problem sometimes is knowing what to search for when you don't know what something is called in opengl. Please put it as an answer I can accept. \$\endgroup\$ – JohnB Sep 3 '13 at 8:04
5
\$\begingroup\$

The OpenGL most closest equivalent of constant buffers might be the Uniform Buffer Object.

More details in the link above.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.