-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Labels
Milestone
Description
I just played around with subroutines in glsl and already implemented basic info output in ofShader, like:
void printSubroutineNames( GLenum shadertype) const;
void printSubroutineUniforms( GLenum shadertype) const;
Since subroutine uniforms are handled completely different then normal uniforms I wanted to start a discussion on how to add them to the ofShader class.
Subroutines are part of the context state and not of the program object, which means every time we call something like glUseProgram the subroutine state is lost. Thus keeping internal track of shadertype ->subroutine uniform -> subroutine index mapping should be added and set every time begin() is called.
Here are just my thoughts on this, if the idea of adding subroutines isn't quashed.
- interface for the mapping:
void setSubroutineUniform( GLenum shadertype, string uniformName, string subroutineName ), internally the uniform location and subroutine index are cached as with the normal uniforms and the array we need forglUniformSubroutinesuivis updated accordingly. - call
glUniformSubroutinesuivin the begin function, like setUniformDefaults - check if there are subroutines after the program is created. If there are, query the necessary information and set default values.
Did I miss something beside that I have the feeling that it won't be used much?