Combining vertex and fragment shaders inside GLSL

I’m planning to completely switch from NVIDIA Cg to OpenGL GLSL, converting a few shaders in the process.

Converting the shaders themselves seems quite straight forward. Unfortunately, GLSL isn’t quite as crafty when it comes to combining fragment and vertex shaders, as it only supports one main function.

I really despise calling multiple render passes from inside my game code, however. Is there any more straight forward way to iterating through multiple passes than this? Preferably one where I’d just call the fragment shader after the vertex pass is finished?

With GLSL, it is not possible to have more than one shader program in one source file.

The shaders are still linked together into a single program after compilation, though. Panda compiles the shaders, links them together into a single program, and binds it before rendering the model.

I don’t really see what that has to do with calling multiple render passes; that is an altogether unrelated concept.


The thing is, how would I convert a single cg shader into multiple (one vertex, one fragment) shaders and use them without doing a rewrite of the game code?

Take the Cartoon-Shader-Advanced sample, for example. With cg, I just load lightingGen.sha. With GLSL though, I’d have to pass through a prospective lightingGenV.sha and, after that lightingGenF.sha. Would there be any way to tell lightingGenV.sha to access lightingGenF.sha after finishing?

EDIT: Never mind. Just found a piece of documentation which helped me quite a bit. Didn’t know you could load vertex, fragment and geometry shaders in a single procedure call.
I thought I’d have to manually link them somehow.