summaryrefslogtreecommitdiff
path: root/data/shaders/path-vert.glsl
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2020-08-28 07:16:51 -0400
committerDavid Thompson <dthompson2@worcester.edu>2020-11-18 15:05:25 -0500
commit9a5ef19d5971488de18539eaf68e35bf590a4c5e (patch)
tree564512b78a8acca80c9840e6057e5a8e75feb123 /data/shaders/path-vert.glsl
parent6de9470ff9a9ac87b391c7b51fa9986faf566d2d (diff)
render: Add vector path rendering module.
Diffstat (limited to 'data/shaders/path-vert.glsl')
-rw-r--r--data/shaders/path-vert.glsl44
1 files changed, 44 insertions, 0 deletions
diff --git a/data/shaders/path-vert.glsl b/data/shaders/path-vert.glsl
new file mode 100644
index 0000000..38fa5d2
--- /dev/null
+++ b/data/shaders/path-vert.glsl
@@ -0,0 +1,44 @@
+// -*- mode: c -*-
+
+#ifdef GLSL330
+layout (location = 0) in vec2 position;
+layout (location = 1) in vec2 tex;
+layout (location = 2) in float strokeLength;
+#elif defined(GLSL130)
+in vec2 position;
+in vec2 tex;
+in float strokeLength;
+#elif defined(GLSL120)
+attribute vec2 position;
+attribute vec2 tex;
+attribute float strokeLength;
+#endif
+
+#ifdef GLSL120
+varying vec2 fragTex;
+varying float fragStrokeLength;
+#else
+out vec2 fragTex;
+out float fragStrokeLength;
+#endif
+
+uniform mat4 mvp;
+uniform vec4 color;
+uniform int mode;
+uniform int strokeClosed;
+
+void main(void) {
+ // Short-circuit because the fragments will just be discarded anyway.
+ if (color.a <= 0.0) {
+ gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
+ return;
+ }
+
+ // Stroke specific setup.
+ if (mode == 1) {
+ fragStrokeLength = strokeLength;
+ }
+
+ fragTex = tex;
+ gl_Position = mvp * vec4(position.xy, 0.0, 1.0);
+}