summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-02-17 20:36:38 -0500
committerDavid Thompson <dthompson2@worcester.edu>2023-06-08 08:14:41 -0400
commit7f3e6de476b5eeccfa6acfdb8b644fe6fe6d0652 (patch)
tree30815804a8e615b12657339c555cd182ed4014d6
parentb4ed69fedd7aa5e9b7eb04e5f18f85e7019dc68e (diff)
Rename texture-2d to texture.
-rw-r--r--chickadee/graphics/9-patch.scm5
-rw-r--r--chickadee/graphics/particles.scm76
-rw-r--r--chickadee/graphics/path.scm2
-rw-r--r--chickadee/graphics/seagull.scm8
-rw-r--r--chickadee/graphics/sprite.scm81
5 files changed, 18 insertions, 154 deletions
diff --git a/chickadee/graphics/9-patch.scm b/chickadee/graphics/9-patch.scm
index eac688d..308cd65 100644
--- a/chickadee/graphics/9-patch.scm
+++ b/chickadee/graphics/9-patch.scm
@@ -40,6 +40,7 @@
(define-graphics-variable 9-patch-model-matrix (make-null-matrix4))
(define-graphics-variable 9-patch-mvp-matrix (make-null-matrix4))
(define-graphics-variable 9-patch-margins (make-null-rect))
+
(define-vertex-shader 9-patch-vertex
((in vec2 position)
(in vec2 distance)
@@ -48,6 +49,7 @@
(outputs
(vertex:position (* mvp (vec4 (-> position x) (-> position y) 0.0 1.0)))
(frag-distance distance)))
+
(define-fragment-shader 9-patch-fragment
((in vec2 frag-distance)
(out vec4 frag-color)
@@ -84,7 +86,8 @@
height
(-> subtexture w))))))
(outputs
- (frag-color (* (texture-2d color-texture texcoord) tint)))))
+ (frag-color (* (texture color-texture texcoord) tint)))))
+
(define-graphics-variable 9-patch-shader
(compile-shader 9-patch-vertex 9-patch-fragment))
diff --git a/chickadee/graphics/particles.scm b/chickadee/graphics/particles.scm
index 6801c39..c9dd532 100644
--- a/chickadee/graphics/particles.scm
+++ b/chickadee/graphics/particles.scm
@@ -127,82 +127,10 @@ indefinitely."
(uniform vec4 end-color))
(outputs
(frag-color (* (mix end-color start-color frag-t)
- (texture-2d color-texture frag-tex)))))
+ (texture color-texture frag-tex)))))
(define-graphics-variable particles-shader
- (compile-shader particles-vertex particles-fragment)
-;; (strings->shader
-;; "
-;; #ifdef GLSL330
-;; layout (location = 0) in vec2 position;
-;; layout (location = 1) in vec2 tex;
-;; layout (location = 2) in vec2 offset;
-;; layout (location = 3) in vec2 velocity;
-;; layout (location = 4) in vec2 acceleration;
-;; layout (location = 5) in float life;
-;; #elif defined(GLSL130)
-;; in vec2 position;
-;; in vec2 tex;
-;; in vec2 offset;
-;; in vec2 velocity;
-;; in vec2 acceleration;
-;; in float life;
-;; #elif defined(GLSL120)
-;; attribute vec2 position;
-;; attribute vec2 tex;
-;; attribute vec2 offset;
-;; attribute vec2 velocity;
-;; attribute vec2 acceleration;
-;; attribute float life;
-;; #endif
-;; #ifdef GLSL120
-;; varying vec2 fragTex;
-;; varying float t;
-;; #else
-;; out vec2 fragTex;
-;; out float t;
-;; #endif
-;; uniform mat4 mvp;
-;; uniform int lifetime;
-;; uniform int animationRows;
-;; uniform int animationColumns;
-
-;; void main(void) {
-;; t = life / lifetime;
-;; int numTiles = animationRows * animationColumns;
-;; int tile = int(numTiles * (1.0 - t));
-;; float tx = float(mod(tile, animationColumns)) / animationColumns;
-;; float ty = float(tile / animationColumns) / animationRows;
-;; float tw = 1.0 / animationColumns;
-;; float th = 1.0 / animationRows;
-;; fragTex = vec2(tx, ty) + tex * vec2(tw, th);
-;; gl_Position = mvp * vec4(position.xy + offset, 0.0, 1.0);
-;; }
-;; "
-;; "
-;; #ifdef GLSL120
-;; varying vec2 fragTex;
-;; varying float t;
-;; #else
-;; in vec2 fragTex;
-;; in float t;
-;; #endif
-;; #ifdef GLSL330
-;; out vec4 fragColor;
-;; #endif
-;; uniform sampler2D color_texture;
-;; uniform vec4 startColor;
-;; uniform vec4 endColor;
-
-;; void main (void) {
-;; #ifdef GLSL330
-;; fragColor = mix(endColor, startColor, t) * texture(color_texture, fragTex);
-;; #else
-;; gl_FragColor = mix(endColor, startColor, t) * texture2D(color_texture, fragTex);
-;; #endif
-;; }
-;; ")
- )
+ (compile-shader particles-vertex particles-fragment))
(define-graphics-variable mvp-matrix (make-null-matrix4))
diff --git a/chickadee/graphics/path.scm b/chickadee/graphics/path.scm
index 63a8049..9c177b5 100644
--- a/chickadee/graphics/path.scm
+++ b/chickadee/graphics/path.scm
@@ -1282,7 +1282,7 @@
(-> color z)
(* (-> color w)
(- 1.0 (/ (- d hw) feather)))))))
- (if (<= (-> color w) 0.0)
+ (if (<= (-> color* w) 0.0)
(outputs)
(outputs
(frag-color color*))))))
diff --git a/chickadee/graphics/seagull.scm b/chickadee/graphics/seagull.scm
index 8c1fcd6..23cb7af 100644
--- a/chickadee/graphics/seagull.scm
+++ b/chickadee/graphics/seagull.scm
@@ -127,7 +127,7 @@
#f)
(define (fragment-primitive-call? x)
- (memq x '(texture-2d)))
+ (memq x '(texture)))
(define (primitive-call? x stage)
(or (binary-operator? x)
@@ -2194,7 +2194,7 @@
(predicate:= a type:int)
(predicate:= a type:float)
(predicate:= a type:vec4)))))))
- (define type:texture-2d
+ (define type:texture
(list (function-type (list type:sampler-2d type:vec2)
(list type:vec4))))
`((+ . ,type:+/-)
@@ -2232,7 +2232,7 @@
(vertex:clip-distance ,type:float)))
((fragment)
`((fragment:depth ,type:float)
- (texture-2d . ,type:texture-2d))))))
+ (texture . ,type:texture))))))
;; TODO: Add some kind of context object that is threaded through the
;; inference process so that when a type error occurs we can show the
@@ -2544,7 +2544,7 @@
(define %primcall-map
'((float->int . int)
(int->float . float)
- (texture-2d . texture2D)))
+ (texture . texture)))
(define (emit:primcall type operator args stage version port level)
(define operator*
diff --git a/chickadee/graphics/sprite.scm b/chickadee/graphics/sprite.scm
index f2fcfe4..118c572 100644
--- a/chickadee/graphics/sprite.scm
+++ b/chickadee/graphics/sprite.scm
@@ -56,6 +56,7 @@
(make-geometry <sprite-vertex> 4 #:index-capacity 6))
(define-graphics-variable sprite-model-matrix (make-null-matrix4))
(define-graphics-variable sprite-mvp-matrix (make-null-matrix4))
+
(define-vertex-shader sprite-vertex
((in vec2 position)
(in vec2 tex)
@@ -64,13 +65,14 @@
(outputs
(vertex:position (* mvp (vec4 (-> position x) (-> position y) 0.0 1.0)))
(frag-tex tex)))
+
(define-fragment-shader sprite-fragment
((in vec2 frag-tex)
(out vec4 frag-color)
- (uniform sampler-2d texture)
+ (uniform sampler-2d color-texture)
(uniform vec4 tint))
(outputs
- (frag-color (* (texture-2d texture frag-tex) tint))))
+ (frag-color (* (texture color-texture frag-tex) tint))))
(define-graphics-variable sprite-shader
(compile-shader sprite-vertex sprite-fragment))
@@ -173,86 +175,17 @@ BLEND-MODE."
(vertex:position (* mvp (vec4 (-> position x) (-> position y) 0.0 1.0)))
(frag-tex tex)
(frag-tint tint)))
-;; #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
-;; }
(define-fragment-shader sprite-batch-fragment
((in vec2 frag-tex)
(in vec4 frag-tint)
(out vec4 frag-color)
- (uniform sampler-2d texture))
+ (uniform sampler-2d color-texture))
(outputs
- (frag-color (* (texture-2d texture frag-tex) frag-tint))))
+ (frag-color (* (texture color-texture frag-tex) frag-tint))))
+
(define-graphics-variable sprite-batch-shader
(compile-shader sprite-batch-vertex sprite-batch-fragment))
-;; (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
-;; }
-;; "))
(define-record-type <sprite-batch>
(%make-sprite-batch texture geometry size)