From 8aff635d5fc9ffc1aefcf85f45b275aa876b514f Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 23 Jun 2014 15:05:28 -0400 Subject: [PATCH] implement vertex coordinate mapping in text.v.glsl --- runtime/shaders/text.v.glsl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/runtime/shaders/text.v.glsl b/runtime/shaders/text.v.glsl index c1d8535..fe234d0 100644 --- a/runtime/shaders/text.v.glsl +++ b/runtime/shaders/text.v.glsl @@ -1,9 +1,16 @@ +uniform vec2 screen_size; +uniform vec2 position; + attribute vec4 coords; varying vec2 texture_coord_v; void main(void) { - gl_Position = vec4(coords.xy, 0, 1); + // Map coordinates such that: + // (-0.5 .. screen_size.x-0.5) => (-1.0 .. 1.0) + gl_Position = vec4(2.0 * (position.x + coords.x + 0.5) / screen_size.x - 1.0, + 2.0 * (position.y + coords.y + 0.5) / screen_size.y - 1.0, + 0, 1); texture_coord_v = coords.zw; }