With c++11, you can also use the new feature of raw string literals. Put this source code in a separate file named shader.vs:
R"(
#version 420 core
void main(void)
{
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
}
)"
and then import it as a string like this:
const std::string vs_source =
#include "shader.vs"
;
The advantage is that its easy to maintain and debug, and you get correct line numbers in case of errors from the OpenGL shader compiler. And you still don’t need to ship separate shaders.
The only disadvantage I can see is the added lines on the top and bottom of the file (R") and )") and the syntax that is a little bit strange for getting the string into C++ code.