free_font.vert 937 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #version 330 core
  2. #define FONT_WIDTH 128
  3. #define FONT_HEIGHT 64
  4. #define FONT_COLS 18
  5. #define FONT_ROWS 7
  6. #define FONT_CH_W (FONT_WIDTH / FONT_COLS)
  7. #define FONT_CH_H (FONT_HEIGHT / FONT_ROWS)
  8. uniform vec2 resolution;
  9. uniform float time;
  10. uniform vec2 camera;
  11. layout(location = 0) in vec2 pos;
  12. layout(location = 1) in vec2 size;
  13. layout(location = 2) in vec2 uv_pos;
  14. layout(location = 3) in vec2 uv_size;
  15. layout(location = 4) in vec4 fg_color;
  16. layout(location = 5) in vec4 bg_color;
  17. out vec2 uv;
  18. out vec2 glyph_uv_pos;
  19. out vec2 glyph_uv_size;
  20. out vec4 glyph_fg_color;
  21. out vec4 glyph_bg_color;
  22. vec2 project_point(vec2 point)
  23. {
  24. return (2.0 * (point - camera)) / resolution;
  25. }
  26. void main()
  27. {
  28. uv = vec2(float(gl_VertexID & 1),
  29. float((gl_VertexID >> 1) & 1));
  30. gl_Position = vec4(project_point(uv * size + pos), 0.0, 1.0);
  31. glyph_uv_pos = uv_pos;
  32. glyph_uv_size = uv_size;
  33. glyph_fg_color = fg_color;
  34. glyph_bg_color = bg_color;
  35. }