Debian Codegraph @

src/base_rendering/glsl/source/image.vs

raw
1 attribute vec2 vertex;
2 attribute vec2 tex_coord;
3
4 /* Note that passing viewport_size (just 2 floats) removes the need to pass
5 a projection_matrix (16 floats).
6
7 We only pass a size of the context (width, height),
8 since we know that the viewport for 2D drawing is always the full context,
9 with coordinates matching pixels.
10 (TCastleWindow.EventRender even sets such projection matrix,
11 although we don't depend on it for TDrawableImage rendering after all.)
12 This allows us to simplify
13 gl_Position = projection_matrix * vec4(vertex, 0.0, 1.0);
14 because we know that the projection_matrix actually corresponds to
15 OrthoProjection(0, viewport_size.x, 0, viewport_size.y);
16 */
17 uniform vec2 viewport_size;
18 varying vec2 tex_coord_frag;
19
20 #ifdef CLIP_LINE
21 varying vec2 frag_coord;
22 #endif
23
24 /* Simple GLSL shader to apply 2D texture.
25 Must be suitable also for GLES20, so don't use any deprecated gl_Xxx
26 variables. */
27
28 void main(void)
29 {
30 gl_Position = vec4(vertex * 2.0 / viewport_size - vec2(1.0), 0.0, 1.0);
31 #ifdef CLIP_LINE
32 frag_coord = vertex;
33 #endif
34 tex_coord_frag = tex_coord;
35 }