Exporting Functions within a Shader Program.
Hello all.
I'm currently trying to minimize Compile time and resources by reusing Shaders. My target is not GLSL 4+ with Subroutines, but, I do want to emulate multiple effects per Shader Program.
The Setup is:
- Shader Program
- Shader1
- Shader2
Assume Shader1 has function, "myfunc", and Shader2 wants to use it. Without adding the source code together and compiling it into one Shader Program, how do you 'import' per-se, the function in Shader2? I've seen on the good ol' interwebs that it could be:
Shader1:
Code :
void myfunc() {
// Do something
}
Shader2:
Code :
void myfunc();
void main() {
myfunc();
}
Then attaching the objects/linking the program. This, however, comes up as an error as:
Quote:
error C3002: call to undefined function "void myfunc();"
Any thoughts as to why this is happening?
- Dennis