diff options
Diffstat (limited to 'chickadee/render/shapes.scm')
-rw-r--r-- | chickadee/render/shapes.scm | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/chickadee/render/shapes.scm b/chickadee/render/shapes.scm index f7412e8..245bc51 100644 --- a/chickadee/render/shapes.scm +++ b/chickadee/render/shapes.scm @@ -58,9 +58,11 @@ (delay (strings->shader " -#version 130 - +#ifdef GLSL330 +layout (location = 0) in vec2 position; +#elif GLSL130 in vec2 position; +#endif uniform mat4 mvp; void main(void) { @@ -68,13 +70,17 @@ void main(void) { } " " -#version 130 - -in vec2 frag_tex; +#ifdef GLSL330 +out vec4 fragColor; +#endif uniform vec4 color; void main (void) { +#ifdef GLSL330 + fragColor = color; +#elif ifdef GLSL130 gl_FragColor = color; +#endif } "))) (mvp (make-null-matrix4))) @@ -133,22 +139,26 @@ void main (void) { (delay (strings->shader " -#version 130 - +#ifdef GLSL330 +layout (location = 0) in vec2 position; +layout (location = 1) in vec2 tex; +#elif ifdef GLSL130 in vec2 position; in vec2 tex; -out vec2 frag_tex; +#endif +out vec2 fragTex; uniform mat4 mvp; void main(void) { - frag_tex = tex; + fragTex = tex; gl_Position = mvp * vec4(position.xy, 0.0, 1.0); } " " -#version 130 - -in vec2 frag_tex; +in vec2 fragTex; +#ifdef GLSL330 +out vec4 fragColor; +#endif uniform vec4 color; uniform float r; uniform float w; @@ -159,8 +169,8 @@ float infinity = 1.0 / 0.0; void main (void) { float hw = w / 2.0; - float u = frag_tex.x; - float v = frag_tex.y; + float u = fragTex.x; + float v = fragTex.y; float dx; float dy; float d; @@ -204,9 +214,17 @@ void main (void) { } if (d <= hw) { +#ifdef GLSL330 + fragColor = color; +#elif ifdef GLSL130 gl_FragColor = color; +#endif } else { +#ifdef GLSL330 + fragColor = vec4(color.rgb, color.a * (1.0 - ((d - hw) / r))); +#elif ifdef GLSL130 gl_FragColor = vec4(color.rgb, color.a * (1.0 - ((d - hw) / r))); +#endif } } ")))) |