summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/graphics/sprite.scm126
1 files changed, 31 insertions, 95 deletions
diff --git a/chickadee/graphics/sprite.scm b/chickadee/graphics/sprite.scm
index 29c1088..b2663cf 100644
--- a/chickadee/graphics/sprite.scm
+++ b/chickadee/graphics/sprite.scm
@@ -56,50 +56,20 @@
(define-graphics-variable sprite-model-matrix (make-null-matrix4))
(define-graphics-variable sprite-mvp-matrix (make-null-matrix4))
(define-graphics-variable sprite-shader
- (strings->shader
- "
-#ifdef GLSL330
-layout (location = 0) in vec2 position;
-layout (location = 1) in vec2 tex;
-#elif defined(GLSL130)
-in vec2 position;
-in vec2 tex;
-#elif defined(GLSL120)
-attribute vec2 position;
-attribute vec2 tex;
-#endif
-#ifdef GLSL120
-varying vec2 fragTex;
-#else
-out vec2 fragTex;
-#endif
-uniform mat4 mvp;
-
-void main(void) {
- fragTex = tex;
- gl_Position = mvp * vec4(position.xy, 0.0, 1.0);
-}
-"
- "
-#ifdef GLSL120
-varying vec2 fragTex;
-#else
-in vec2 fragTex;
-#endif
-#ifdef GLSL330
-out vec4 fragColor;
-#endif
-uniform sampler2D colorTexture;
-uniform vec4 tint;
-
-void main (void) {
-#ifdef GLSL330
- fragColor = texture(colorTexture, fragTex) * tint;
-#else
- gl_FragColor = texture2D(colorTexture, fragTex) * tint;
-#endif
-}
-"))
+ (make-shader*
+ ((in vec2 position)
+ (in vec2 tex)
+ (out vec2 fragTex)
+ (uniform mat4 mvp)
+ (define (void main)
+ (= fragTex tex)
+ (= gl_Position (* mvp (vec4 (-> position xy) 0.0 1.0)))))
+ ((in vec2 fragTex)
+ (out vec4 fragColor)
+ (uniform sampler2D colorTexture)
+ (uniform vec4 tint)
+ (define (void main)
+ (= fragColor (* (texture colorTexture fragTex) tint))))))
(define* (draw-sprite* texture
rect
@@ -189,57 +159,23 @@ BLEND-MODE."
(tint vec4))
(define-graphics-variable sprite-batch-shader
- (strings->shader
- "
-#ifdef GLSL330
-layout (location = 0) in vec2 position;
-layout (location = 1) in vec2 tex;
-layout (location = 2) in vec4 tint;
-#elif defined(GLSL130)
-in vec2 position;
-in vec2 tex;
-in vec4 tint;
-#elif defined(GLSL120)
-attribute vec2 position;
-attribute vec2 tex;
-attribute vec4 tint;
-#endif
-#ifdef GLSL120
-varying vec2 fragTex;
-varying vec4 fragTint;
-#else
-out vec2 fragTex;
-out vec4 fragTint;
-#endif
-uniform mat4 mvp;
-
-void main(void) {
- fragTex = tex;
- fragTint = tint;
- gl_Position = mvp * vec4(position.xy, 0.0, 1.0);
-}
-"
- "
-#ifdef GLSL120
-varying vec2 fragTex;
-varying vec4 fragTint;
-#else
-in vec2 fragTex;
-in vec4 fragTint;
-#endif
-#ifdef GLSL330
-out vec4 fragColor;
-#endif
-uniform sampler2D colorTexture;
-
-void main (void) {
-#ifdef GLSL330
- fragColor = texture(colorTexture, fragTex) * fragTint;
-#else
- gl_FragColor = texture2D(colorTexture, fragTex) * fragTint;
-#endif
-}
-"))
+ (make-shader*
+ ((in vec2 position)
+ (in vec2 tex)
+ (in vec4 tint)
+ (out vec2 fragTex)
+ (out vec4 fragTint)
+ (uniform mat4 mvp)
+ (define (void main)
+ (= fragTex tex)
+ (= fragTint tint)
+ (= gl_Position (* mvp (vec4 (-> position xy) 0.0 1.0)))))
+ ((in vec2 fragTex)
+ (in vec4 fragTint)
+ (out vec4 fragColor)
+ (uniform sampler2D colorTexture)
+ (define (void main)
+ (= fragColor (* (texture colorTexture fragTex) fragTint))))))
(define-record-type <sprite-batch>
(%make-sprite-batch texture geometry size)