shader.vert 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* License Notice:
  2. **
  3. ** This program is free software: you can redistribute it and/or modify
  4. ** it under the terms of the GNU General Public License as published by
  5. ** the Free Software Foundation, either version 3 of the License, or
  6. ** (at your option) any later version.
  7. ** This program is distributed in the hope that it will be useful,
  8. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. ** GNU General Public License for more details.
  11. ** You should have received a copy of the GNU General Public License
  12. ** along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. */
  14. /**
  15. * @file shader.vert
  16. * @author TooOld2Rock'nRoll
  17. * @date 2022/Ago
  18. * @remark Last modified in 2023/set
  19. *
  20. * @brief Vertex Shader program for the ArcadeFighter library.
  21. *
  22. * Originally this code was part of Breakout, now part of ArcadeFighter library
  23. * and was modified by the author as a exercise.<br>
  24. * Breakout is free software: you can redistribute it and/or modify
  25. * it under the terms of the CC BY 4.0 license as published by
  26. * Creative Commons, either version 4 of the License, or (at your
  27. * option) any later version.
  28. *
  29. * @see https://learnopengl.com/Getting-started/Shaders
  30. * @see https://www.khronos.org/opengl/wiki/OpenGL_Shading_Language
  31. * @see https://www.khronos.org/opengl/wiki/Vertex_Shader
  32. *
  33. * @todo use the z coordinate of the vertex_pos.
  34. */
  35. //The minimum version of OpenGl that this program supports.
  36. #version 330 core
  37. //Texture Unit, not in use for now, see sprite2D.hpp for more info
  38. //layout (location = 0)
  39. in vec2 vertex_pos; ///< the vertex position
  40. in vec2 texture_uv; ///< the texture coordinates to render
  41. out vec2 TexCoords; ///< forward the texture coordinate to the Fragment Shader
  42. uniform mat4 model; ///< transformation applied to the mesh
  43. uniform mat4 view; ///< "camera" position
  44. uniform mat4 projection; ///< which projection to use when rendering
  45. /**
  46. * @brief The main method of the Vertex Shader.
  47. */
  48. void main ()
  49. {
  50. TexCoords = texture_uv;
  51. gl_Position = projection * (view * (model * vec4(vertex_pos.xy, 0.0, 1.0)));
  52. }//END main ()