9
3

matrix_projection.hpp 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /// @ref ext_matrix_projection
  2. /// @file glm/ext/matrix_projection.hpp
  3. ///
  4. /// @defgroup ext_matrix_projection GLM_EXT_matrix_projection
  5. /// @ingroup ext
  6. ///
  7. /// Functions that generate common projection transformation matrices.
  8. ///
  9. /// The matrices generated by this extension use standard OpenGL fixed-function
  10. /// conventions. For example, the lookAt function generates a transform from world
  11. /// space into the specific eye space that the projective matrix functions
  12. /// (perspective, ortho, etc) are designed to expect. The OpenGL compatibility
  13. /// specifications defines the particular layout of this eye space.
  14. ///
  15. /// Include <glm/ext/matrix_projection.hpp> to use the features of this extension.
  16. ///
  17. /// @see ext_matrix_transform
  18. /// @see ext_matrix_clip_space
  19. #pragma once
  20. // Dependencies
  21. #include "../gtc/constants.hpp"
  22. #include "../geometric.hpp"
  23. #include "../trigonometric.hpp"
  24. #include "../matrix.hpp"
  25. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  26. # pragma message("GLM: GLM_EXT_matrix_projection extension included")
  27. #endif
  28. namespace glm
  29. {
  30. /// @addtogroup ext_matrix_projection
  31. /// @{
  32. /// Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates.
  33. /// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  34. ///
  35. /// @param obj Specify the object coordinates.
  36. /// @param model Specifies the current modelview matrix
  37. /// @param proj Specifies the current projection matrix
  38. /// @param viewport Specifies the current viewport
  39. /// @return Return the computed window coordinates.
  40. /// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
  41. /// @tparam U Currently supported: Floating-point types and integer types.
  42. ///
  43. /// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluProject.xml">gluProject man page</a>
  44. template<typename T, typename U, qualifier Q>
  45. GLM_FUNC_DECL vec<3, T, Q> projectZO(
  46. vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
  47. /// Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates.
  48. /// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  49. ///
  50. /// @param obj Specify the object coordinates.
  51. /// @param model Specifies the current modelview matrix
  52. /// @param proj Specifies the current projection matrix
  53. /// @param viewport Specifies the current viewport
  54. /// @return Return the computed window coordinates.
  55. /// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
  56. /// @tparam U Currently supported: Floating-point types and integer types.
  57. ///
  58. /// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluProject.xml">gluProject man page</a>
  59. template<typename T, typename U, qualifier Q>
  60. GLM_FUNC_DECL vec<3, T, Q> projectNO(
  61. vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
  62. /// Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates using default near and far clip planes definition.
  63. /// To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
  64. ///
  65. /// @param obj Specify the object coordinates.
  66. /// @param model Specifies the current modelview matrix
  67. /// @param proj Specifies the current projection matrix
  68. /// @param viewport Specifies the current viewport
  69. /// @return Return the computed window coordinates.
  70. /// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
  71. /// @tparam U Currently supported: Floating-point types and integer types.
  72. ///
  73. /// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluProject.xml">gluProject man page</a>
  74. template<typename T, typename U, qualifier Q>
  75. GLM_FUNC_DECL vec<3, T, Q> project(
  76. vec<3, T, Q> const& obj, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
  77. /// Map the specified window coordinates (win.x, win.y, win.z) into object coordinates.
  78. /// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  79. ///
  80. /// @param win Specify the window coordinates to be mapped.
  81. /// @param model Specifies the modelview matrix
  82. /// @param proj Specifies the projection matrix
  83. /// @param viewport Specifies the viewport
  84. /// @return Returns the computed object coordinates.
  85. /// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
  86. /// @tparam U Currently supported: Floating-point types and integer types.
  87. ///
  88. /// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluUnProject.xml">gluUnProject man page</a>
  89. template<typename T, typename U, qualifier Q>
  90. GLM_FUNC_DECL vec<3, T, Q> unProjectZO(
  91. vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
  92. /// Map the specified window coordinates (win.x, win.y, win.z) into object coordinates.
  93. /// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  94. ///
  95. /// @param win Specify the window coordinates to be mapped.
  96. /// @param model Specifies the modelview matrix
  97. /// @param proj Specifies the projection matrix
  98. /// @param viewport Specifies the viewport
  99. /// @return Returns the computed object coordinates.
  100. /// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
  101. /// @tparam U Currently supported: Floating-point types and integer types.
  102. ///
  103. /// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluUnProject.xml">gluUnProject man page</a>
  104. template<typename T, typename U, qualifier Q>
  105. GLM_FUNC_DECL vec<3, T, Q> unProjectNO(
  106. vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
  107. /// Map the specified window coordinates (win.x, win.y, win.z) into object coordinates using default near and far clip planes definition.
  108. /// To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
  109. ///
  110. /// @param win Specify the window coordinates to be mapped.
  111. /// @param model Specifies the modelview matrix
  112. /// @param proj Specifies the projection matrix
  113. /// @param viewport Specifies the viewport
  114. /// @return Returns the computed object coordinates.
  115. /// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
  116. /// @tparam U Currently supported: Floating-point types and integer types.
  117. ///
  118. /// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluUnProject.xml">gluUnProject man page</a>
  119. template<typename T, typename U, qualifier Q>
  120. GLM_FUNC_DECL vec<3, T, Q> unProject(
  121. vec<3, T, Q> const& win, mat<4, 4, T, Q> const& model, mat<4, 4, T, Q> const& proj, vec<4, U, Q> const& viewport);
  122. /// Define a picking region
  123. ///
  124. /// @param center Specify the center of a picking region in window coordinates.
  125. /// @param delta Specify the width and height, respectively, of the picking region in window coordinates.
  126. /// @param viewport Rendering viewport
  127. /// @tparam T Native type used for the computation. Currently supported: half (not recommended), float or double.
  128. /// @tparam U Currently supported: Floating-point types and integer types.
  129. ///
  130. /// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPickMatrix.xml">gluPickMatrix man page</a>
  131. template<typename T, qualifier Q, typename U>
  132. GLM_FUNC_DECL mat<4, 4, T, Q> pickMatrix(
  133. vec<2, T, Q> const& center, vec<2, T, Q> const& delta, vec<4, U, Q> const& viewport);
  134. /// @}
  135. }//namespace glm
  136. #include "matrix_projection.inl"