GCC, Stringifizierung und Inline-GLSL?
Ich möchte GLSL-Shader-Strings mithilfe der Makro-String-Kennzeichnung inline deklarieren:
#define STRINGIFY(A) #A
const GLchar* vert = STRINGIFY(
#version 120\n
attribute vec2 position;
void main()
{
gl_Position = vec4( position, 0.0, 1.0 );
}
);
Dies wird mit VS2010 problemlos erstellt und ausgeführt, kann jedoch nicht kompiliert werdengcc
mit:
error: invalid preprocessing directive #version
Gibt es eine Möglichkeit, eine solche Stringifizierung portabel einzusetzen?
Ich versuche, Anführungszeichen pro Zeile zu vermeiden:
const GLchar* vert =
"#version 120\n"
"attribute vec2 position;"
"void main()"
"{"
" gl_Position = vec4( position, 0.0, 1.0 );"
"}"
;
... und / oder Zeilenfortsetzung:
const GLchar* vert = "\
#version 120\n \
attribute vec2 position; \
void main() \
{ \
gl_Position = vec4( position, 0.0, 1.0 ); \
} \
";