summaryrefslogtreecommitdiff
path: root/data/shaders/path-stroke-vert.glsl
blob: f1c7e3a3ff34cfaa780984d36d4917765af33e1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// -*- 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

#ifdef GLSL120
uniform mat4 mvp;
uniform vec4 color;
uniform int mode;
uniform int strokeClosed;
#else
layout (std140) uniform Stroke
{
  mat4 mvp;
  vec4 color;
  float feather;
  float strokeWidth;
  float strokeMiterLimit;
  int strokeClosed;
  int strokeCap;
  int strokeMiterStyle;
};
#endif

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);
  } else {
    fragStrokeLength = strokeLength;
    fragTex = tex;
    gl_Position = mvp * vec4(position.xy, 0.0, 1.0);
  }
}