-
-
Notifications
You must be signed in to change notification settings - Fork 10
Embed GLSL
Swoosh can embed GLSL without strings; making it look completely natural and retaining your IDE syntax highlighting.
First add #include <Swoosh/EmbedGLSL.h>
to the top of your file.
This will export a macro definition GLSL(version, shader)
that returns std::string
. We'll use it to write the script. The first value is your GLSL version number.
e.g. #version 110
would become GLSL(110, ...)
.
After, we simply write our script as if it were another class.
auto CHECKERBOARD_FRAG_SHADER = GLSL
(
110,
uniform sampler2D texture;
uniform sampler2D pattern;
uniform float progress;
void main()
{
vec4 pixel = texture2D(texture, vec2(gl_TexCoord[0].xy));
vec4 transition = texture2D(pattern, vec2(gl_TexCoord[0].xy));
vec4 color = gl_Color * pixel;
if (progress >= transition.g) {
color = vec4(1, 1, 1, 0);
}
gl_FragColor = color;
}
);
One of the functions used in the macro uses C string functions that VS does not like. They are perfectly fine to use.
Press Alt-F7 or right click in solution explorer and select "Properties"
Then drop to Configurations:All Configurations
Click on the Preprocessor Definitions line to invoke its editor
Choose Edit...
Copy "_CRT_SECURE_NO_WARNINGS" into the Preprocessor Definitions white box on the top.
Get started here.