openframeworks / openframeworks/openFrameworks
OpenGL subroutines in ofShader
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing ofShader's existing uniform handling, especially begin() and setUniformDefaults, alongside the proposed subroutine methods. Clarify the intended interface and how subroutine state should be restored after glUseProgram; done means the project has an agreed design and corresponding implementation requirements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100