Is it somehow possible to have multiple entry points in a single shader?
CG has the feature, and it is very convenient, to keep several shaders related to the same effect in one file. I have not been able to find any documentation on how to do it?
What you want can be done in a different way in glslang. A cleaner way.
A compiled shader is like a .o file. It doesn’t need to have a main() in it. It can just have some common functions. At link-time, (program building), you can link together multiple compiled shaders, one of which has a main() function. So, effectively, you can have a few shader files that you use as libraries that you link into the final program building section.
First, Korval is exactly right. All “main()” vertex or fragment shaders can be compiled as separate shader objects. You attach whichever main shader object you wish to a program object, and then link. The disadvantage is that requires the application to split up the “single text file” into multiple parts.
Another approach is to pass your “single text file” as the second string to glShaderSourceARB. (Remember, it takes an array of pointers to strings.) Let’s say your “single text file” contains the string