1
0

ortho_lh_no.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Copyright (c), Recep Aslantas.
  3. *
  4. * MIT License (MIT), http://opensource.org/licenses/MIT
  5. * Full license can be found in the LICENSE file
  6. */
  7. /*
  8. Functions:
  9. CGLM_INLINE mat4s glms_ortho_lh_no(float left, float right,
  10. float bottom, float top,
  11. float nearZ, float farZ)
  12. CGLM_INLINE mat4s glms_ortho_aabb_lh_no(vec3s box[2]);
  13. CGLM_INLINE mat4s glms_ortho_aabb_p_lh_no(vec3s box[2], float padding);
  14. CGLM_INLINE mat4s glms_ortho_aabb_pz_lh_no(vec3s box[2], float padding);
  15. CGLM_INLINE mat4s glms_ortho_default_lh_no(float aspect)
  16. CGLM_INLINE mat4s glms_ortho_default_s_lh_no(float aspect, float size)
  17. */
  18. #ifndef cglms_ortho_lh_no_h
  19. #define cglms_ortho_lh_no_h
  20. #include "../../common.h"
  21. #include "../../types-struct.h"
  22. #include "../../plane.h"
  23. #include "../../cam.h"
  24. #include "../vec3.h"
  25. #include "../../clipspace/ortho_lh_no.h"
  26. /*!
  27. * @brief set up orthographic projection matrix
  28. * with a left-hand coordinate system and a
  29. * clip-space of [-1, 1].
  30. *
  31. * @param[in] left viewport.left
  32. * @param[in] right viewport.right
  33. * @param[in] bottom viewport.bottom
  34. * @param[in] top viewport.top
  35. * @param[in] nearZ near clipping plane
  36. * @param[in] farZ far clipping plane
  37. * @returns result matrix
  38. */
  39. CGLM_INLINE
  40. mat4s
  41. glms_ortho_lh_no(float left, float right,
  42. float bottom, float top,
  43. float nearZ, float farZ) {
  44. mat4s dest;
  45. glm_ortho_lh_no(left, right, bottom, top, nearZ, farZ, dest.raw);
  46. return dest;
  47. }
  48. /*!
  49. * @brief set up orthographic projection matrix using bounding box
  50. * with a left-hand coordinate system and a
  51. * clip-space of [-1, 1].
  52. *
  53. * bounding box (AABB) must be in view space
  54. *
  55. * @param[in] box AABB
  56. * @returns result matrix
  57. */
  58. CGLM_INLINE
  59. mat4s
  60. glms_ortho_aabb_lh_no(vec3s box[2]) {
  61. mat4s dest;
  62. vec3 rawBox[2];
  63. glms_vec3_(unpack)(rawBox, box, 2);
  64. glm_ortho_aabb_lh_no(rawBox, dest.raw);
  65. return dest;
  66. }
  67. /*!
  68. * @brief set up orthographic projection matrix using bounding box
  69. * with a left-hand coordinate system and a
  70. * clip-space of [-1, 1].
  71. *
  72. * bounding box (AABB) must be in view space
  73. *
  74. * @param[in] box AABB
  75. * @param[in] padding padding
  76. * @returns result matrix
  77. */
  78. CGLM_INLINE
  79. mat4s
  80. glms_ortho_aabb_p_lh_no(vec3s box[2], float padding) {
  81. mat4s dest;
  82. vec3 rawBox[2];
  83. glms_vec3_(unpack)(rawBox, box, 2);
  84. glm_ortho_aabb_p_lh_no(rawBox, padding, dest.raw);
  85. return dest;
  86. }
  87. /*!
  88. * @brief set up orthographic projection matrix using bounding box
  89. * with a left-hand coordinate system and a
  90. * clip-space of [-1, 1].
  91. *
  92. * bounding box (AABB) must be in view space
  93. *
  94. * @param[in] box AABB
  95. * @param[in] padding padding for near and far
  96. * @returns result matrix
  97. */
  98. CGLM_INLINE
  99. mat4s
  100. glms_ortho_aabb_pz_lh_no(vec3s box[2], float padding) {
  101. mat4s dest;
  102. vec3 rawBox[2];
  103. glms_vec3_(unpack)(rawBox, box, 2);
  104. glm_ortho_aabb_pz_lh_no(rawBox, padding, dest.raw);
  105. return dest;
  106. }
  107. /*!
  108. * @brief set up unit orthographic projection matrix
  109. * with a left-hand coordinate system and a
  110. * clip-space of [-1, 1].
  111. *
  112. * @param[in] aspect aspect ration ( width / height )
  113. * @returns result matrix
  114. */
  115. CGLM_INLINE
  116. mat4s
  117. glms_ortho_default_lh_no(float aspect) {
  118. mat4s dest;
  119. glm_ortho_default_lh_no(aspect, dest.raw);
  120. return dest;
  121. }
  122. /*!
  123. * @brief set up orthographic projection matrix with given CUBE size
  124. * with a left-hand coordinate system and a
  125. * clip-space of [-1, 1].
  126. *
  127. * @param[in] aspect aspect ratio ( width / height )
  128. * @param[in] size cube size
  129. * @returns result matrix
  130. */
  131. CGLM_INLINE
  132. mat4s
  133. glms_ortho_default_s_lh_no(float aspect, float size) {
  134. mat4s dest;
  135. glm_ortho_default_s_lh_no(aspect, size, dest.raw);
  136. return dest;
  137. }
  138. #endif /* cglms_ortho_lh_no_h */