Yesterday I briefly tried out Philip Rideout’s very nice Shader Wrangler (click the link for full details). I tried to make a couple of changes to allow combining of shaders using several effect keys like this
shaders.Shared+shaders.Vertex
which will combine “Shared” and “Vertex” both from within the file named “shaders” (they don’t have to be from the same file)
I’ve added two methods for doing this, not sure which one is best yet. glswGetShaders returns the final combined string.glswGetShadersAlt is passed a char** and a maximum size for the array and returns the number of effects that matched.
const char* pStr[2] = {0,0};
int got = glswGetShadersAlt("shaders.Shared+shaders.Vertex", pStr, 2);
const char* pV2 = glswGetShaders("shaders.Shared+shaders.Vertex2");
The first method is appealing as it is the most simple, but results is some wasted data internal to glsw.c. The second method doesn’t have any wasted data and the char** and the returned number of matching effect files can be passed to glShaderSource as they are.
Of course it’s not too difficult to do this outside of the default shader wrangler, but if you like here are the modified glsw.c and glsw.h.