@dimitre wrote:
I'm asking for an advice. I'm writing inline shaders this way in OFW.
Nice thing is you can actually read the multiline code.
Is there any downside of this kind of string declaration? maybe doesn't work on some compilers?
Thank youstring vertShader = R"( varying vec2 texcoord0; void main() { gl_Position = ftransform(); texcoord0 = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0); } )"; string fragShader = R"( uniform int x, y, w, h; uniform sampler2DRect tex0; uniform sampler2DRect mask0; varying vec2 texcoord0; void main (void) { vec4 cor = texture2DRect(tex0, texcoord0); // vec4 cor = texture2DRect(tex0, texcoord0).rgb; // cor.a = texture2DRect(mask0, texcoord0).r; vec2 xy = gl_FragCoord.xy; int xx = int(xy.x); int yy = int(xy.y); bool limpa = false; if (xx > x && yy > y) { if (xx < (x+w) && yy < (y+h)) { limpa = true; } } gl_FragColor = limpa ? vec4(0.0, 0.0, 0.0, 0.0) : cor; } )";
Posts: 3
Participants: 3