Skip to content

OpenGL subroutines in ofShader  #3886

@patrickFuerst

Description

@patrickFuerst

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 for glUniformSubroutinesuiv is updated accordingly.
  • call glUniformSubroutinesuiv in 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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions