summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/shaders/default-fragment.glsl5
-rw-r--r--sly/render/model.scm1
-rw-r--r--sly/render/shader.scm2
3 files changed, 7 insertions, 1 deletions
diff --git a/data/shaders/default-fragment.glsl b/data/shaders/default-fragment.glsl
index 21bb756..a447a79 100644
--- a/data/shaders/default-fragment.glsl
+++ b/data/shaders/default-fragment.glsl
@@ -3,7 +3,12 @@
in vec2 frag_tex;
uniform vec4 color;
uniform sampler2D color_texture;
+uniform bool use_texture;
void main (void) {
+ if(use_texture) {
gl_FragColor = texture2D(color_texture, frag_tex) * color;
+ } else {
+ gl_FragColor = color;
+ }
}
diff --git a/sly/render/model.scm b/sly/render/model.scm
index 8f83ed5..4d15dc5 100644
--- a/sly/render/model.scm
+++ b/sly/render/model.scm
@@ -155,6 +155,7 @@ CONTEXT."
;; TODO: Support user-defined uniforms.
(uniform-set! shader "mvp" (render-context-transform context))
(uniform-set! shader "color" color)
+ (uniform-set! shader "use_texture" (not (texture-null? texture)))
(glDrawElements (begin-mode triangles)
(mesh-length mesh)
(data-type unsigned-int)
diff --git a/sly/render/shader.scm b/sly/render/shader.scm
index f9949fa..9f80d2a 100644
--- a/sly/render/shader.scm
+++ b/sly/render/shader.scm
@@ -305,7 +305,7 @@ VERTEX-SHADER and FRAGMENT-SHADER."
"/shaders/default-vertex.glsl")
(string-append %pkgdatadir
"/shaders/default-fragment.glsl")
- '("mvp" "color")
+ '("mvp" "color" "use_texture")
'("position" "tex")))))
;;;