• Create Account

### #ActualOlof Hedman

Posted 11 October 2012 - 01:06 AM

A different way to do with with macro magic is something like:

Yep, that's pretty much what Olof Hedman and I were talking about, should work just fine.

Yep. I like my suggestion (and mhagain's) better though, that is to re-define the main function name.
That way you don't have to clutter your source file with #ifdefs, and the other main should be removed at link time.

### #1Olof Hedman

Posted 11 October 2012 - 01:06 AM

A different way to do with with macro magic is something like:

#ifdef COMPILING_VERTEX_SHADER

void main()
{}

#endif

void main()
{}

#endif


Source File.cpp
std::string fileContents = fileToString("Shader.glsl"); // load it as a string
std::string compilingString = "#define COMPILNG_VERTEX_SHADER\n" + fileContents;
compilingString = "#define COMPILING_FRAGMENT_SHADER\n" + fileContents;