There isn't a way to do that out of the box. But I imagine you could modify the layout function to indent heredoc that would start with a specific string. For example if you used:
| const char* fragmentShaderCode =
R"ShaderCode(
...
)ShaderCode";
|
You could probably (I haven't done it) detect the "ShaderCode(" and indent the string.
I use a different method: I added a meta programming step in my build system, that will parse shader files and produce a header that contains the shaders as C strings.
For example, the shader file I edit look like this:
| [name: vs_default]
in vec2 position;
in vec2 in_uv;
out vec2 out_uv;
void main( ) {
gl_Position = vec4( position, 0.0, 1.0 );
out_uv = in_uv;
}
|
The
[name: vs_default] defines the name the string will have in the C header.
This will output something like this:
| u8 vs_default[ ] =
"in vec2 position;\n"
"in vec2 in_uv;\n"
"out vec2 out_uv;\n"
"\n"
"void main( ) {\n"
" gl_Position = vec4( position, 0.0, 1.0 );\n"
" out_uv = in_uv;\n"
"}\n"
"\n";
|
The parser is really simple, it just a text search for
[name: , extract the name, and copy the bytes to the next
[name: or the end of the file. I added the
\n in the strings so that OpenGL shader compiler error will be easier to find.