r3d_draw.odin 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /* r3d_draw.odin -- R3D Draw Module.
  2. *
  3. * Copyright (c) 2025-2026 Le Juez Victor
  4. *
  5. * This software is provided 'as-is', without any express or implied warranty.
  6. * For conditions of distribution and use, see accompanying LICENSE file.
  7. */
  8. package r3d
  9. import rl "vendor:raylib"
  10. when ODIN_OS == .Windows {
  11. foreign import lib {
  12. "windows/libr3d.a",
  13. "system:raylib",
  14. "system:assimp",
  15. }
  16. } else when ODIN_OS == .Linux {
  17. foreign import lib {
  18. "linux/libr3d.a",
  19. "system:raylib",
  20. "system:assimp",
  21. }
  22. } else when ODIN_OS == .Darwin {
  23. foreign import lib {
  24. "darwin/libr3d.a",
  25. "system:raylib",
  26. "system:assimp",
  27. }
  28. }
  29. @(default_calling_convention="c", link_prefix="R3D_")
  30. foreign lib {
  31. /**
  32. * @brief Begins a rendering session using the given camera.
  33. *
  34. * Rendering output is directed to the default framebuffer.
  35. *
  36. * @param camera rl.Camera used to render the scene.
  37. */
  38. Begin :: proc(camera: rl.Camera3D) ---
  39. /**
  40. * @brief Begins a rendering session with a custom render target.
  41. *
  42. * If the render target is invalid (ID = 0), rendering goes to the screen.
  43. *
  44. * @param target Render texture to render into.
  45. * @param camera rl.Camera used to render the scene.
  46. */
  47. BeginEx :: proc(target: rl.RenderTexture, camera: rl.Camera3D) ---
  48. /**
  49. * @brief Ends the current rendering session.
  50. *
  51. * This function is the one that actually performs the full
  52. * rendering of the described scene. It carries out culling,
  53. * sorting, shadow rendering, scene rendering, and screen /
  54. * post-processing effects.
  55. */
  56. End :: proc() ---
  57. /**
  58. * @brief Begins a clustered draw pass.
  59. *
  60. * All draw calls submitted in this pass are first tested against the
  61. * cluster AABB. If the cluster fails the scene/shadow frustum test,
  62. * none of the contained objects are tested or drawn.
  63. *
  64. * @param aabb Bounding box used as the cluster-level frustum test.
  65. */
  66. BeginCluster :: proc(aabb: rl.BoundingBox) ---
  67. /**
  68. * @brief Ends the current clustered draw pass.
  69. *
  70. * Stops submitting draw calls to the active cluster.
  71. */
  72. EndCluster :: proc() ---
  73. /**
  74. * @brief Queues a mesh draw command with position and uniform scale.
  75. *
  76. * The command is executed during R3D_End().
  77. */
  78. DrawMesh :: proc(mesh: Mesh, material: Material, position: rl.Vector3, scale: f32) ---
  79. /**
  80. * @brief Queues a mesh draw command with position, rotation and non-uniform scale.
  81. *
  82. * The command is executed during R3D_End().
  83. */
  84. DrawMeshEx :: proc(mesh: Mesh, material: Material, position: rl.Vector3, rotation: rl.Quaternion, scale: rl.Vector3) ---
  85. /**
  86. * @brief Queues a mesh draw command using a full transform matrix.
  87. *
  88. * The command is executed during R3D_End().
  89. */
  90. DrawMeshPro :: proc(mesh: Mesh, material: Material, transform: rl.Matrix) ---
  91. /**
  92. * @brief Queues an instanced mesh draw command.
  93. *
  94. * Draws multiple instances using the provided instance buffer.
  95. * Does nothing if the number of instances is <= 0.
  96. *
  97. * The command is executed during R3D_End().
  98. */
  99. DrawMeshInstanced :: proc(mesh: Mesh, material: Material, instances: InstanceBuffer, count: i32) ---
  100. /**
  101. * @brief Queues an instanced mesh draw command with an additional transform.
  102. *
  103. * Does nothing if the number of instances is <= 0.
  104. * The transform is applied to all instances.
  105. *
  106. * The command is executed during R3D_End().
  107. */
  108. DrawMeshInstancedEx :: proc(mesh: Mesh, material: Material, instances: InstanceBuffer, count: i32, transform: rl.Matrix) ---
  109. /**
  110. * @brief Queues a model draw command with position and uniform scale.
  111. *
  112. * The command is executed during R3D_End().
  113. */
  114. DrawModel :: proc(model: Model, position: rl.Vector3, scale: f32) ---
  115. /**
  116. * @brief Queues a model draw command with position, rotation and non-uniform scale.
  117. *
  118. * The command is executed during R3D_End().
  119. */
  120. DrawModelEx :: proc(model: Model, position: rl.Vector3, rotation: rl.Quaternion, scale: rl.Vector3) ---
  121. /**
  122. * @brief Queues a model draw command using a full transform matrix.
  123. *
  124. * The command is executed during R3D_End().
  125. */
  126. DrawModelPro :: proc(model: Model, transform: rl.Matrix) ---
  127. /**
  128. * @brief Queues an instanced model draw command.
  129. *
  130. * Draws multiple instances using the provided instance buffer.
  131. * Does nothing if the number of instances is <= 0.
  132. *
  133. * The command is executed during R3D_End().
  134. */
  135. DrawModelInstanced :: proc(model: Model, instances: InstanceBuffer, count: i32) ---
  136. /**
  137. * @brief Queues an instanced model draw command with an additional transform.
  138. *
  139. * Does nothing if the number of instances is <= 0.
  140. * The transform is applied to all instances.
  141. *
  142. * The command is executed during R3D_End().
  143. */
  144. DrawModelInstancedEx :: proc(model: Model, instances: InstanceBuffer, count: i32, transform: rl.Matrix) ---
  145. /**
  146. * @brief Queues an animated model draw command.
  147. *
  148. * Uses the provided animation player to compute the pose.
  149. *
  150. * The command is executed during R3D_End().
  151. */
  152. DrawAnimatedModel :: proc(model: Model, player: AnimationPlayer, position: rl.Vector3, scale: f32) ---
  153. /**
  154. * @brief Queues an animated model draw command with position, rotation and non-uniform scale.
  155. *
  156. * Uses the provided animation player to compute the pose.
  157. *
  158. * The command is executed during R3D_End().
  159. */
  160. DrawAnimatedModelEx :: proc(model: Model, player: AnimationPlayer, position: rl.Vector3, rotation: rl.Quaternion, scale: rl.Vector3) ---
  161. /**
  162. * @brief Queues an animated model draw command using a full transform matrix.
  163. *
  164. * The command is executed during R3D_End().
  165. */
  166. DrawAnimatedModelPro :: proc(model: Model, player: AnimationPlayer, transform: rl.Matrix) ---
  167. /**
  168. * @brief Queues an instanced animated model draw command.
  169. *
  170. * Draws multiple animated instances using the provided instance buffer.
  171. * Does nothing if the number of instances is <= 0.
  172. *
  173. * The command is executed during R3D_End().
  174. */
  175. DrawAnimatedModelInstanced :: proc(model: Model, player: AnimationPlayer, instances: InstanceBuffer, count: i32) ---
  176. /**
  177. * @brief Queues an instanced animated model draw command with an additional transform.
  178. *
  179. * Does nothing if the number of instances is <= 0.
  180. * The transform is applied to all instances.
  181. *
  182. * The command is executed during R3D_End().
  183. */
  184. DrawAnimatedModelInstancedEx :: proc(model: Model, player: AnimationPlayer, instances: InstanceBuffer, count: i32, transform: rl.Matrix) ---
  185. /**
  186. * @brief Queues a decal draw command with position and uniform scale.
  187. *
  188. * The command is executed during R3D_End().
  189. */
  190. DrawDecal :: proc(decal: Decal, position: rl.Vector3, scale: f32) ---
  191. /**
  192. * @brief Queues a decal draw command with position, rotation and non-uniform scale.
  193. *
  194. * The command is executed during R3D_End().
  195. */
  196. DrawDecalEx :: proc(decal: Decal, position: rl.Vector3, rotation: rl.Quaternion, scale: rl.Vector3) ---
  197. /**
  198. * @brief Queues a decal draw command using a full transform matrix.
  199. *
  200. * The command is executed during R3D_End().
  201. */
  202. DrawDecalPro :: proc(decal: Decal, transform: rl.Matrix) ---
  203. /**
  204. * @brief Queues an instanced decal draw command.
  205. *
  206. * Draws multiple instances using the provided instance buffer.
  207. * Does nothing if the number of instances is <= 0.
  208. *
  209. * The command is executed during R3D_End().
  210. */
  211. DrawDecalInstanced :: proc(decal: Decal, instances: InstanceBuffer, count: i32) ---
  212. /**
  213. * @brief Queues an instanced decal draw command with an additional transform.
  214. *
  215. * Does nothing if the number of instances is <= 0.
  216. * The transform is applied to all instances.
  217. *
  218. * The command is executed during R3D_End().
  219. */
  220. DrawDecalInstancedEx :: proc(decal: Decal, instances: InstanceBuffer, count: i32, transform: rl.Matrix) ---
  221. }