pp_opengl.vert 815 B

12345678910111213141516171819202122232425
  1. // Pass to fragment shader with the same name
  2. varying vec2 TexCoords;
  3. void main(void)
  4. {
  5. gl_Position = gl_Vertex;
  6. // The origin of the texture coordinates locates at bottom-left
  7. // corner rather than top-left corner as defined on screen quad.
  8. // Instead of using texture coordinates passed in by OpenGL, we
  9. // calculate TexCoords based on vertex position as follows.
  10. //
  11. // Vertex[0] (-1, -1) to (0, 0)
  12. // Vertex[1] (-1, 1) to (0, 1)
  13. // Vertex[2] ( 1, 1) to (1, 1)
  14. // Vertex[3] ( 1, -1) to (1, 0)
  15. //
  16. // Texture coordinate system in OpenGL operates differently from
  17. // DirectX 3D. It is not necessary to offset TexCoords to texel
  18. // center by adding 1.0 / TextureSize / 2.0
  19. TexCoords = (gl_Vertex.xy * 0.5 + 0.5);
  20. }