2
0

Sprite.vert 956 B

123456789101112131415161718192021222324252627282930313233
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. // Request GLSL 3.3
  9. #version 330
  10. // Uniforms for world transform and view-proj
  11. uniform mat4 uWorldTransform;
  12. uniform mat4 uViewProj;
  13. // Attribute 0 is position, 1 is tex coords.
  14. layout(location = 0) in vec3 inPosition;
  15. layout(location = 1) in vec2 inTexCoord;
  16. // Add texture coordinate as output
  17. out vec2 fragTexCoord;
  18. void main()
  19. {
  20. // Convert position to homogeneous coordinates
  21. vec4 pos = vec4(inPosition, 1.0);
  22. // Transform position to world space, then clip space
  23. gl_Position = pos * uWorldTransform * uViewProj;
  24. // Transform
  25. // Pass along the texture coordinate to frag shader
  26. fragTexCoord = inTexCoord;
  27. }