openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.98k stars 2.55k forks source link

[idea / wip] - ofShader::setUniformBufferObject to easily pass a struct to a shader #8097

Open dimitre opened 2 months ago

dimitre commented 2 months ago

relevant discussion: https://forum.openframeworks.cc/t/multiple-lights-limit-with-opengl-3-2-how-to-increase/43777/26

usage example:

shader.setUniformBufferObject("vars", &customVars, sizeof(customVars));

PS: not static yet

What do you think @NickHardeman ?

NickHardeman commented 2 months ago

Should probably be wrapped in the defines next to getUniformBlockIndex, getUniformBlockBinding, etc. I don't have much experience with Uniform Blocks, so would be good to test with openGL ES. Testing with Emscripten would be helpful. Could be wrapped in

#if !defined(TARGET_OPENGLES) || defined(TARGET_EMSCRIPTEN)
#ifdef GLEW_ARB_uniform_buffer_object