ugui.c3l/text_rendering/font_vertshader.glsl

27 lines
753 B
Plaintext
Raw Normal View History

2023-02-21 22:05:28 +01:00
#version 330 core
// viewsize.x = viewport width in pixels; viewsize.y = viewport height in pixels
2023-02-22 21:39:29 +01:00
uniform ivec2 viewsize;
uniform ivec2 texturesize;
2023-02-21 22:05:28 +01:00
2023-02-22 21:39:29 +01:00
// both position and and uv are in pixels, they where converted to floats when
// passed to the shader
2023-02-21 22:05:28 +01:00
layout(location = 0) in vec2 position;
2023-02-22 21:39:29 +01:00
layout(location = 1) in vec2 txcoord;
2023-02-21 22:05:28 +01:00
2023-02-22 21:39:29 +01:00
out vec2 uv;
2023-02-21 22:05:28 +01:00
void main()
{
2023-02-23 01:23:21 +01:00
vec2 v = vec2(float(viewsize.x), float(viewsize.y));
2023-02-23 23:39:34 +01:00
// vec2 p = vec2(position.x*2.0f/v.x - 1.0f, position.y*2.0f/v.y - 1.0f);
vec2 p = vec2(position.x*2.0/v.x - 1.0, 1.0 - position.y*2.0/v.y);
2023-02-23 01:23:21 +01:00
vec4 pos = vec4(p.x, p.y, 0.0f, 1.0f);
2023-02-21 22:05:28 +01:00
gl_Position = pos;
2023-02-23 23:39:34 +01:00
// since the texture is a GL_TEXTURE_RECTANGLE the coordintes do not need to
// be normalized
uv = vec2(txcoord.x, txcoord.y);
2023-02-21 22:05:28 +01:00
}