summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
Diffstat (limited to 'data')
-rw-r--r--data/Makefile.am5
-rw-r--r--data/shaders/sprite-fragment.glsl8
-rw-r--r--data/shaders/sprite-vertex.glsl26
3 files changed, 39 insertions, 0 deletions
diff --git a/data/Makefile.am b/data/Makefile.am
index 552da87..b6d0d74 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,2 +1,7 @@
fontsdir = $(pkgdatadir)/fonts
fonts_DATA = fonts/DejaVuSans.ttf
+
+shadersdir = $(pkgdatadir)/shaders
+shaders_DATA = \
+ shaders/sprite-vertex.glsl \
+ shaders/sprite-fragment.glsl
diff --git a/data/shaders/sprite-fragment.glsl b/data/shaders/sprite-fragment.glsl
new file mode 100644
index 0000000..3dd10f1
--- /dev/null
+++ b/data/shaders/sprite-fragment.glsl
@@ -0,0 +1,8 @@
+#version 120
+
+uniform sampler2D color_texture;
+uniform vec4 color;
+
+void main (void) {
+ gl_FragColor = texture2D(color_texture, gl_TexCoord[0].st) * color;
+}
diff --git a/data/shaders/sprite-vertex.glsl b/data/shaders/sprite-vertex.glsl
new file mode 100644
index 0000000..d6efd3f
--- /dev/null
+++ b/data/shaders/sprite-vertex.glsl
@@ -0,0 +1,26 @@
+#version 120
+
+uniform mat4 projection;
+uniform vec2 position;
+uniform vec2 anchor;
+uniform vec2 scale;
+uniform float rotation;
+
+void main(void) {
+ mat4 rotationMatrix = mat4(cos(rotation), -sin(rotation), 0.0, 0.0,
+ sin(rotation), cos(rotation), 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
+ mat4 translationMatrix = mat4(1.0, 0.0, 0.0, position.x - anchor.x,
+ 0.0, 1.0, 0.0, position.y - anchor.y,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
+ mat4 scaleMatrix = mat4(scale.x, 0.0, 0.0, 0.0,
+ 0.0, scale.y, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
+
+ gl_Position = projection * (gl_Vertex * scaleMatrix *
+ rotationMatrix * translationMatrix);
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+}