matrix_clip_space.hpp 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. /// @ref ext_matrix_clip_space
  2. /// @file glm/ext/matrix_clip_space.hpp
  3. ///
  4. /// @defgroup ext_matrix_clip_space GLM_EXT_matrix_clip_space
  5. /// @ingroup ext
  6. ///
  7. /// Defines functions that generate clip space 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_clip_space.hpp> to use the features of this extension.
  16. ///
  17. /// @see ext_matrix_transform
  18. /// @see ext_matrix_projection
  19. #pragma once
  20. // Dependencies
  21. #include "../ext/scalar_constants.hpp"
  22. #include "../geometric.hpp"
  23. #include "../trigonometric.hpp"
  24. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  25. # pragma message("GLM: GLM_EXT_matrix_clip_space extension included")
  26. #endif
  27. namespace glm
  28. {
  29. /// @addtogroup ext_matrix_clip_space
  30. /// @{
  31. /// Creates a matrix for projecting two-dimensional coordinates onto the screen.
  32. ///
  33. /// @tparam T A floating-point scalar type
  34. ///
  35. /// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top, T const& zNear, T const& zFar)
  36. /// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluOrtho2D.xml">gluOrtho2D man page</a>
  37. template<typename T>
  38. GLM_FUNC_DECL mat<4, 4, T, defaultp> ortho(
  39. T left, T right, T bottom, T top);
  40. /// Creates a matrix for an orthographic parallel viewing volume, using left-handed coordinates.
  41. /// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  42. ///
  43. /// @tparam T A floating-point scalar type
  44. ///
  45. /// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
  46. template<typename T>
  47. GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoLH_ZO(
  48. T left, T right, T bottom, T top, T zNear, T zFar);
  49. /// Creates a matrix for an orthographic parallel viewing volume using right-handed coordinates.
  50. /// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  51. ///
  52. /// @tparam T A floating-point scalar type
  53. ///
  54. /// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
  55. template<typename T>
  56. GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoLH_NO(
  57. T left, T right, T bottom, T top, T zNear, T zFar);
  58. /// Creates a matrix for an orthographic parallel viewing volume, using left-handed coordinates.
  59. /// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  60. ///
  61. /// @tparam T A floating-point scalar type
  62. ///
  63. /// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
  64. template<typename T>
  65. GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoRH_ZO(
  66. T left, T right, T bottom, T top, T zNear, T zFar);
  67. /// Creates a matrix for an orthographic parallel viewing volume, using right-handed coordinates.
  68. /// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  69. ///
  70. /// @tparam T A floating-point scalar type
  71. ///
  72. /// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
  73. template<typename T>
  74. GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoRH_NO(
  75. T left, T right, T bottom, T top, T zNear, T zFar);
  76. /// Creates a matrix for an orthographic parallel viewing volume, using left-handed coordinates.
  77. /// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  78. ///
  79. /// @tparam T A floating-point scalar type
  80. ///
  81. /// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
  82. template<typename T>
  83. GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoZO(
  84. T left, T right, T bottom, T top, T zNear, T zFar);
  85. /// Creates a matrix for an orthographic parallel viewing volume, using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
  86. /// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  87. ///
  88. /// @tparam T A floating-point scalar type
  89. ///
  90. /// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
  91. template<typename T>
  92. GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoNO(
  93. T left, T right, T bottom, T top, T zNear, T zFar);
  94. /// Creates a matrix for an orthographic parallel viewing volume, using left-handed coordinates.
  95. /// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  96. /// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  97. ///
  98. /// @tparam T A floating-point scalar type
  99. ///
  100. /// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
  101. template<typename T>
  102. GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoLH(
  103. T left, T right, T bottom, T top, T zNear, T zFar);
  104. /// Creates a matrix for an orthographic parallel viewing volume, using right-handed coordinates.
  105. /// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  106. /// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  107. ///
  108. /// @tparam T A floating-point scalar type
  109. ///
  110. /// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
  111. template<typename T>
  112. GLM_FUNC_DECL mat<4, 4, T, defaultp> orthoRH(
  113. T left, T right, T bottom, T top, T zNear, T zFar);
  114. /// Creates a matrix for an orthographic parallel viewing volume, using the default handedness and default near and far clip planes definition.
  115. /// To change default handedness use GLM_FORCE_LEFT_HANDED. To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
  116. ///
  117. /// @tparam T A floating-point scalar type
  118. ///
  119. /// @see - glm::ortho(T const& left, T const& right, T const& bottom, T const& top)
  120. /// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glOrtho.xml">glOrtho man page</a>
  121. template<typename T>
  122. GLM_FUNC_DECL mat<4, 4, T, defaultp> ortho(
  123. T left, T right, T bottom, T top, T zNear, T zFar);
  124. /// Creates a left handed frustum matrix.
  125. /// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  126. ///
  127. /// @tparam T A floating-point scalar type
  128. template<typename T>
  129. GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumLH_ZO(
  130. T left, T right, T bottom, T top, T near, T far);
  131. /// Creates a left handed frustum matrix.
  132. /// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  133. ///
  134. /// @tparam T A floating-point scalar type
  135. template<typename T>
  136. GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumLH_NO(
  137. T left, T right, T bottom, T top, T near, T far);
  138. /// Creates a right handed frustum matrix.
  139. /// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  140. ///
  141. /// @tparam T A floating-point scalar type
  142. template<typename T>
  143. GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumRH_ZO(
  144. T left, T right, T bottom, T top, T near, T far);
  145. /// Creates a right handed frustum matrix.
  146. /// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  147. ///
  148. /// @tparam T A floating-point scalar type
  149. template<typename T>
  150. GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumRH_NO(
  151. T left, T right, T bottom, T top, T near, T far);
  152. /// Creates a frustum matrix using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
  153. /// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  154. ///
  155. /// @tparam T A floating-point scalar type
  156. template<typename T>
  157. GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumZO(
  158. T left, T right, T bottom, T top, T near, T far);
  159. /// Creates a frustum matrix using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
  160. /// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  161. ///
  162. /// @tparam T A floating-point scalar type
  163. template<typename T>
  164. GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumNO(
  165. T left, T right, T bottom, T top, T near, T far);
  166. /// Creates a left handed frustum matrix.
  167. /// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  168. /// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  169. ///
  170. /// @tparam T A floating-point scalar type
  171. template<typename T>
  172. GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumLH(
  173. T left, T right, T bottom, T top, T near, T far);
  174. /// Creates a right handed frustum matrix.
  175. /// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  176. /// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  177. ///
  178. /// @tparam T A floating-point scalar type
  179. template<typename T>
  180. GLM_FUNC_DECL mat<4, 4, T, defaultp> frustumRH(
  181. T left, T right, T bottom, T top, T near, T far);
  182. /// Creates a frustum matrix with default handedness, using the default handedness and default near and far clip planes definition.
  183. /// To change default handedness use GLM_FORCE_LEFT_HANDED. To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
  184. ///
  185. /// @tparam T A floating-point scalar type
  186. /// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glFrustum.xml">glFrustum man page</a>
  187. template<typename T>
  188. GLM_FUNC_DECL mat<4, 4, T, defaultp> frustum(
  189. T left, T right, T bottom, T top, T near, T far);
  190. /// Creates a matrix for a right handed, symetric perspective-view frustum.
  191. /// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  192. ///
  193. /// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
  194. /// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
  195. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  196. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  197. ///
  198. /// @tparam T A floating-point scalar type
  199. template<typename T>
  200. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveRH_ZO(
  201. T fovy, T aspect, T near, T far);
  202. /// Creates a matrix for a right handed, symetric perspective-view frustum.
  203. /// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  204. ///
  205. /// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
  206. /// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
  207. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  208. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  209. ///
  210. /// @tparam T A floating-point scalar type
  211. template<typename T>
  212. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveRH_NO(
  213. T fovy, T aspect, T near, T far);
  214. /// Creates a matrix for a left handed, symetric perspective-view frustum.
  215. /// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  216. ///
  217. /// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
  218. /// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
  219. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  220. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  221. ///
  222. /// @tparam T A floating-point scalar type
  223. template<typename T>
  224. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveLH_ZO(
  225. T fovy, T aspect, T near, T far);
  226. /// Creates a matrix for a left handed, symetric perspective-view frustum.
  227. /// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  228. ///
  229. /// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
  230. /// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
  231. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  232. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  233. ///
  234. /// @tparam T A floating-point scalar type
  235. template<typename T>
  236. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveLH_NO(
  237. T fovy, T aspect, T near, T far);
  238. /// Creates a matrix for a symetric perspective-view frustum using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
  239. /// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  240. ///
  241. /// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
  242. /// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
  243. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  244. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  245. ///
  246. /// @tparam T A floating-point scalar type
  247. template<typename T>
  248. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveZO(
  249. T fovy, T aspect, T near, T far);
  250. /// Creates a matrix for a symetric perspective-view frustum using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
  251. /// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  252. ///
  253. /// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
  254. /// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
  255. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  256. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  257. ///
  258. /// @tparam T A floating-point scalar type
  259. template<typename T>
  260. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveNO(
  261. T fovy, T aspect, T near, T far);
  262. /// Creates a matrix for a right handed, symetric perspective-view frustum.
  263. /// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  264. /// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  265. ///
  266. /// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
  267. /// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
  268. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  269. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  270. ///
  271. /// @tparam T A floating-point scalar type
  272. template<typename T>
  273. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveRH(
  274. T fovy, T aspect, T near, T far);
  275. /// Creates a matrix for a left handed, symetric perspective-view frustum.
  276. /// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  277. /// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  278. ///
  279. /// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
  280. /// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
  281. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  282. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  283. ///
  284. /// @tparam T A floating-point scalar type
  285. template<typename T>
  286. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveLH(
  287. T fovy, T aspect, T near, T far);
  288. /// Creates a matrix for a symetric perspective-view frustum based on the default handedness and default near and far clip planes definition.
  289. /// To change default handedness use GLM_FORCE_LEFT_HANDED. To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
  290. ///
  291. /// @param fovy Specifies the field of view angle in the y direction. Expressed in radians.
  292. /// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
  293. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  294. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  295. ///
  296. /// @tparam T A floating-point scalar type
  297. /// @see <a href="https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPerspective.xml">gluPerspective man page</a>
  298. template<typename T>
  299. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspective(
  300. T fovy, T aspect, T near, T far);
  301. /// Builds a perspective projection matrix based on a field of view using right-handed coordinates.
  302. /// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  303. ///
  304. /// @param fov Expressed in radians.
  305. /// @param width Width of the viewport
  306. /// @param height Height of the viewport
  307. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  308. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  309. ///
  310. /// @tparam T A floating-point scalar type
  311. template<typename T>
  312. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovRH_ZO(
  313. T fov, T width, T height, T near, T far);
  314. /// Builds a perspective projection matrix based on a field of view using right-handed coordinates.
  315. /// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  316. ///
  317. /// @param fov Expressed in radians.
  318. /// @param width Width of the viewport
  319. /// @param height Height of the viewport
  320. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  321. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  322. ///
  323. /// @tparam T A floating-point scalar type
  324. template<typename T>
  325. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovRH_NO(
  326. T fov, T width, T height, T near, T far);
  327. /// Builds a perspective projection matrix based on a field of view using left-handed coordinates.
  328. /// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  329. ///
  330. /// @param fov Expressed in radians.
  331. /// @param width Width of the viewport
  332. /// @param height Height of the viewport
  333. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  334. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  335. ///
  336. /// @tparam T A floating-point scalar type
  337. template<typename T>
  338. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovLH_ZO(
  339. T fov, T width, T height, T near, T far);
  340. /// Builds a perspective projection matrix based on a field of view using left-handed coordinates.
  341. /// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  342. ///
  343. /// @param fov Expressed in radians.
  344. /// @param width Width of the viewport
  345. /// @param height Height of the viewport
  346. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  347. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  348. ///
  349. /// @tparam T A floating-point scalar type
  350. template<typename T>
  351. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovLH_NO(
  352. T fov, T width, T height, T near, T far);
  353. /// Builds a perspective projection matrix based on a field of view using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
  354. /// The near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  355. ///
  356. /// @param fov Expressed in radians.
  357. /// @param width Width of the viewport
  358. /// @param height Height of the viewport
  359. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  360. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  361. ///
  362. /// @tparam T A floating-point scalar type
  363. template<typename T>
  364. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovZO(
  365. T fov, T width, T height, T near, T far);
  366. /// Builds a perspective projection matrix based on a field of view using left-handed coordinates if GLM_FORCE_LEFT_HANDED if defined or right-handed coordinates otherwise.
  367. /// The near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  368. ///
  369. /// @param fov Expressed in radians.
  370. /// @param width Width of the viewport
  371. /// @param height Height of the viewport
  372. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  373. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  374. ///
  375. /// @tparam T A floating-point scalar type
  376. template<typename T>
  377. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovNO(
  378. T fov, T width, T height, T near, T far);
  379. /// Builds a right handed perspective projection matrix based on a field of view.
  380. /// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  381. /// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  382. ///
  383. /// @param fov Expressed in radians.
  384. /// @param width Width of the viewport
  385. /// @param height Height of the viewport
  386. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  387. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  388. ///
  389. /// @tparam T A floating-point scalar type
  390. template<typename T>
  391. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovRH(
  392. T fov, T width, T height, T near, T far);
  393. /// Builds a left handed perspective projection matrix based on a field of view.
  394. /// If GLM_FORCE_DEPTH_ZERO_TO_ONE is defined, the near and far clip planes correspond to z normalized device coordinates of 0 and +1 respectively. (Direct3D clip volume definition)
  395. /// Otherwise, the near and far clip planes correspond to z normalized device coordinates of -1 and +1 respectively. (OpenGL clip volume definition)
  396. ///
  397. /// @param fov Expressed in radians.
  398. /// @param width Width of the viewport
  399. /// @param height Height of the viewport
  400. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  401. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  402. ///
  403. /// @tparam T A floating-point scalar type
  404. template<typename T>
  405. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFovLH(
  406. T fov, T width, T height, T near, T far);
  407. /// Builds a perspective projection matrix based on a field of view and the default handedness and default near and far clip planes definition.
  408. /// To change default handedness use GLM_FORCE_LEFT_HANDED. To change default near and far clip planes definition use GLM_FORCE_DEPTH_ZERO_TO_ONE.
  409. ///
  410. /// @param fov Expressed in radians.
  411. /// @param width Width of the viewport
  412. /// @param height Height of the viewport
  413. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  414. /// @param far Specifies the distance from the viewer to the far clipping plane (always positive).
  415. ///
  416. /// @tparam T A floating-point scalar type
  417. template<typename T>
  418. GLM_FUNC_DECL mat<4, 4, T, defaultp> perspectiveFov(
  419. T fov, T width, T height, T near, T far);
  420. /// Creates a matrix for a left handed, symmetric perspective-view frustum with far plane at infinite.
  421. ///
  422. /// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
  423. /// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
  424. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  425. ///
  426. /// @tparam T A floating-point scalar type
  427. template<typename T>
  428. GLM_FUNC_DECL mat<4, 4, T, defaultp> infinitePerspectiveLH(
  429. T fovy, T aspect, T near);
  430. /// Creates a matrix for a right handed, symmetric perspective-view frustum with far plane at infinite.
  431. ///
  432. /// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
  433. /// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
  434. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  435. ///
  436. /// @tparam T A floating-point scalar type
  437. template<typename T>
  438. GLM_FUNC_DECL mat<4, 4, T, defaultp> infinitePerspectiveRH(
  439. T fovy, T aspect, T near);
  440. /// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite with default handedness.
  441. ///
  442. /// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
  443. /// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
  444. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  445. ///
  446. /// @tparam T A floating-point scalar type
  447. template<typename T>
  448. GLM_FUNC_DECL mat<4, 4, T, defaultp> infinitePerspective(
  449. T fovy, T aspect, T near);
  450. /// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
  451. ///
  452. /// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
  453. /// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
  454. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  455. ///
  456. /// @tparam T A floating-point scalar type
  457. template<typename T>
  458. GLM_FUNC_DECL mat<4, 4, T, defaultp> tweakedInfinitePerspective(
  459. T fovy, T aspect, T near);
  460. /// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
  461. ///
  462. /// @param fovy Specifies the field of view angle, in degrees, in the y direction. Expressed in radians.
  463. /// @param aspect Specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
  464. /// @param near Specifies the distance from the viewer to the near clipping plane (always positive).
  465. /// @param ep Epsilon
  466. ///
  467. /// @tparam T A floating-point scalar type
  468. template<typename T>
  469. GLM_FUNC_DECL mat<4, 4, T, defaultp> tweakedInfinitePerspective(
  470. T fovy, T aspect, T near, T ep);
  471. /// @}
  472. }//namespace glm
  473. #include "matrix_clip_space.inl"