Files
updated-radar/build/shaders/text.vert
2026-04-23 08:05:03 -07:00

28 lines
717 B
GLSL

/*
* MIT License
* Author: Mark Allyn
*
* text.vert — vertex shader for FreeType glyph-atlas text rendering.
* Each glyph is a textured quad. Vertices are in window pixels
* (top-left origin); the shader converts to NDC and passes the
* glyph atlas UV coordinates to the fragment shader.
*/
#version 330 core
layout(location = 0) in vec4 aVertex; // xy = screen pos (px), zw = atlas UV
out vec2 vTexCoord;
uniform vec2 u_viewportSize; // (WINDOW_WIDTH, WINDOW_HEIGHT)
void main() {
vec2 pos = aVertex.xy;
vTexCoord = aVertex.zw;
vec2 ndc = vec2(
pos.x / u_viewportSize.x * 2.0 - 1.0,
-pos.y / u_viewportSize.y * 2.0 + 1.0
);
gl_Position = vec4(ndc, 0.0, 1.0);
}