FbVtxShader.glsl 676 B

1234567891011121314151617181920212223242526
  1. #version 330 core
  2. precision highp float;
  3. uniform vec2 window_size;
  4. uniform mat2 transform;
  5. layout(location = 0) in vec2 in_position;
  6. layout(location = 1) in vec2 in_tex_coord;
  7. out vec2 tex_coord;
  8. // Have a fixed aspect ratio, fit the image within the available space.
  9. vec2 get_scale_ratio(void) {
  10. vec2 native_size = vec2(1280, 720);
  11. vec2 ratio = vec2(
  12. (window_size.y * native_size.x) / (native_size.y * window_size.x),
  13. (window_size.x * native_size.y) / (native_size.x * window_size.y)
  14. );
  15. return min(ratio, 1);
  16. }
  17. void main(void) {
  18. tex_coord = in_tex_coord;
  19. gl_Position = vec4((transform * in_position) * get_scale_ratio(), 0, 1);
  20. }