Possible Duplicate:
C/C++, can you #include a file into a string literal?
Is it possible to get the entire contents of a text file as a string at compile time using C++11 raw string literals?
Basically, I want to be able to embed GLSL shader source files without having to modify them.
The following approach is suggested here:
const std::string shaderSource = R"glsl(
#include "my_shader.glsl"
)glsl";
It's hacky, but it'd be fine for my application. However, this doesn't seem to work due to raw string literals being evaluated before file inclusion.
I suppose I could move the 'R"glsl('
and ')glsl"'
parts to the beginning and end of each shader source file instead, and then just do this:
const std::string shaderSource =
#include "my_shader.glsl"
;
But like I said, I'd really prefer not having to modify the shader source files as that would complicate run-time loading of the same files and therefore make them less portable.