/* * MIT License * Author: Mark Allyn * * graticule.vert — vertex shader for the incandescent bearing graticule, * the yellow cursor, and any other 2-D screen-space line geometry. * * Vertices are supplied in window pixels (origin top-left, y down). * The shader converts them to OpenGL NDC (origin bottom-left, y up). */ #version 330 core layout(location = 0) in vec2 aPos; // screen pixels, top-left origin uniform vec2 u_viewportSize; // (WINDOW_WIDTH, WINDOW_HEIGHT) void main() { // Convert: pixel → NDC // ndc.x: 0 → -1, width → +1 // ndc.y: 0 → +1 (top), height → -1 (bottom) vec2 ndc = vec2( aPos.x / u_viewportSize.x * 2.0 - 1.0, -aPos.y / u_viewportSize.y * 2.0 + 1.0 ); gl_Position = vec4(ndc, 0.0, 1.0); }