2011-12-25 10:42:39 +00:00
|
|
|
uniform mat4 mvp_mat;
|
2011-12-25 06:53:12 +00:00
|
|
|
/** Vertex position.
|
|
|
|
|
|
|
|
x, y, cx, cy
|
|
|
|
|
|
|
|
\a vertex provides the onscreen location at which to draw the character
|
|
|
|
(\a x, \a y) and which corner of the character cell this vertex
|
|
|
|
represents (\a cx, \a cy). \a cx and \a cy must be either 0 or 1, or
|
|
|
|
wierd things will happen with the character cell.
|
|
|
|
*/
|
|
|
|
attribute vec4 vertex;
|
|
|
|
|
2011-12-28 00:04:26 +00:00
|
|
|
/** Vectex color.
|
|
|
|
|
|
|
|
r, g, b, a
|
|
|
|
*/
|
|
|
|
attribute vec4 vcolor;
|
|
|
|
|
2011-12-25 06:53:12 +00:00
|
|
|
/** The character to draw.
|
|
|
|
|
|
|
|
The quake character map supports only 256 characters, 0-255. Any other
|
|
|
|
value will give interesting results.
|
|
|
|
*/
|
2012-04-21 11:59:04 +00:00
|
|
|
attribute float dchar;
|
2011-12-25 06:53:12 +00:00
|
|
|
|
|
|
|
/** Coordinate in character map texture.
|
|
|
|
*/
|
2011-12-28 00:04:26 +00:00
|
|
|
varying vec4 color;
|
2011-12-25 06:53:12 +00:00
|
|
|
varying vec2 st;
|
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
2011-12-25 10:42:39 +00:00
|
|
|
float row, col;
|
2011-12-25 06:53:12 +00:00
|
|
|
vec2 pos, corner, uv;
|
2011-12-26 01:16:16 +00:00
|
|
|
const vec2 inset = vec2 (0.03125, 0.03125);
|
2011-12-25 10:42:39 +00:00
|
|
|
const vec2 size = vec2 (0.0625, 0.0625);
|
2011-12-25 06:53:12 +00:00
|
|
|
|
2012-04-21 11:59:04 +00:00
|
|
|
row = floor (dchar / 16.0);
|
|
|
|
col = mod (dchar, 16.0);
|
2011-12-25 06:53:12 +00:00
|
|
|
|
|
|
|
pos = vertex.xy;
|
|
|
|
corner = vertex.zw;
|
2011-12-26 01:16:16 +00:00
|
|
|
uv = vec2 (col, row) + inset * (1.0 - 2.0 * corner) + corner;
|
2011-12-25 06:53:12 +00:00
|
|
|
uv *= size;
|
2011-12-25 10:42:39 +00:00
|
|
|
gl_Position = mvp_mat * vec4 (pos + corner * 8.0, 0.0, 1.0);
|
2011-12-26 01:16:16 +00:00
|
|
|
st = uv;
|
2011-12-28 00:04:26 +00:00
|
|
|
color = vcolor;
|
2011-12-25 06:53:12 +00:00
|
|
|
}
|