# Multiple mains in vertex shader, GLSL

I have a renderer where you can define passes where you pick the shader, and a signal, each object can register a listener to that signal in order to draw himself, the problem comes when some objects are normal meshes, others are sprites, some have skeletal animations, some don't. I was wondering if I could pack within the same vertex shader many different optional main functions, and pick the correct one for each object.

If there is no way, I would have to compile a different shader for each of the types and bind it from zero for all objects, even though all fragment shaders are the same.

No, I don't believe there's any way to have different main() functions in one shader. But you do have a few options. You could pass in a uniform that the main() function uses to decide which other function to call. Something like this:

uniform int shaderType;

{
// ... do whatever you need for the first shader type
}

{
// ... do whatever you need for the second shader type
}

{
// ... etc.
}

void main()
{
vec4 result;
{
}
{
}