Quantcast
Viewing all articles
Browse latest Browse all 22230

GCC, stringification, and inline GLSL?

I'd like to declare GLSL shader strings inline using macro stringification:

#define STRINGIFY(A)  #Aconst GLchar* vert = STRINGIFY(#version 120\nattribute vec2 position;void main(){    gl_Position = vec4( position, 0.0, 1.0 );});

This builds and runs fine using VS2010 but fails to compile on gcc with:

error: invalid preprocessing directive #version

Is there a way to use stringification like this in a portable manner?

I'm trying to avoid per-line quotes:

const GLchar* vert = "#version 120\n""attribute vec2 position;""void main()""{""    gl_Position = vec4( position, 0.0, 1.0 );""}";

...and/or line continuation:

const GLchar* vert = "\#version 120\n                                 \attribute vec2 position;                       \void main()                                    \{                                              \    gl_Position = vec4( position, 0.0, 1.0 );  \}                                              \";

Viewing all articles
Browse latest Browse all 22230

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>