shape.odin 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. // machine generated, do not edit
  2. package sokol_shape
  3. /*
  4. sokol_shape.h -- create simple primitive shapes for sokol_gfx.h
  5. Project URL: https://github.com/floooh/sokol
  6. Do this:
  7. #define SOKOL_IMPL or
  8. #define SOKOL_SHAPE_IMPL
  9. before you include this file in *one* C or C++ file to create the
  10. implementation.
  11. Include the following headers before including sokol_shape.h:
  12. sokol_gfx.h
  13. ...optionally provide the following macros to override defaults:
  14. SOKOL_ASSERT(c) - your own assert macro (default: assert(c))
  15. SOKOL_SHAPE_API_DECL- public function declaration prefix (default: extern)
  16. SOKOL_API_DECL - same as SOKOL_SHAPE_API_DECL
  17. SOKOL_API_IMPL - public function implementation prefix (default: -)
  18. If sokol_shape.h is compiled as a DLL, define the following before
  19. including the declaration or implementation:
  20. SOKOL_DLL
  21. On Windows, SOKOL_DLL will define SOKOL_SHAPE_API_DECL as __declspec(dllexport)
  22. or __declspec(dllimport) as needed.
  23. FEATURE OVERVIEW
  24. ================
  25. sokol_shape.h creates vertices and indices for simple shapes and
  26. builds structs which can be plugged into sokol-gfx resource
  27. creation functions:
  28. The following shape types are supported:
  29. - plane
  30. - cube
  31. - sphere (with poles, not geodesic)
  32. - cylinder
  33. - torus (donut)
  34. Generated vertices look like this:
  35. typedef struct sshape_vertex_t {
  36. float x, y, z;
  37. uint32_t normal; // packed normal as BYTE4N
  38. uint16_t u, v; // packed uv coords as USHORT2N
  39. uint32_t color; // packed color as UBYTE4N (r,g,b,a);
  40. } sshape_vertex_t;
  41. Indices are generally 16-bits wide (SG_INDEXTYPE_UINT16) and the indices
  42. are written as triangle-lists (SG_PRIMITIVETYPE_TRIANGLES).
  43. EXAMPLES:
  44. =========
  45. Create multiple shapes into the same vertex- and index-buffer and
  46. render with separate draw calls:
  47. https://github.com/floooh/sokol-samples/blob/master/sapp/shapes-sapp.c
  48. Same as the above, but pre-transform shapes and merge them into a single
  49. shape that's rendered with a single draw call.
  50. https://github.com/floooh/sokol-samples/blob/master/sapp/shapes-transform-sapp.c
  51. STEP-BY-STEP:
  52. =============
  53. Setup an sshape_buffer_t struct with pointers to memory buffers where
  54. generated vertices and indices will be written to:
  55. ```c
  56. sshape_vertex_t vertices[512];
  57. uint16_t indices[4096];
  58. sshape_buffer_t buf = {
  59. .vertices = {
  60. .buffer = SSHAPE_RANGE(vertices),
  61. },
  62. .indices = {
  63. .buffer = SSHAPE_RANGE(indices),
  64. }
  65. };
  66. ```
  67. To find out how big those memory buffers must be (in case you want
  68. to allocate dynamically) call the following functions:
  69. ```c
  70. sshape_sizes_t sshape_plane_sizes(uint32_t tiles);
  71. sshape_sizes_t sshape_box_sizes(uint32_t tiles);
  72. sshape_sizes_t sshape_sphere_sizes(uint32_t slices, uint32_t stacks);
  73. sshape_sizes_t sshape_cylinder_sizes(uint32_t slices, uint32_t stacks);
  74. sshape_sizes_t sshape_torus_sizes(uint32_t sides, uint32_t rings);
  75. ```
  76. The returned sshape_sizes_t struct contains vertex- and index-counts
  77. as well as the equivalent buffer sizes in bytes. For instance:
  78. ```c
  79. sshape_sizes_t sizes = sshape_sphere_sizes(36, 12);
  80. uint32_t num_vertices = sizes.vertices.num;
  81. uint32_t num_indices = sizes.indices.num;
  82. uint32_t vertex_buffer_size = sizes.vertices.size;
  83. uint32_t index_buffer_size = sizes.indices.size;
  84. ```
  85. With the sshape_buffer_t struct that was setup earlier, call any
  86. of the shape-builder functions:
  87. ```c
  88. sshape_buffer_t sshape_build_plane(const sshape_buffer_t* buf, const sshape_plane_t* params);
  89. sshape_buffer_t sshape_build_box(const sshape_buffer_t* buf, const sshape_box_t* params);
  90. sshape_buffer_t sshape_build_sphere(const sshape_buffer_t* buf, const sshape_sphere_t* params);
  91. sshape_buffer_t sshape_build_cylinder(const sshape_buffer_t* buf, const sshape_cylinder_t* params);
  92. sshape_buffer_t sshape_build_torus(const sshape_buffer_t* buf, const sshape_torus_t* params);
  93. ```
  94. Note how the sshape_buffer_t struct is both an input value and the
  95. return value. This can be used to append multiple shapes into the
  96. same vertex- and index-buffers (more on this later).
  97. The second argument is a struct which holds creation parameters.
  98. For instance to build a sphere with radius 2, 36 "cake slices" and 12 stacks:
  99. ```c
  100. sshape_buffer_t buf = ...;
  101. buf = sshape_build_sphere(&buf, &(sshape_sphere_t){
  102. .radius = 2.0f,
  103. .slices = 36,
  104. .stacks = 12,
  105. });
  106. ```
  107. If the provided buffers are big enough to hold all generated vertices and
  108. indices, the "valid" field in the result will be true:
  109. ```c
  110. assert(buf.valid);
  111. ```
  112. The shape creation parameters have "useful defaults", refer to the
  113. actual C struct declarations below to look up those defaults.
  114. You can also provide additional creation parameters, like a common vertex
  115. color, a debug-helper to randomize colors, tell the shape builder function
  116. to merge the new shape with the previous shape into the same draw-element-range,
  117. or a 4x4 transform matrix to move, rotate and scale the generated vertices:
  118. ```c
  119. sshape_buffer_t buf = ...;
  120. buf = sshape_build_sphere(&buf, &(sshape_sphere_t){
  121. .radius = 2.0f,
  122. .slices = 36,
  123. .stacks = 12,
  124. // merge with previous shape into a single element-range
  125. .merge = true,
  126. // set vertex color to red+opaque
  127. .color = sshape_color_4f(1.0f, 0.0f, 0.0f, 1.0f),
  128. // set position to y = 2.0
  129. .transform = {
  130. .m = {
  131. { 1.0f, 0.0f, 0.0f, 0.0f },
  132. { 0.0f, 1.0f, 0.0f, 0.0f },
  133. { 0.0f, 0.0f, 1.0f, 0.0f },
  134. { 0.0f, 2.0f, 0.0f, 1.0f },
  135. }
  136. }
  137. });
  138. assert(buf.valid);
  139. ```
  140. The following helper functions can be used to build a packed
  141. color value or to convert from external matrix types:
  142. ```c
  143. uint32_t sshape_color_4f(float r, float g, float b, float a);
  144. uint32_t sshape_color_3f(float r, float g, float b);
  145. uint32_t sshape_color_4b(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
  146. uint32_t sshape_color_3b(uint8_t r, uint8_t g, uint8_t b);
  147. sshape_mat4_t sshape_mat4(const float m[16]);
  148. sshape_mat4_t sshape_mat4_transpose(const float m[16]);
  149. ```
  150. After the shape builder function has been called, the following functions
  151. are used to extract the build result for plugging into sokol_gfx.h:
  152. ```c
  153. sshape_element_range_t sshape_element_range(const sshape_buffer_t* buf);
  154. sg_buffer_desc sshape_vertex_buffer_desc(const sshape_buffer_t* buf);
  155. sg_buffer_desc sshape_index_buffer_desc(const sshape_buffer_t* buf);
  156. sg_vertex_buffer_layout_state sshape_vertex_buffer_layout_state(void);
  157. sg_vertex_attr_state sshape_position_vertex_attr_state(void);
  158. sg_vertex_attr_state sshape_normal_vertex_attr_state(void);
  159. sg_vertex_attr_state sshape_texcoord_vertex_attr_state(void);
  160. sg_vertex_attr_state sshape_color_vertex_attr_state(void);
  161. ```
  162. The sshape_element_range_t struct contains the base-index and number of
  163. indices which can be plugged into the sg_draw() call:
  164. ```c
  165. sshape_element_range_t elms = sshape_element_range(&buf);
  166. ...
  167. sg_draw(elms.base_element, elms.num_elements, 1);
  168. ```
  169. To create sokol-gfx vertex- and index-buffers from the generated
  170. shape data:
  171. ```c
  172. // create sokol-gfx vertex buffer
  173. sg_buffer_desc vbuf_desc = sshape_vertex_buffer_desc(&buf);
  174. sg_buffer vbuf = sg_make_buffer(&vbuf_desc);
  175. // create sokol-gfx index buffer
  176. sg_buffer_desc ibuf_desc = sshape_index_buffer_desc(&buf);
  177. sg_buffer ibuf = sg_make_buffer(&ibuf_desc);
  178. ```
  179. The remaining functions are used to populate the vertex-layout item
  180. in sg_pipeline_desc, note that these functions don't depend on the
  181. created geometry, they always return the same result:
  182. ```c
  183. sg_pipeline pip = sg_make_pipeline(&(sg_pipeline_desc){
  184. .layout = {
  185. .buffers[0] = sshape_vertex_buffer_layout_state(),
  186. .attrs = {
  187. [0] = sshape_position_vertex_attr_state(),
  188. [1] = ssape_normal_vertex_attr_state(),
  189. [2] = sshape_texcoord_vertex_attr_state(),
  190. [3] = sshape_color_vertex_attr_state()
  191. }
  192. },
  193. ...
  194. });
  195. ```
  196. Note that you don't have to use all generated vertex attributes in the
  197. pipeline's vertex layout, the sg_vertex_buffer_layout_state struct returned
  198. by sshape_vertex_buffer_layout_state() contains the correct vertex stride
  199. to skip vertex components.
  200. WRITING MULTIPLE SHAPES INTO THE SAME BUFFER
  201. ============================================
  202. You can merge multiple shapes into the same vertex- and
  203. index-buffers and either render them as a single shape, or
  204. in separate draw calls.
  205. To build a single shape made of two cubes which can be rendered
  206. in a single draw-call:
  207. ```
  208. sshape_vertex_t vertices[128];
  209. uint16_t indices[16];
  210. sshape_buffer_t buf = {
  211. .vertices.buffer = SSHAPE_RANGE(vertices),
  212. .indices.buffer = SSHAPE_RANGE(indices)
  213. };
  214. // first cube at pos x=-2.0 (with default size of 1x1x1)
  215. buf = sshape_build_cube(&buf, &(sshape_box_t){
  216. .transform = {
  217. .m = {
  218. { 1.0f, 0.0f, 0.0f, 0.0f },
  219. { 0.0f, 1.0f, 0.0f, 0.0f },
  220. { 0.0f, 0.0f, 1.0f, 0.0f },
  221. {-2.0f, 0.0f, 0.0f, 1.0f },
  222. }
  223. }
  224. });
  225. // ...and append another cube at pos pos=+1.0
  226. // NOTE the .merge = true, this tells the shape builder
  227. // function to not advance the current shape start offset
  228. buf = sshape_build_cube(&buf, &(sshape_box_t){
  229. .merge = true,
  230. .transform = {
  231. .m = {
  232. { 1.0f, 0.0f, 0.0f, 0.0f },
  233. { 0.0f, 1.0f, 0.0f, 0.0f },
  234. { 0.0f, 0.0f, 1.0f, 0.0f },
  235. {-2.0f, 0.0f, 0.0f, 1.0f },
  236. }
  237. }
  238. });
  239. assert(buf.valid);
  240. // skipping buffer- and pipeline-creation...
  241. sshape_element_range_t elms = sshape_element_range(&buf);
  242. sg_draw(elms.base_element, elms.num_elements, 1);
  243. ```
  244. To render the two cubes in separate draw-calls, the element-ranges used
  245. in the sg_draw() calls must be captured right after calling the
  246. builder-functions:
  247. ```c
  248. sshape_vertex_t vertices[128];
  249. uint16_t indices[16];
  250. sshape_buffer_t buf = {
  251. .vertices.buffer = SSHAPE_RANGE(vertices),
  252. .indices.buffer = SSHAPE_RANGE(indices)
  253. };
  254. // build a red cube...
  255. buf = sshape_build_cube(&buf, &(sshape_box_t){
  256. .color = sshape_color_3b(255, 0, 0)
  257. });
  258. sshape_element_range_t red_cube = sshape_element_range(&buf);
  259. // append a green cube to the same vertex-/index-buffer:
  260. buf = sshape_build_cube(&bud, &sshape_box_t){
  261. .color = sshape_color_3b(0, 255, 0);
  262. });
  263. sshape_element_range_t green_cube = sshape_element_range(&buf);
  264. // skipping buffer- and pipeline-creation...
  265. sg_draw(red_cube.base_element, red_cube.num_elements, 1);
  266. sg_draw(green_cube.base_element, green_cube.num_elements, 1);
  267. ```
  268. ...that's about all :)
  269. LICENSE
  270. =======
  271. zlib/libpng license
  272. Copyright (c) 2020 Andre Weissflog
  273. This software is provided 'as-is', without any express or implied warranty.
  274. In no event will the authors be held liable for any damages arising from the
  275. use of this software.
  276. Permission is granted to anyone to use this software for any purpose,
  277. including commercial applications, and to alter it and redistribute it
  278. freely, subject to the following restrictions:
  279. 1. The origin of this software must not be misrepresented; you must not
  280. claim that you wrote the original software. If you use this software in a
  281. product, an acknowledgment in the product documentation would be
  282. appreciated but is not required.
  283. 2. Altered source versions must be plainly marked as such, and must not
  284. be misrepresented as being the original software.
  285. 3. This notice may not be removed or altered from any source
  286. distribution.
  287. */
  288. import sg "../gfx"
  289. import "core:c"
  290. _ :: c
  291. SOKOL_DEBUG :: #config(SOKOL_DEBUG, ODIN_DEBUG)
  292. DEBUG :: #config(SOKOL_SHAPE_DEBUG, SOKOL_DEBUG)
  293. USE_GL :: #config(SOKOL_USE_GL, false)
  294. USE_DLL :: #config(SOKOL_DLL, false)
  295. when ODIN_OS == .Windows {
  296. when USE_DLL {
  297. when USE_GL {
  298. when DEBUG { foreign import sokol_shape_clib { "../sokol_dll_windows_x64_gl_debug.lib" } }
  299. else { foreign import sokol_shape_clib { "../sokol_dll_windows_x64_gl_release.lib" } }
  300. } else {
  301. when DEBUG { foreign import sokol_shape_clib { "../sokol_dll_windows_x64_d3d11_debug.lib" } }
  302. else { foreign import sokol_shape_clib { "../sokol_dll_windows_x64_d3d11_release.lib" } }
  303. }
  304. } else {
  305. when USE_GL {
  306. when DEBUG { foreign import sokol_shape_clib { "sokol_shape_windows_x64_gl_debug.lib" } }
  307. else { foreign import sokol_shape_clib { "sokol_shape_windows_x64_gl_release.lib" } }
  308. } else {
  309. when DEBUG { foreign import sokol_shape_clib { "sokol_shape_windows_x64_d3d11_debug.lib" } }
  310. else { foreign import sokol_shape_clib { "sokol_shape_windows_x64_d3d11_release.lib" } }
  311. }
  312. }
  313. } else when ODIN_OS == .Darwin {
  314. when USE_DLL {
  315. when USE_GL && ODIN_ARCH == .arm64 && DEBUG { foreign import sokol_shape_clib { "../dylib/sokol_dylib_macos_arm64_gl_debug.dylib" } }
  316. else when USE_GL && ODIN_ARCH == .arm64 && !DEBUG { foreign import sokol_shape_clib { "../dylib/sokol_dylib_macos_arm64_gl_release.dylib" } }
  317. else when USE_GL && ODIN_ARCH == .amd64 && DEBUG { foreign import sokol_shape_clib { "../dylib/sokol_dylib_macos_x64_gl_debug.dylib" } }
  318. else when USE_GL && ODIN_ARCH == .amd64 && !DEBUG { foreign import sokol_shape_clib { "../dylib/sokol_dylib_macos_x64_gl_release.dylib" } }
  319. else when !USE_GL && ODIN_ARCH == .arm64 && DEBUG { foreign import sokol_shape_clib { "../dylib/sokol_dylib_macos_arm64_metal_debug.dylib" } }
  320. else when !USE_GL && ODIN_ARCH == .arm64 && !DEBUG { foreign import sokol_shape_clib { "../dylib/sokol_dylib_macos_arm64_metal_release.dylib" } }
  321. else when !USE_GL && ODIN_ARCH == .amd64 && DEBUG { foreign import sokol_shape_clib { "../dylib/sokol_dylib_macos_x64_metal_debug.dylib" } }
  322. else when !USE_GL && ODIN_ARCH == .amd64 && !DEBUG { foreign import sokol_shape_clib { "../dylib/sokol_dylib_macos_x64_metal_release.dylib" } }
  323. } else {
  324. when USE_GL {
  325. when ODIN_ARCH == .arm64 {
  326. when DEBUG { foreign import sokol_shape_clib { "sokol_shape_macos_arm64_gl_debug.a" } }
  327. else { foreign import sokol_shape_clib { "sokol_shape_macos_arm64_gl_release.a" } }
  328. } else {
  329. when DEBUG { foreign import sokol_shape_clib { "sokol_shape_macos_x64_gl_debug.a" } }
  330. else { foreign import sokol_shape_clib { "sokol_shape_macos_x64_gl_release.a" } }
  331. }
  332. } else {
  333. when ODIN_ARCH == .arm64 {
  334. when DEBUG { foreign import sokol_shape_clib { "sokol_shape_macos_arm64_metal_debug.a" } }
  335. else { foreign import sokol_shape_clib { "sokol_shape_macos_arm64_metal_release.a" } }
  336. } else {
  337. when DEBUG { foreign import sokol_shape_clib { "sokol_shape_macos_x64_metal_debug.a" } }
  338. else { foreign import sokol_shape_clib { "sokol_shape_macos_x64_metal_release.a" } }
  339. }
  340. }
  341. }
  342. } else when ODIN_OS == .Linux {
  343. when USE_DLL {
  344. when DEBUG { foreign import sokol_shape_clib { "sokol_shape_linux_x64_gl_debug.so" } }
  345. else { foreign import sokol_shape_clib { "sokol_shape_linux_x64_gl_release.so" } }
  346. } else {
  347. when DEBUG { foreign import sokol_shape_clib { "sokol_shape_linux_x64_gl_debug.a" } }
  348. else { foreign import sokol_shape_clib { "sokol_shape_linux_x64_gl_release.a" } }
  349. }
  350. } else when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 {
  351. // Feed sokol_shape_wasm_gl_debug.a or sokol_shape_wasm_gl_release.a into emscripten compiler.
  352. foreign import sokol_shape_clib { "env.o" }
  353. } else {
  354. #panic("This OS is currently not supported")
  355. }
  356. @(default_calling_convention="c", link_prefix="sshape_")
  357. foreign sokol_shape_clib {
  358. // shape builder functions
  359. build_plane :: proc(#by_ptr buf: Buffer, #by_ptr params: Plane) -> Buffer ---
  360. build_box :: proc(#by_ptr buf: Buffer, #by_ptr params: Box) -> Buffer ---
  361. build_sphere :: proc(#by_ptr buf: Buffer, #by_ptr params: Sphere) -> Buffer ---
  362. build_cylinder :: proc(#by_ptr buf: Buffer, #by_ptr params: Cylinder) -> Buffer ---
  363. build_torus :: proc(#by_ptr buf: Buffer, #by_ptr params: Torus) -> Buffer ---
  364. // query required vertex- and index-buffer sizes in bytes
  365. plane_sizes :: proc(tiles: u32) -> Sizes ---
  366. box_sizes :: proc(tiles: u32) -> Sizes ---
  367. sphere_sizes :: proc(slices: u32, stacks: u32) -> Sizes ---
  368. cylinder_sizes :: proc(slices: u32, stacks: u32) -> Sizes ---
  369. torus_sizes :: proc(sides: u32, rings: u32) -> Sizes ---
  370. // extract sokol-gfx desc structs and primitive ranges from build state
  371. element_range :: proc(#by_ptr buf: Buffer) -> Element_Range ---
  372. vertex_buffer_desc :: proc(#by_ptr buf: Buffer) -> sg.Buffer_Desc ---
  373. index_buffer_desc :: proc(#by_ptr buf: Buffer) -> sg.Buffer_Desc ---
  374. vertex_buffer_layout_state :: proc() -> sg.Vertex_Buffer_Layout_State ---
  375. position_vertex_attr_state :: proc() -> sg.Vertex_Attr_State ---
  376. normal_vertex_attr_state :: proc() -> sg.Vertex_Attr_State ---
  377. texcoord_vertex_attr_state :: proc() -> sg.Vertex_Attr_State ---
  378. color_vertex_attr_state :: proc() -> sg.Vertex_Attr_State ---
  379. // helper functions to build packed color value from floats or bytes
  380. color_4f :: proc(r: f32, g: f32, b: f32, a: f32) -> u32 ---
  381. color_3f :: proc(r: f32, g: f32, b: f32) -> u32 ---
  382. color_4b :: proc(r: u8, g: u8, b: u8, a: u8) -> u32 ---
  383. color_3b :: proc(r: u8, g: u8, b: u8) -> u32 ---
  384. // adapter function for filling matrix struct from generic float[16] array
  385. mat4 :: proc(m: ^f32) -> Mat4 ---
  386. mat4_transpose :: proc(m: ^f32) -> Mat4 ---
  387. }
  388. /*
  389. sshape_range is a pointer-size-pair struct used to pass memory
  390. blobs into sokol-shape. When initialized from a value type
  391. (array or struct), use the SSHAPE_RANGE() macro to build
  392. an sshape_range struct.
  393. */
  394. Range :: struct {
  395. ptr : rawptr,
  396. size : c.size_t,
  397. }
  398. // a 4x4 matrix wrapper struct
  399. Mat4 :: struct {
  400. m : [4][4]f32,
  401. }
  402. // vertex layout of the generated geometry
  403. Vertex :: struct {
  404. x : f32,
  405. y : f32,
  406. z : f32,
  407. normal : u32,
  408. u : u16,
  409. v : u16,
  410. color : u32,
  411. }
  412. // a range of draw-elements (sg_draw(int base_element, int num_element, ...))
  413. Element_Range :: struct {
  414. base_element : c.int,
  415. num_elements : c.int,
  416. }
  417. // number of elements and byte size of build actions
  418. Sizes_Item :: struct {
  419. num : u32,
  420. size : u32,
  421. }
  422. Sizes :: struct {
  423. vertices : Sizes_Item,
  424. indices : Sizes_Item,
  425. }
  426. // in/out struct to keep track of mesh-build state
  427. Buffer_Item :: struct {
  428. buffer : Range,
  429. data_size : c.size_t,
  430. shape_offset : c.size_t,
  431. }
  432. Buffer :: struct {
  433. valid : bool,
  434. vertices : Buffer_Item,
  435. indices : Buffer_Item,
  436. }
  437. // creation parameters for the different shape types
  438. Plane :: struct {
  439. width : f32,
  440. depth : f32,
  441. tiles : u16,
  442. color : u32,
  443. random_colors : bool,
  444. merge : bool,
  445. transform : Mat4,
  446. }
  447. Box :: struct {
  448. width : f32,
  449. height : f32,
  450. depth : f32,
  451. tiles : u16,
  452. color : u32,
  453. random_colors : bool,
  454. merge : bool,
  455. transform : Mat4,
  456. }
  457. Sphere :: struct {
  458. radius : f32,
  459. slices : u16,
  460. stacks : u16,
  461. color : u32,
  462. random_colors : bool,
  463. merge : bool,
  464. transform : Mat4,
  465. }
  466. Cylinder :: struct {
  467. radius : f32,
  468. height : f32,
  469. slices : u16,
  470. stacks : u16,
  471. color : u32,
  472. random_colors : bool,
  473. merge : bool,
  474. transform : Mat4,
  475. }
  476. Torus :: struct {
  477. radius : f32,
  478. ring_radius : f32,
  479. sides : u16,
  480. rings : u16,
  481. color : u32,
  482. random_colors : bool,
  483. merge : bool,
  484. transform : Mat4,
  485. }