koffi 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/ChangeLog.md +6 -0
  2. package/build/qemu/2.1.2/koffi_darwin_arm64.tar.gz +0 -0
  3. package/build/qemu/2.1.2/koffi_darwin_x64.tar.gz +0 -0
  4. package/build/qemu/2.1.2/koffi_freebsd_arm64.tar.gz +0 -0
  5. package/build/qemu/2.1.2/koffi_freebsd_ia32.tar.gz +0 -0
  6. package/build/qemu/2.1.2/koffi_freebsd_x64.tar.gz +0 -0
  7. package/build/qemu/2.1.2/koffi_linux_arm32hf.tar.gz +0 -0
  8. package/build/qemu/2.1.2/koffi_linux_arm64.tar.gz +0 -0
  9. package/build/qemu/2.1.2/koffi_linux_ia32.tar.gz +0 -0
  10. package/build/qemu/2.1.2/koffi_linux_riscv64hf64.tar.gz +0 -0
  11. package/build/qemu/2.1.2/koffi_linux_x64.tar.gz +0 -0
  12. package/build/qemu/2.1.2/koffi_openbsd_ia32.tar.gz +0 -0
  13. package/build/qemu/2.1.2/koffi_openbsd_x64.tar.gz +0 -0
  14. package/build/qemu/2.1.2/koffi_win32_arm64.tar.gz +0 -0
  15. package/build/qemu/2.1.2/koffi_win32_ia32.tar.gz +0 -0
  16. package/build/qemu/2.1.2/koffi_win32_x64.tar.gz +0 -0
  17. package/doc/templates/badges.html +3 -0
  18. package/package.json +2 -2
  19. package/src/abi_arm64.cc +35 -1
  20. package/src/abi_x64_win.cc +2 -8
  21. package/src/abi_x86.cc +1 -7
  22. package/src/ffi.hh +1 -1
  23. package/src/util.hh +6 -0
  24. package/test/raylib.js +37 -5
  25. package/vendor/libcc/libcc.cc +430 -196
  26. package/vendor/libcc/libcc.hh +1417 -1283
  27. package/vendor/raylib/BINDINGS.md +87 -70
  28. package/vendor/raylib/CHANGELOG +263 -50
  29. package/vendor/raylib/CMakeLists.txt +12 -0
  30. package/vendor/raylib/CMakeOptions.txt +8 -1
  31. package/vendor/raylib/CONVENTIONS.md +2 -3
  32. package/vendor/raylib/FAQ.md +137 -0
  33. package/vendor/raylib/HISTORY.md +62 -29
  34. package/vendor/raylib/LICENSE +1 -1
  35. package/vendor/raylib/README.md +22 -17
  36. package/vendor/raylib/ROADMAP.md +8 -7
  37. package/vendor/raylib/cmake/CompileDefinitions.cmake +19 -15
  38. package/vendor/raylib/cmake/GlfwImport.cmake +2 -0
  39. package/vendor/raylib/cmake/LibraryConfigurations.cmake +22 -16
  40. package/vendor/raylib/cmake/raylib-config.cmake +52 -49
  41. package/vendor/raylib/examples/CMakeLists.txt +14 -9
  42. package/vendor/raylib/examples/Makefile +112 -125
  43. package/vendor/raylib/examples/Makefile.Android +1 -1
  44. package/vendor/raylib/examples/Makefile.Web +145 -158
  45. package/vendor/raylib/examples/README.md +141 -141
  46. package/vendor/raylib/examples/audio/audio_module_playing.c +9 -4
  47. package/vendor/raylib/examples/audio/audio_multichannel_sound.c +8 -3
  48. package/vendor/raylib/examples/audio/audio_music_stream.c +16 -11
  49. package/vendor/raylib/examples/audio/audio_raw_stream.c +57 -9
  50. package/vendor/raylib/examples/audio/audio_sound_loading.c +8 -3
  51. package/vendor/raylib/examples/audio/audio_stream_effects.c +179 -0
  52. package/vendor/raylib/examples/audio/audio_stream_effects.png +0 -0
  53. package/vendor/raylib/examples/build.zig +17 -6
  54. package/vendor/raylib/examples/core/core_2d_camera.c +8 -4
  55. package/vendor/raylib/examples/core/core_2d_camera_mouse_zoom.c +105 -0
  56. package/vendor/raylib/examples/core/core_2d_camera_mouse_zoom.png +0 -0
  57. package/vendor/raylib/examples/core/core_2d_camera_platformer.c +11 -6
  58. package/vendor/raylib/examples/core/core_3d_camera_first_person.c +9 -4
  59. package/vendor/raylib/examples/core/core_3d_camera_free.c +9 -4
  60. package/vendor/raylib/examples/core/core_3d_camera_mode.c +8 -3
  61. package/vendor/raylib/examples/core/core_3d_picking.c +9 -4
  62. package/vendor/raylib/examples/core/core_basic_screen_manager.c +9 -7
  63. package/vendor/raylib/examples/core/core_basic_window.c +8 -3
  64. package/vendor/raylib/examples/core/core_basic_window_web.c +13 -11
  65. package/vendor/raylib/examples/core/core_custom_frame_control.c +9 -4
  66. package/vendor/raylib/examples/core/core_custom_logging.c +12 -8
  67. package/vendor/raylib/examples/core/core_drop_files.c +20 -12
  68. package/vendor/raylib/examples/core/core_input_gamepad.c +20 -15
  69. package/vendor/raylib/examples/core/core_input_gestures.c +19 -15
  70. package/vendor/raylib/examples/core/core_input_keys.c +8 -3
  71. package/vendor/raylib/examples/core/core_input_mouse.c +8 -3
  72. package/vendor/raylib/examples/core/core_input_mouse_wheel.c +8 -3
  73. package/vendor/raylib/examples/core/core_input_multitouch.c +8 -3
  74. package/vendor/raylib/examples/core/core_loading_thread.c +10 -6
  75. package/vendor/raylib/examples/core/core_random_values.c +8 -3
  76. package/vendor/raylib/examples/core/core_scissor_test.c +8 -3
  77. package/vendor/raylib/examples/core/core_smooth_pixelperfect.c +9 -4
  78. package/vendor/raylib/examples/core/core_split_screen.c +8 -3
  79. package/vendor/raylib/examples/core/core_storage_values.c +109 -3
  80. package/vendor/raylib/examples/core/core_vr_simulator.c +15 -7
  81. package/vendor/raylib/examples/core/core_window_flags.c +8 -3
  82. package/vendor/raylib/examples/core/core_window_letterbox.c +13 -18
  83. package/vendor/raylib/examples/core/core_window_should_close.c +77 -0
  84. package/vendor/raylib/examples/core/core_window_should_close.png +0 -0
  85. package/vendor/raylib/examples/core/core_world_screen.c +9 -4
  86. package/vendor/raylib/examples/examples_template.c +8 -3
  87. package/vendor/raylib/examples/models/models_animation.c +11 -7
  88. package/vendor/raylib/examples/models/models_billboard.c +9 -4
  89. package/vendor/raylib/examples/models/models_box_collisions.c +8 -3
  90. package/vendor/raylib/examples/models/models_cubicmap.c +9 -4
  91. package/vendor/raylib/examples/models/models_first_person_maze.c +9 -4
  92. package/vendor/raylib/examples/models/models_geometric_shapes.c +8 -3
  93. package/vendor/raylib/examples/models/models_heightmap.c +9 -4
  94. package/vendor/raylib/examples/models/models_loading.c +21 -17
  95. package/vendor/raylib/examples/models/models_loading_gltf.c +15 -41
  96. package/vendor/raylib/examples/models/models_loading_vox.c +9 -4
  97. package/vendor/raylib/examples/models/models_mesh_generation.c +71 -58
  98. package/vendor/raylib/examples/models/models_mesh_picking.c +25 -7
  99. package/vendor/raylib/examples/models/models_orthographic_projection.c +8 -5
  100. package/vendor/raylib/examples/models/models_rlgl_solar_system.c +6 -4
  101. package/vendor/raylib/examples/models/models_skybox.c +16 -12
  102. package/vendor/raylib/examples/models/models_waving_cubes.c +9 -4
  103. package/vendor/raylib/examples/models/models_yaw_pitch_roll.c +12 -7
  104. package/vendor/raylib/examples/models/resources/LICENSE.md +9 -10
  105. package/vendor/raylib/examples/models/resources/models/gltf/LICENSE +2 -23
  106. package/vendor/raylib/examples/models/resources/models/gltf/{raylib_32x32.glb → raylib_logo_3d.glb} +0 -0
  107. package/vendor/raylib/examples/models/resources/models/gltf/robot.blend +0 -0
  108. package/vendor/raylib/examples/models/resources/models/gltf/robot.glb +0 -0
  109. package/vendor/raylib/examples/others/easings_testbed.c +10 -8
  110. package/vendor/raylib/examples/others/easings_testbed.png +0 -0
  111. package/vendor/raylib/examples/others/embedded_files_loading.c +10 -5
  112. package/vendor/raylib/examples/others/embedded_files_loading.png +0 -0
  113. package/vendor/raylib/examples/others/raylib_opengl_interop.c +10 -6
  114. package/vendor/raylib/{src/extras/easings.h → examples/others/reasings.h} +38 -38
  115. package/vendor/raylib/examples/others/rlgl_compute_shader.c +21 -20
  116. package/vendor/raylib/examples/others/rlgl_compute_shader.png +0 -0
  117. package/vendor/raylib/examples/others/rlgl_standalone.c +4 -4
  118. package/vendor/raylib/examples/others/rlgl_standalone.png +0 -0
  119. package/vendor/raylib/examples/raylib_compile_execute.bat +2 -2
  120. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/lighting.fs +1 -1
  121. package/vendor/raylib/examples/shaders/resources/shaders/glsl330/{base_lighting_instanced.vs → lighting_instancing.vs} +2 -2
  122. package/vendor/raylib/examples/shaders/rlights.h +14 -27
  123. package/vendor/raylib/examples/shaders/shaders_basic_lighting.c +24 -26
  124. package/vendor/raylib/examples/shaders/shaders_custom_uniform.c +10 -5
  125. package/vendor/raylib/examples/shaders/shaders_eratosthenes.c +13 -8
  126. package/vendor/raylib/examples/shaders/shaders_fog.c +8 -12
  127. package/vendor/raylib/examples/shaders/shaders_hot_reloading.c +10 -5
  128. package/vendor/raylib/examples/shaders/shaders_julia_set.c +9 -4
  129. package/vendor/raylib/examples/shaders/shaders_mesh_instancing.c +45 -119
  130. package/vendor/raylib/examples/shaders/shaders_model_shader.c +10 -5
  131. package/vendor/raylib/examples/shaders/shaders_multi_sample2d.c +8 -3
  132. package/vendor/raylib/examples/shaders/shaders_palette_switch.c +8 -3
  133. package/vendor/raylib/examples/shaders/shaders_postprocessing.c +9 -4
  134. package/vendor/raylib/examples/shaders/shaders_raymarching.c +14 -11
  135. package/vendor/raylib/examples/shaders/shaders_shapes_textures.c +8 -3
  136. package/vendor/raylib/examples/shaders/shaders_simple_mask.c +10 -5
  137. package/vendor/raylib/examples/shaders/shaders_spotlight.c +10 -6
  138. package/vendor/raylib/examples/shaders/shaders_texture_drawing.c +9 -4
  139. package/vendor/raylib/examples/shaders/shaders_texture_outline.c +8 -3
  140. package/vendor/raylib/examples/shaders/shaders_texture_waves.c +8 -3
  141. package/vendor/raylib/{src/extras → examples/shapes}/raygui.h +1290 -1141
  142. package/vendor/raylib/examples/{others/easings.h → shapes/reasings.h} +40 -40
  143. package/vendor/raylib/examples/shapes/shapes_basic_shapes.c +8 -3
  144. package/vendor/raylib/examples/shapes/shapes_bouncing_ball.c +8 -3
  145. package/vendor/raylib/examples/shapes/shapes_collision_area.c +10 -4
  146. package/vendor/raylib/examples/shapes/shapes_colors_palette.c +8 -3
  147. package/vendor/raylib/examples/shapes/shapes_draw_circle_sector.c +9 -4
  148. package/vendor/raylib/examples/shapes/shapes_draw_rectangle_rounded.c +9 -4
  149. package/vendor/raylib/examples/shapes/shapes_draw_ring.c +10 -6
  150. package/vendor/raylib/examples/shapes/shapes_easings_ball_anim.c +9 -4
  151. package/vendor/raylib/examples/shapes/shapes_easings_box_anim.c +9 -4
  152. package/vendor/raylib/examples/shapes/shapes_easings_rectangle_array.c +9 -4
  153. package/vendor/raylib/examples/shapes/shapes_following_eyes.c +8 -3
  154. package/vendor/raylib/examples/shapes/shapes_lines_bezier.c +8 -3
  155. package/vendor/raylib/examples/shapes/shapes_logo_raylib.c +8 -3
  156. package/vendor/raylib/examples/shapes/shapes_logo_raylib_anim.c +8 -3
  157. package/vendor/raylib/examples/shapes/shapes_rectangle_scaling.c +14 -5
  158. package/vendor/raylib/examples/shapes/shapes_top_down_lights.c +355 -0
  159. package/vendor/raylib/examples/shapes/shapes_top_down_lights.png +0 -0
  160. package/vendor/raylib/examples/text/resources/DotGothic16-Regular.ttf +0 -0
  161. package/vendor/raylib/examples/text/resources/DotGothic16-Regular_OFL.txt +93 -0
  162. package/vendor/raylib/examples/text/resources/LICENSE.md +1 -1
  163. package/vendor/raylib/examples/text/text_codepoints_loading.c +138 -0
  164. package/vendor/raylib/examples/text/text_codepoints_loading.png +0 -0
  165. package/vendor/raylib/examples/text/text_draw_3d.c +42 -33
  166. package/vendor/raylib/examples/text/text_font_filters.c +14 -11
  167. package/vendor/raylib/examples/text/text_font_loading.c +9 -4
  168. package/vendor/raylib/examples/text/text_font_sdf.c +9 -4
  169. package/vendor/raylib/examples/text/text_font_spritefont.c +12 -6
  170. package/vendor/raylib/examples/text/text_format_text.c +8 -3
  171. package/vendor/raylib/examples/text/text_input_box.c +8 -3
  172. package/vendor/raylib/examples/text/text_raylib_fonts.c +9 -4
  173. package/vendor/raylib/examples/text/text_rectangle_bounds.c +9 -5
  174. package/vendor/raylib/examples/text/text_unicode.c +9 -7
  175. package/vendor/raylib/examples/text/text_writing_anim.c +8 -3
  176. package/vendor/raylib/examples/textures/resources/scarfy_run.gif +0 -0
  177. package/vendor/raylib/examples/textures/textures_background_scrolling.c +8 -3
  178. package/vendor/raylib/examples/textures/textures_blend_modes.c +8 -3
  179. package/vendor/raylib/examples/textures/textures_bunnymark.c +8 -3
  180. package/vendor/raylib/examples/textures/textures_draw_tiled.c +14 -10
  181. package/vendor/raylib/examples/textures/textures_fog_of_war.c +154 -0
  182. package/vendor/raylib/examples/textures/textures_fog_of_war.png +0 -0
  183. package/vendor/raylib/examples/textures/textures_gif_player.c +121 -0
  184. package/vendor/raylib/examples/textures/textures_gif_player.png +0 -0
  185. package/vendor/raylib/examples/textures/textures_image_drawing.c +8 -3
  186. package/vendor/raylib/examples/textures/textures_image_generation.c +8 -3
  187. package/vendor/raylib/examples/textures/textures_image_loading.c +8 -3
  188. package/vendor/raylib/examples/textures/textures_image_processing.c +8 -3
  189. package/vendor/raylib/examples/textures/textures_image_text.c +8 -3
  190. package/vendor/raylib/examples/textures/textures_logo_raylib.c +8 -3
  191. package/vendor/raylib/examples/textures/textures_mouse_painting.c +9 -4
  192. package/vendor/raylib/examples/textures/textures_npatch_drawing.c +8 -3
  193. package/vendor/raylib/examples/textures/textures_particles_blending.c +8 -3
  194. package/vendor/raylib/examples/textures/textures_polygon.c +9 -5
  195. package/vendor/raylib/examples/textures/textures_raw_data.c +8 -3
  196. package/vendor/raylib/examples/textures/{textures_rectangle.c → textures_sprite_anim.c} +11 -5
  197. package/vendor/raylib/examples/textures/{textures_rectangle.png → textures_sprite_anim.png} +0 -0
  198. package/vendor/raylib/examples/textures/textures_sprite_button.c +8 -3
  199. package/vendor/raylib/examples/textures/textures_sprite_explosion.c +8 -3
  200. package/vendor/raylib/examples/textures/textures_srcrec_dstrec.c +8 -3
  201. package/vendor/raylib/examples/textures/textures_to_image.c +8 -3
  202. package/vendor/raylib/parser/LICENSE +1 -1
  203. package/vendor/raylib/parser/Makefile +28 -0
  204. package/vendor/raylib/parser/README.md +49 -5
  205. package/vendor/raylib/parser/output/raylib_api.json +10717 -0
  206. package/vendor/raylib/parser/output/raylib_api.lua +7435 -0
  207. package/vendor/raylib/parser/{raylib_api.txt → output/raylib_api.txt} +1371 -824
  208. package/vendor/raylib/parser/{raylib_api.xml → output/raylib_api.xml} +827 -595
  209. package/vendor/raylib/parser/raylib_parser.c +1174 -196
  210. package/vendor/raylib/projects/4coder/Makefile +2 -4
  211. package/vendor/raylib/projects/4coder/main.c +0 -1
  212. package/vendor/raylib/projects/CMake/CMakeLists.txt +13 -16
  213. package/vendor/raylib/projects/CMake/README.md +27 -0
  214. package/vendor/raylib/projects/CMake/core_basic_window.c +52 -31
  215. package/vendor/raylib/projects/CodeBlocks/README.md +4 -4
  216. package/vendor/raylib/projects/Geany/core_basic_window.c +1 -1
  217. package/vendor/raylib/projects/Notepad++/c_raylib.xml +168 -128
  218. package/vendor/raylib/projects/Notepad++/npes_saved_tcc.txt +0 -0
  219. package/vendor/raylib/projects/Notepad++/npes_saved_w64devkit.txt +0 -0
  220. package/vendor/raylib/projects/Notepad++/npes_saved_zig.txt +0 -0
  221. package/vendor/raylib/projects/Notepad++/raylib_npp_parser/raylib_npp.xml +168 -84
  222. package/vendor/raylib/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h +67 -51
  223. package/vendor/raylib/projects/README.md +1 -1
  224. package/vendor/raylib/projects/VSCode/.vscode/c_cpp_properties.json +1 -1
  225. package/vendor/raylib/projects/VSCode/Makefile +8 -11
  226. package/vendor/raylib/projects/VSCode/main.c +53 -26
  227. package/vendor/raylib/projects/VSCode/resources/LICENSE +1 -0
  228. package/vendor/raylib/projects/scripts/build-linux.sh +6 -6
  229. package/vendor/raylib/projects/scripts/build-osx.sh +6 -6
  230. package/vendor/raylib/projects/scripts/build-rpi.sh +6 -6
  231. package/vendor/raylib/projects/scripts/build-windows.bat +2 -2
  232. package/vendor/raylib/src/CMakeLists.txt +6 -7
  233. package/vendor/raylib/src/Makefile +209 -103
  234. package/vendor/raylib/src/build.zig +56 -20
  235. package/vendor/raylib/src/config.h +32 -27
  236. package/vendor/raylib/src/external/cgltf.h +342 -104
  237. package/vendor/raylib/src/external/dr_wav.h +487 -225
  238. package/vendor/raylib/src/external/glfw/src/posix_time.c +1 -3
  239. package/vendor/raylib/src/external/glfw/src/wl_init.c +1 -3
  240. package/vendor/raylib/src/external/jar_xm.h +2 -1
  241. package/vendor/raylib/src/external/miniaudio.h +62251 -42061
  242. package/vendor/raylib/src/external/qoi.h +671 -0
  243. package/vendor/raylib/src/external/stb_vorbis.h +1 -1
  244. package/vendor/raylib/src/external/vox_loader.h +30 -25
  245. package/vendor/raylib/src/minshell.html +82 -0
  246. package/vendor/raylib/src/raudio.c +359 -201
  247. package/vendor/raylib/src/raylib.dll.rc +5 -5
  248. package/vendor/raylib/src/raylib.dll.rc.data +0 -0
  249. package/vendor/raylib/src/raylib.h +95 -63
  250. package/vendor/raylib/src/raylib.rc +5 -5
  251. package/vendor/raylib/src/raylib.rc.data +0 -0
  252. package/vendor/raylib/src/raymath.h +391 -133
  253. package/vendor/raylib/src/rcamera.h +32 -41
  254. package/vendor/raylib/src/rcore.c +775 -471
  255. package/vendor/raylib/src/rgestures.h +5 -5
  256. package/vendor/raylib/src/rglfw.c +3 -3
  257. package/vendor/raylib/src/rlgl.h +184 -144
  258. package/vendor/raylib/src/rmodels.c +207 -144
  259. package/vendor/raylib/src/rshapes.c +105 -47
  260. package/vendor/raylib/src/rtext.c +255 -38
  261. package/vendor/raylib/src/rtextures.c +167 -71
  262. package/vendor/raylib/src/shell.html +63 -63
  263. package/vendor/raylib/src/utils.c +49 -3
  264. package/vendor/raylib/src/utils.h +3 -3
  265. package/build/qemu/2.1.1/koffi_darwin_arm64.tar.gz +0 -0
  266. package/build/qemu/2.1.1/koffi_darwin_x64.tar.gz +0 -0
  267. package/build/qemu/2.1.1/koffi_freebsd_arm64.tar.gz +0 -0
  268. package/build/qemu/2.1.1/koffi_freebsd_ia32.tar.gz +0 -0
  269. package/build/qemu/2.1.1/koffi_freebsd_x64.tar.gz +0 -0
  270. package/build/qemu/2.1.1/koffi_linux_arm32hf.tar.gz +0 -0
  271. package/build/qemu/2.1.1/koffi_linux_arm64.tar.gz +0 -0
  272. package/build/qemu/2.1.1/koffi_linux_ia32.tar.gz +0 -0
  273. package/build/qemu/2.1.1/koffi_linux_riscv64hf64.tar.gz +0 -0
  274. package/build/qemu/2.1.1/koffi_linux_x64.tar.gz +0 -0
  275. package/build/qemu/2.1.1/koffi_openbsd_ia32.tar.gz +0 -0
  276. package/build/qemu/2.1.1/koffi_openbsd_x64.tar.gz +0 -0
  277. package/build/qemu/2.1.1/koffi_win32_arm64.tar.gz +0 -0
  278. package/build/qemu/2.1.1/koffi_win32_ia32.tar.gz +0 -0
  279. package/build/qemu/2.1.1/koffi_win32_x64.tar.gz +0 -0
  280. package/vendor/raylib/CONTRIBUTORS.md +0 -63
  281. package/vendor/raylib/SPONSORS.md +0 -68
  282. package/vendor/raylib/examples/core/core_quat_conversion.c +0 -132
  283. package/vendor/raylib/examples/core/core_quat_conversion.png +0 -0
  284. package/vendor/raylib/examples/models/resources/models/gltf/AnimatedMorphCube.glb +0 -0
  285. package/vendor/raylib/examples/models/resources/models/gltf/AnimatedTriangle.gltf +0 -118
  286. package/vendor/raylib/examples/models/resources/models/gltf/BoxAnimated.glb +0 -0
  287. package/vendor/raylib/examples/models/resources/models/gltf/girl.glb +0 -0
  288. package/vendor/raylib/examples/models/resources/models/gltf/rigged_figure.glb +0 -0
  289. package/vendor/raylib/examples/models/resources/models/gltf/vertex_colored_object.glb +0 -0
  290. package/vendor/raylib/examples/models/resources/models/iqm/vertex_colored_object.iqm +0 -0
  291. package/vendor/raylib/examples/models/rlights.h +0 -183
  292. package/vendor/raylib/examples/others/raudio_standalone.c +0 -152
  293. package/vendor/raylib/examples/others/resources/audio/country.mp3 +0 -0
  294. package/vendor/raylib/examples/others/resources/audio/target.ogg +0 -0
  295. package/vendor/raylib/examples/others/resources/audio/weird.wav +0 -0
  296. package/vendor/raylib/examples/physics/physics_demo.c +0 -128
  297. package/vendor/raylib/examples/physics/physics_demo.png +0 -0
  298. package/vendor/raylib/examples/physics/physics_friction.c +0 -142
  299. package/vendor/raylib/examples/physics/physics_friction.png +0 -0
  300. package/vendor/raylib/examples/physics/physics_movement.c +0 -128
  301. package/vendor/raylib/examples/physics/physics_movement.png +0 -0
  302. package/vendor/raylib/examples/physics/physics_restitution.c +0 -129
  303. package/vendor/raylib/examples/physics/physics_restitution.png +0 -0
  304. package/vendor/raylib/examples/physics/physics_shatter.c +0 -111
  305. package/vendor/raylib/examples/physics/physics_shatter.png +0 -0
  306. package/vendor/raylib/parser/raylib_api.json +0 -6668
  307. package/vendor/raylib/projects/VS2019/raylib/raylib.rc +0 -0
  308. package/vendor/raylib/projects/VS2019/raylib/resource.h +0 -14
  309. package/vendor/raylib/src/extras/physac.h +0 -1977
  310. package/vendor/raylib/src/extras/rmem.h +0 -751
  311. package/vendor/raylib/src/raudio.h +0 -198
@@ -4,12 +4,14 @@
4
4
  *
5
5
  * CONFIGURATION:
6
6
  *
7
+ * #define SUPPORT_MODULE_RMODELS
8
+ * rmodels module is included in the build
9
+ *
7
10
  * #define SUPPORT_FILEFORMAT_OBJ
8
11
  * #define SUPPORT_FILEFORMAT_MTL
9
12
  * #define SUPPORT_FILEFORMAT_IQM
10
13
  * #define SUPPORT_FILEFORMAT_GLTF
11
14
  * #define SUPPORT_FILEFORMAT_VOX
12
- *
13
15
  * Selected desired fileformats to be supported for model data loading.
14
16
  *
15
17
  * #define SUPPORT_MESH_GENERATION
@@ -19,7 +21,7 @@
19
21
  *
20
22
  * LICENSE: zlib/libpng
21
23
  *
22
- * Copyright (c) 2013-2021 Ramon Santamaria (@raysan5)
24
+ * Copyright (c) 2013-2022 Ramon Santamaria (@raysan5)
23
25
  *
24
26
  * This software is provided "as-is", without any express or implied warranty. In no event
25
27
  * will the authors be held liable for any damages arising from the use of this software.
@@ -45,6 +47,8 @@
45
47
  #include "config.h" // Defines module configuration flags
46
48
  #endif
47
49
 
50
+ #if defined(SUPPORT_MODULE_RMODELS)
51
+
48
52
  #include "utils.h" // Required for: TRACELOG(), LoadFileData(), LoadFileText(), SaveFileText()
49
53
  #include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 2.1, 3.3+ or ES2
50
54
  #include "raymath.h" // Required for: Vector3, Quaternion and Matrix functionality
@@ -148,7 +152,7 @@ void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color)
148
152
  // WARNING: Be careful with internal buffer vertex alignment
149
153
  // when using RL_LINES or RL_TRIANGLES, data is aligned to fit
150
154
  // lines-triangles-quads in the same indexed buffers!!!
151
- rlCheckRenderBatchLimit(8);
155
+ //rlCheckRenderBatchLimit(8);
152
156
 
153
157
  rlBegin(RL_LINES);
154
158
  rlColor4ub(color.r, color.g, color.b, color.a);
@@ -160,7 +164,7 @@ void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color)
160
164
  // Draw a point in 3D space, actually a small line
161
165
  void DrawPoint3D(Vector3 position, Color color)
162
166
  {
163
- rlCheckRenderBatchLimit(8);
167
+ //rlCheckRenderBatchLimit(8);
164
168
 
165
169
  rlPushMatrix();
166
170
  rlTranslatef(position.x, position.y, position.z);
@@ -175,7 +179,7 @@ void DrawPoint3D(Vector3 position, Color color)
175
179
  // Draw a circle in 3D world space
176
180
  void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color)
177
181
  {
178
- rlCheckRenderBatchLimit(2*36);
182
+ //rlCheckRenderBatchLimit(2*36);
179
183
 
180
184
  rlPushMatrix();
181
185
  rlTranslatef(center.x, center.y, center.z);
@@ -196,7 +200,7 @@ void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rota
196
200
  // Draw a color-filled triangle (vertex in counter-clockwise order!)
197
201
  void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color)
198
202
  {
199
- rlCheckRenderBatchLimit(3);
203
+ //rlCheckRenderBatchLimit(8);
200
204
 
201
205
  rlBegin(RL_TRIANGLES);
202
206
  rlColor4ub(color.r, color.g, color.b, color.a);
@@ -211,7 +215,7 @@ void DrawTriangleStrip3D(Vector3 *points, int pointCount, Color color)
211
215
  {
212
216
  if (pointCount >= 3)
213
217
  {
214
- rlCheckRenderBatchLimit(3*(pointCount - 2));
218
+ //rlCheckRenderBatchLimit(3*(pointCount - 2));
215
219
 
216
220
  rlBegin(RL_TRIANGLES);
217
221
  rlColor4ub(color.r, color.g, color.b, color.a);
@@ -243,7 +247,7 @@ void DrawCube(Vector3 position, float width, float height, float length, Color c
243
247
  float y = 0.0f;
244
248
  float z = 0.0f;
245
249
 
246
- rlCheckRenderBatchLimit(36);
250
+ //rlCheckRenderBatchLimit(36);
247
251
 
248
252
  rlPushMatrix();
249
253
  // NOTE: Transformation is applied in inverse order (scale -> rotate -> translate)
@@ -324,7 +328,7 @@ void DrawCubeWires(Vector3 position, float width, float height, float length, Co
324
328
  float y = 0.0f;
325
329
  float z = 0.0f;
326
330
 
327
- rlCheckRenderBatchLimit(36);
331
+ //rlCheckRenderBatchLimit(36);
328
332
 
329
333
  rlPushMatrix();
330
334
  rlTranslatef(position.x, position.y, position.z);
@@ -401,7 +405,7 @@ void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float hei
401
405
  float y = position.y;
402
406
  float z = position.z;
403
407
 
404
- rlCheckRenderBatchLimit(36);
408
+ //rlCheckRenderBatchLimit(36);
405
409
 
406
410
  rlSetTexture(texture.id);
407
411
 
@@ -464,7 +468,7 @@ void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, f
464
468
  float texWidth = (float)texture.width;
465
469
  float texHeight = (float)texture.height;
466
470
 
467
- rlCheckRenderBatchLimit(36);
471
+ //rlCheckRenderBatchLimit(36);
468
472
 
469
473
  rlSetTexture(texture.id);
470
474
 
@@ -551,8 +555,8 @@ void DrawSphere(Vector3 centerPos, float radius, Color color)
551
555
  // Draw sphere with extended parameters
552
556
  void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color)
553
557
  {
554
- int numVertex = (rings + 2)*slices*6;
555
- rlCheckRenderBatchLimit(numVertex);
558
+ //int numVertex = (rings + 2)*slices*6;
559
+ //rlCheckRenderBatchLimit(numVertex);
556
560
 
557
561
  rlPushMatrix();
558
562
  // NOTE: Transformation is applied in inverse order (scale -> translate)
@@ -594,8 +598,8 @@ void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color
594
598
  // Draw sphere wires
595
599
  void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color)
596
600
  {
597
- int numVertex = (rings + 2)*slices*6;
598
- rlCheckRenderBatchLimit(numVertex);
601
+ //int numVertex = (rings + 2)*slices*6;
602
+ //rlCheckRenderBatchLimit(numVertex);
599
603
 
600
604
  rlPushMatrix();
601
605
  // NOTE: Transformation is applied in inverse order (scale -> translate)
@@ -641,8 +645,8 @@ void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float h
641
645
  {
642
646
  if (sides < 3) sides = 3;
643
647
 
644
- int numVertex = sides*6;
645
- rlCheckRenderBatchLimit(numVertex);
648
+ //int numVertex = sides*6;
649
+ //rlCheckRenderBatchLimit(numVertex);
646
650
 
647
651
  rlPushMatrix();
648
652
  rlTranslatef(position.x, position.y, position.z);
@@ -700,8 +704,8 @@ void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float e
700
704
  {
701
705
  if (sides < 3) sides = 3;
702
706
 
703
- int numVertex = sides*6;
704
- rlCheckRenderBatchLimit(numVertex);
707
+ //int numVertex = sides*6;
708
+ //rlCheckRenderBatchLimit(numVertex);
705
709
 
706
710
  Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
707
711
  if ((direction.x == 0) && (direction.y == 0) && (direction.z == 0)) return;
@@ -759,8 +763,8 @@ void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, fl
759
763
  {
760
764
  if (sides < 3) sides = 3;
761
765
 
762
- int numVertex = sides*8;
763
- rlCheckRenderBatchLimit(numVertex);
766
+ //int numVertex = sides*8;
767
+ //rlCheckRenderBatchLimit(numVertex);
764
768
 
765
769
  rlPushMatrix();
766
770
  rlTranslatef(position.x, position.y, position.z);
@@ -793,8 +797,8 @@ void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, fl
793
797
  {
794
798
  if (sides < 3) sides = 3;
795
799
 
796
- int numVertex = sides*6;
797
- rlCheckRenderBatchLimit(numVertex);
800
+ //int numVertex = sides*6;
801
+ //rlCheckRenderBatchLimit(numVertex);
798
802
 
799
803
  Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
800
804
  if ((direction.x == 0) && (direction.y == 0) && (direction.z == 0))return;
@@ -839,7 +843,7 @@ void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, fl
839
843
  // Draw a plane
840
844
  void DrawPlane(Vector3 centerPos, Vector2 size, Color color)
841
845
  {
842
- rlCheckRenderBatchLimit(4);
846
+ //rlCheckRenderBatchLimit(4);
843
847
 
844
848
  // NOTE: Plane is always created on XZ ground
845
849
  rlPushMatrix();
@@ -877,7 +881,7 @@ void DrawGrid(int slices, float spacing)
877
881
  {
878
882
  int halfSlices = slices/2;
879
883
 
880
- rlCheckRenderBatchLimit((slices + 2)*4);
884
+ //rlCheckRenderBatchLimit((slices + 2)*4);
881
885
 
882
886
  rlBegin(RL_LINES);
883
887
  for (int i = -halfSlices; i <= halfSlices; i++)
@@ -918,7 +922,7 @@ Model LoadModel(const char *fileName)
918
922
  if (IsFileExtension(fileName, ".iqm")) model = LoadIQM(fileName);
919
923
  #endif
920
924
  #if defined(SUPPORT_FILEFORMAT_GLTF)
921
- if (IsFileExtension(fileName, ".gltf;.glb")) model = LoadGLTF(fileName);
925
+ if (IsFileExtension(fileName, ".gltf") || IsFileExtension(fileName, ".glb")) model = LoadGLTF(fileName);
922
926
  #endif
923
927
  #if defined(SUPPORT_FILEFORMAT_VOX)
924
928
  if (IsFileExtension(fileName, ".vox")) model = LoadVOX(fileName);
@@ -1083,7 +1087,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
1083
1087
  mesh->vaoId = rlLoadVertexArray();
1084
1088
  rlEnableVertexArray(mesh->vaoId);
1085
1089
 
1086
- // NOTE: Attributes must be uploaded considering default locations points
1090
+ // NOTE: Vertex attributes must be uploaded considering default locations points and available vertex data
1087
1091
 
1088
1092
  // Enable vertex attributes: position (shader-location = 0)
1089
1093
  void *vertices = mesh->animVertices != NULL ? mesh->animVertices : mesh->vertices;
@@ -1096,6 +1100,9 @@ void UploadMesh(Mesh *mesh, bool dynamic)
1096
1100
  rlSetVertexAttribute(1, 2, RL_FLOAT, 0, 0, 0);
1097
1101
  rlEnableVertexAttribute(1);
1098
1102
 
1103
+ // WARNING: When setting default vertex attribute values, the values for each generic vertex attribute
1104
+ // is part of current state and it is maintained even if a different program object is used
1105
+
1099
1106
  if (mesh->normals != NULL)
1100
1107
  {
1101
1108
  // Enable vertex attributes: normals (shader-location = 2)
@@ -1106,7 +1113,8 @@ void UploadMesh(Mesh *mesh, bool dynamic)
1106
1113
  }
1107
1114
  else
1108
1115
  {
1109
- // Default color vertex attribute set to WHITE
1116
+ // Default vertex attribute: normal
1117
+ // WARNING: Default value provided to shader if location available
1110
1118
  float value[3] = { 1.0f, 1.0f, 1.0f };
1111
1119
  rlSetVertexAttributeDefault(2, value, SHADER_ATTRIB_VEC3, 3);
1112
1120
  rlDisableVertexAttribute(2);
@@ -1121,8 +1129,9 @@ void UploadMesh(Mesh *mesh, bool dynamic)
1121
1129
  }
1122
1130
  else
1123
1131
  {
1124
- // Default color vertex attribute set to WHITE
1125
- float value[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
1132
+ // Default vertex attribute: color
1133
+ // WARNING: Default value provided to shader if location available
1134
+ float value[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; // WHITE
1126
1135
  rlSetVertexAttributeDefault(3, value, SHADER_ATTRIB_VEC4, 4);
1127
1136
  rlDisableVertexAttribute(3);
1128
1137
  }
@@ -1136,7 +1145,8 @@ void UploadMesh(Mesh *mesh, bool dynamic)
1136
1145
  }
1137
1146
  else
1138
1147
  {
1139
- // Default tangents vertex attribute
1148
+ // Default vertex attribute: tangent
1149
+ // WARNING: Default value provided to shader if location available
1140
1150
  float value[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
1141
1151
  rlSetVertexAttributeDefault(4, value, SHADER_ATTRIB_VEC4, 4);
1142
1152
  rlDisableVertexAttribute(4);
@@ -1151,7 +1161,8 @@ void UploadMesh(Mesh *mesh, bool dynamic)
1151
1161
  }
1152
1162
  else
1153
1163
  {
1154
- // Default texcoord2 vertex attribute
1164
+ // Default vertex attribute: texcoord2
1165
+ // WARNING: Default value provided to shader if location available
1155
1166
  float value[2] = { 0.0f, 0.0f };
1156
1167
  rlSetVertexAttributeDefault(5, value, SHADER_ATTRIB_VEC2, 2);
1157
1168
  rlDisableVertexAttribute(5);
@@ -1170,7 +1181,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
1170
1181
  }
1171
1182
 
1172
1183
  // Update mesh vertex data in GPU for a specific buffer index
1173
- void UpdateMeshBuffer(Mesh mesh, int index, void *data, int dataSize, int offset)
1184
+ void UpdateMeshBuffer(Mesh mesh, int index, const void *data, int dataSize, int offset)
1174
1185
  {
1175
1186
  rlUpdateVertexBuffer(mesh.vboId[index], data, dataSize, offset);
1176
1187
  }
@@ -1289,8 +1300,10 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
1289
1300
  }
1290
1301
  }
1291
1302
 
1292
- // Try binding vertex array objects (VAO)
1293
- // or use VBOs if not possible
1303
+ // Try binding vertex array objects (VAO) or use VBOs if not possible
1304
+ // WARNING: UploadMesh() enables all vertex attributes available in mesh and sets default attribute values
1305
+ // for shader expected vertex attributes that are not provided by the mesh (i.e. colors)
1306
+ // This could be a dangerous approach because different meshes with different shaders can enable/disable some attributes
1294
1307
  if (!rlEnableVertexArray(mesh.vaoId))
1295
1308
  {
1296
1309
  // Bind mesh VBO data: vertex position (shader-location = 0)
@@ -1322,10 +1335,10 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
1322
1335
  }
1323
1336
  else
1324
1337
  {
1325
- // Set default value for unused attribute
1326
- // NOTE: Required when using default shader and no VAO support
1338
+ // Set default value for defined vertex attribute in shader but not provided by mesh
1339
+ // WARNING: It could result in GPU undefined behaviour
1327
1340
  float value[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
1328
- rlSetVertexAttributeDefault(material.shader.locs[SHADER_LOC_VERTEX_COLOR], value, SHADER_ATTRIB_VEC2, 4);
1341
+ rlSetVertexAttributeDefault(material.shader.locs[SHADER_LOC_VERTEX_COLOR], value, SHADER_ATTRIB_VEC4, 4);
1329
1342
  rlDisableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_COLOR]);
1330
1343
  }
1331
1344
  }
@@ -1349,6 +1362,9 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
1349
1362
  if (mesh.indices != NULL) rlEnableVertexBufferElement(mesh.vboId[6]);
1350
1363
  }
1351
1364
 
1365
+ // WARNING: Disable vertex attribute color input if mesh can not provide that data (despite location being enabled in shader)
1366
+ if (mesh.vboId[3] == 0) rlDisableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_COLOR]);
1367
+
1352
1368
  int eyeCount = 1;
1353
1369
  if (rlIsStereoRenderEnabled()) eyeCount = 2;
1354
1370
 
@@ -1375,14 +1391,17 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
1375
1391
  // Unbind all binded texture maps
1376
1392
  for (int i = 0; i < MAX_MATERIAL_MAPS; i++)
1377
1393
  {
1378
- // Select current shader texture slot
1379
- rlActiveTextureSlot(i);
1380
-
1381
- // Disable texture for active slot
1382
- if ((i == MATERIAL_MAP_IRRADIANCE) ||
1383
- (i == MATERIAL_MAP_PREFILTER) ||
1384
- (i == MATERIAL_MAP_CUBEMAP)) rlDisableTextureCubemap();
1385
- else rlDisableTexture();
1394
+ if (material.maps[i].texture.id > 0)
1395
+ {
1396
+ // Select current shader texture slot
1397
+ rlActiveTextureSlot(i);
1398
+
1399
+ // Disable texture for active slot
1400
+ if ((i == MATERIAL_MAP_IRRADIANCE) ||
1401
+ (i == MATERIAL_MAP_PREFILTER) ||
1402
+ (i == MATERIAL_MAP_CUBEMAP)) rlDisableTextureCubemap();
1403
+ else rlDisableTexture();
1404
+ }
1386
1405
  }
1387
1406
 
1388
1407
  // Disable all possible vertex array objects (or VBOs)
@@ -1400,7 +1419,7 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
1400
1419
  }
1401
1420
 
1402
1421
  // Draw multiple mesh instances with material and different transforms
1403
- void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int instances)
1422
+ void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, int instances)
1404
1423
  {
1405
1424
  #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
1406
1425
  // Instancing required variables
@@ -1540,7 +1559,7 @@ void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int ins
1540
1559
  // Set default value for unused attribute
1541
1560
  // NOTE: Required when using default shader and no VAO support
1542
1561
  float value[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
1543
- rlSetVertexAttributeDefault(material.shader.locs[SHADER_LOC_VERTEX_COLOR], value, SHADER_ATTRIB_VEC2, 4);
1562
+ rlSetVertexAttributeDefault(material.shader.locs[SHADER_LOC_VERTEX_COLOR], value, SHADER_ATTRIB_VEC4, 4);
1544
1563
  rlDisableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_COLOR]);
1545
1564
  }
1546
1565
  }
@@ -1564,6 +1583,9 @@ void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int ins
1564
1583
  if (mesh.indices != NULL) rlEnableVertexBufferElement(mesh.vboId[6]);
1565
1584
  }
1566
1585
 
1586
+ // WARNING: Disable vertex attribute color input if mesh can not provide that data (despite location being enabled in shader)
1587
+ if (mesh.vboId[3] == 0) rlDisableVertexAttribute(material.shader.locs[SHADER_LOC_VERTEX_COLOR]);
1588
+
1567
1589
  int eyeCount = 1;
1568
1590
  if (rlIsStereoRenderEnabled()) eyeCount = 2;
1569
1591
 
@@ -1590,14 +1612,17 @@ void DrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int ins
1590
1612
  // Unbind all binded texture maps
1591
1613
  for (int i = 0; i < MAX_MATERIAL_MAPS; i++)
1592
1614
  {
1593
- // Select current shader texture slot
1594
- rlActiveTextureSlot(i);
1595
-
1596
- // Disable texture for active slot
1597
- if ((i == MATERIAL_MAP_IRRADIANCE) ||
1598
- (i == MATERIAL_MAP_PREFILTER) ||
1599
- (i == MATERIAL_MAP_CUBEMAP)) rlDisableTextureCubemap();
1600
- else rlDisableTexture();
1615
+ if (material.maps[i].texture.id > 0)
1616
+ {
1617
+ // Select current shader texture slot
1618
+ rlActiveTextureSlot(i);
1619
+
1620
+ // Disable texture for active slot
1621
+ if ((i == MATERIAL_MAP_IRRADIANCE) ||
1622
+ (i == MATERIAL_MAP_PREFILTER) ||
1623
+ (i == MATERIAL_MAP_CUBEMAP)) rlDisableTextureCubemap();
1624
+ else rlDisableTexture();
1625
+ }
1601
1626
  }
1602
1627
 
1603
1628
  // Disable all possible vertex array objects (or VBOs)
@@ -1620,7 +1645,7 @@ void UnloadMesh(Mesh mesh)
1620
1645
  // Unload rlgl mesh vboId data
1621
1646
  rlUnloadVertexArray(mesh.vaoId);
1622
1647
 
1623
- for (int i = 0; i < MAX_MESH_VERTEX_BUFFERS; i++) rlUnloadVertexBuffer(mesh.vboId[i]);
1648
+ if (mesh.vboId != NULL) for (int i = 0; i < MAX_MESH_VERTEX_BUFFERS; i++) rlUnloadVertexBuffer(mesh.vboId[i]);
1624
1649
  RL_FREE(mesh.vboId);
1625
1650
 
1626
1651
  RL_FREE(mesh.vertices);
@@ -1645,13 +1670,13 @@ bool ExportMesh(Mesh mesh, const char *fileName)
1645
1670
  if (IsFileExtension(fileName, ".obj"))
1646
1671
  {
1647
1672
  // Estimated data size, it should be enough...
1648
- int dataSize = mesh.vertexCount/3* (int)strlen("v 0000.00f 0000.00f 0000.00f") +
1649
- mesh.vertexCount/2* (int)strlen("vt 0.000f 0.00f") +
1650
- mesh.vertexCount/3* (int)strlen("vn 0.000f 0.00f 0.00f") +
1651
- mesh.triangleCount/3* (int)strlen("f 00000/00000/00000 00000/00000/00000 00000/00000/00000");
1673
+ int dataSize = mesh.vertexCount*(int)strlen("v 0000.00f 0000.00f 0000.00f") +
1674
+ mesh.vertexCount*(int)strlen("vt 0.000f 0.00f") +
1675
+ mesh.vertexCount*(int)strlen("vn 0.000f 0.00f 0.00f") +
1676
+ mesh.triangleCount*(int)strlen("f 00000/00000/00000 00000/00000/00000 00000/00000/00000");
1652
1677
 
1653
1678
  // NOTE: Text data buffer size is estimated considering mesh data size
1654
- char *txtData = (char *)RL_CALLOC(dataSize + 2000, sizeof(char));
1679
+ char *txtData = (char *)RL_CALLOC(dataSize*2 + 2000, sizeof(char));
1655
1680
 
1656
1681
  int byteCount = 0;
1657
1682
  byteCount += sprintf(txtData + byteCount, "# //////////////////////////////////////////////////////////////////////////////////\n");
@@ -1661,7 +1686,7 @@ bool ExportMesh(Mesh mesh, const char *fileName)
1661
1686
  byteCount += sprintf(txtData + byteCount, "# // more info and bugs-report: github.com/raysan5/raylib //\n");
1662
1687
  byteCount += sprintf(txtData + byteCount, "# // feedback and support: ray[at]raylib.com //\n");
1663
1688
  byteCount += sprintf(txtData + byteCount, "# // //\n");
1664
- byteCount += sprintf(txtData + byteCount, "# // Copyright (c) 2018 Ramon Santamaria (@raysan5) //\n");
1689
+ byteCount += sprintf(txtData + byteCount, "# // Copyright (c) 2018-2022 Ramon Santamaria (@raysan5) //\n");
1665
1690
  byteCount += sprintf(txtData + byteCount, "# // //\n");
1666
1691
  byteCount += sprintf(txtData + byteCount, "# //////////////////////////////////////////////////////////////////////////////////\n\n");
1667
1692
  byteCount += sprintf(txtData + byteCount, "# Vertex Count: %i\n", mesh.vertexCount);
@@ -1684,9 +1709,22 @@ bool ExportMesh(Mesh mesh, const char *fileName)
1684
1709
  byteCount += sprintf(txtData + byteCount, "vn %.3f %.3f %.3f\n", mesh.normals[v], mesh.normals[v + 1], mesh.normals[v + 2]);
1685
1710
  }
1686
1711
 
1687
- for (int i = 0; i < mesh.triangleCount; i += 3)
1712
+ if (mesh.indices != NULL)
1688
1713
  {
1689
- byteCount += sprintf(txtData + byteCount, "f %i/%i/%i %i/%i/%i %i/%i/%i\n", i, i, i, i + 1, i + 1, i + 1, i + 2, i + 2, i + 2);
1714
+ for (int i = 0, v = 0; i < mesh.triangleCount; i++, v += 3)
1715
+ {
1716
+ byteCount += sprintf(txtData + byteCount, "f %i/%i/%i %i/%i/%i %i/%i/%i\n",
1717
+ mesh.indices[v] + 1, mesh.indices[v] + 1, mesh.indices[v] + 1,
1718
+ mesh.indices[v + 1] + 1, mesh.indices[v + 1] + 1, mesh.indices[v + 1] + 1,
1719
+ mesh.indices[v + 2] + 1, mesh.indices[v + 2] + 1, mesh.indices[v + 2] + 1);
1720
+ }
1721
+ }
1722
+ else
1723
+ {
1724
+ for (int i = 0, v = 1; i < mesh.triangleCount; i++, v += 3)
1725
+ {
1726
+ byteCount += sprintf(txtData + byteCount, "f %i/%i/%i %i/%i/%i %i/%i/%i\n", v, v, v, v + 1, v + 1, v + 1, v + 2, v + 2, v + 2);
1727
+ }
1690
1728
  }
1691
1729
 
1692
1730
  byteCount += sprintf(txtData + byteCount, "\n");
@@ -1704,7 +1742,6 @@ bool ExportMesh(Mesh mesh, const char *fileName)
1704
1742
  return success;
1705
1743
  }
1706
1744
 
1707
-
1708
1745
  // Load materials from model file
1709
1746
  Material *LoadMaterials(const char *fileName, int *materialCount)
1710
1747
  {
@@ -1771,9 +1808,12 @@ void UnloadMaterial(Material material)
1771
1808
  if (material.shader.id != rlGetShaderIdDefault()) UnloadShader(material.shader);
1772
1809
 
1773
1810
  // Unload loaded texture maps (avoid unloading default texture, managed by raylib)
1774
- for (int i = 0; i < MAX_MATERIAL_MAPS; i++)
1811
+ if (material.maps != NULL)
1775
1812
  {
1776
- if (material.maps[i].texture.id != rlGetTextureIdDefault()) rlUnloadTexture(material.maps[i].texture.id);
1813
+ for (int i = 0; i < MAX_MATERIAL_MAPS; i++)
1814
+ {
1815
+ if (material.maps[i].texture.id != rlGetTextureIdDefault()) rlUnloadTexture(material.maps[i].texture.id);
1816
+ }
1777
1817
  }
1778
1818
 
1779
1819
  RL_FREE(material.maps);
@@ -1911,7 +1951,7 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
1911
1951
  }
1912
1952
 
1913
1953
  // Unload animation array data
1914
- void UnloadModelAnimations(ModelAnimation* animations, unsigned int count)
1954
+ void UnloadModelAnimations(ModelAnimation *animations, unsigned int count)
1915
1955
  {
1916
1956
  for (unsigned int i = 0; i < count; i++) UnloadModelAnimation(animations[i]);
1917
1957
  RL_FREE(animations);
@@ -2249,14 +2289,14 @@ Mesh GenMeshCube(float width, float height, float length)
2249
2289
  int k = 0;
2250
2290
 
2251
2291
  // Indices can be initialized right now
2252
- for (int i = 0; i < 36; i+=6)
2292
+ for (int i = 0; i < 36; i += 6)
2253
2293
  {
2254
2294
  mesh.indices[i] = 4*k;
2255
- mesh.indices[i+1] = 4*k+1;
2256
- mesh.indices[i+2] = 4*k+2;
2257
- mesh.indices[i+3] = 4*k;
2258
- mesh.indices[i+4] = 4*k+2;
2259
- mesh.indices[i+5] = 4*k+3;
2295
+ mesh.indices[i + 1] = 4*k + 1;
2296
+ mesh.indices[i + 2] = 4*k + 2;
2297
+ mesh.indices[i + 3] = 4*k;
2298
+ mesh.indices[i + 4] = 4*k + 2;
2299
+ mesh.indices[i + 5] = 4*k + 3;
2260
2300
 
2261
2301
  k++;
2262
2302
  }
@@ -2412,13 +2452,13 @@ Mesh GenMeshCylinder(float radius, float height, int slices)
2412
2452
  par_shapes_mesh *cylinder = par_shapes_create_cylinder(slices, 8);
2413
2453
  par_shapes_scale(cylinder, radius, radius, height);
2414
2454
  par_shapes_rotate(cylinder, -PI/2.0f, (float[]){ 1, 0, 0 });
2415
- par_shapes_rotate(cylinder, PI/2.0f, (float[]){ 0, 1, 0 });
2416
2455
 
2417
2456
  // Generate an orientable disk shape (top cap)
2418
2457
  par_shapes_mesh *capTop = par_shapes_create_disk(radius, slices, (float[]){ 0, 0, 0 }, (float[]){ 0, 0, 1 });
2419
2458
  capTop->tcoords = PAR_MALLOC(float, 2*capTop->npoints);
2420
2459
  for (int i = 0; i < 2*capTop->npoints; i++) capTop->tcoords[i] = 0.0f;
2421
2460
  par_shapes_rotate(capTop, -PI/2.0f, (float[]){ 1, 0, 0 });
2461
+ par_shapes_rotate(capTop, 90*DEG2RAD, (float[]){ 0, 1, 0 });
2422
2462
  par_shapes_translate(capTop, 0, height, 0);
2423
2463
 
2424
2464
  // Generate an orientable disk shape (bottom cap)
@@ -2426,6 +2466,7 @@ Mesh GenMeshCylinder(float radius, float height, int slices)
2426
2466
  capBottom->tcoords = PAR_MALLOC(float, 2*capBottom->npoints);
2427
2467
  for (int i = 0; i < 2*capBottom->npoints; i++) capBottom->tcoords[i] = 0.95f;
2428
2468
  par_shapes_rotate(capBottom, PI/2.0f, (float[]){ 1, 0, 0 });
2469
+ par_shapes_rotate(capBottom, -90*DEG2RAD, (float[]){ 0, 1, 0 });
2429
2470
 
2430
2471
  par_shapes_merge_and_free(cylinder, capTop);
2431
2472
  par_shapes_merge_and_free(cylinder, capBottom);
@@ -2610,7 +2651,7 @@ Mesh GenMeshKnot(float radius, float size, int radSeg, int sides)
2610
2651
  // NOTE: Vertex data is uploaded to GPU
2611
2652
  Mesh GenMeshHeightmap(Image heightmap, Vector3 size)
2612
2653
  {
2613
- #define GRAY_VALUE(c) ((c.r+c.g+c.b)/3)
2654
+ #define GRAY_VALUE(c) ((c.r+c.g+c.b)/3.0f)
2614
2655
 
2615
2656
  Mesh mesh = { 0 };
2616
2657
 
@@ -2633,8 +2674,6 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size)
2633
2674
  int tcCounter = 0; // Used to count texcoords float by float
2634
2675
  int nCounter = 0; // Used to count normals float by float
2635
2676
 
2636
- int trisCounter = 0;
2637
-
2638
2677
  Vector3 scaleFactor = { size.x/mapX, size.y/255.0f, size.z/mapZ };
2639
2678
 
2640
2679
  Vector3 vA = { 0 };
@@ -2651,15 +2690,15 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size)
2651
2690
 
2652
2691
  // one triangle - 3 vertex
2653
2692
  mesh.vertices[vCounter] = (float)x*scaleFactor.x;
2654
- mesh.vertices[vCounter + 1] = (float)GRAY_VALUE(pixels[x + z*mapX])*scaleFactor.y;
2693
+ mesh.vertices[vCounter + 1] = GRAY_VALUE(pixels[x + z*mapX])*scaleFactor.y;
2655
2694
  mesh.vertices[vCounter + 2] = (float)z*scaleFactor.z;
2656
2695
 
2657
2696
  mesh.vertices[vCounter + 3] = (float)x*scaleFactor.x;
2658
- mesh.vertices[vCounter + 4] = (float)GRAY_VALUE(pixels[x + (z + 1)*mapX])*scaleFactor.y;
2697
+ mesh.vertices[vCounter + 4] = GRAY_VALUE(pixels[x + (z + 1)*mapX])*scaleFactor.y;
2659
2698
  mesh.vertices[vCounter + 5] = (float)(z + 1)*scaleFactor.z;
2660
2699
 
2661
2700
  mesh.vertices[vCounter + 6] = (float)(x + 1)*scaleFactor.x;
2662
- mesh.vertices[vCounter + 7] = (float)GRAY_VALUE(pixels[(x + 1) + z*mapX])*scaleFactor.y;
2701
+ mesh.vertices[vCounter + 7] = GRAY_VALUE(pixels[(x + 1) + z*mapX])*scaleFactor.y;
2663
2702
  mesh.vertices[vCounter + 8] = (float)z*scaleFactor.z;
2664
2703
 
2665
2704
  // another triangle - 3 vertex
@@ -2672,7 +2711,7 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size)
2672
2711
  mesh.vertices[vCounter + 14] = mesh.vertices[vCounter + 5];
2673
2712
 
2674
2713
  mesh.vertices[vCounter + 15] = (float)(x + 1)*scaleFactor.x;
2675
- mesh.vertices[vCounter + 16] = (float)GRAY_VALUE(pixels[(x + 1) + (z + 1)*mapX])*scaleFactor.y;
2714
+ mesh.vertices[vCounter + 16] = GRAY_VALUE(pixels[(x + 1) + (z + 1)*mapX])*scaleFactor.y;
2676
2715
  mesh.vertices[vCounter + 17] = (float)(z + 1)*scaleFactor.z;
2677
2716
  vCounter += 18; // 6 vertex, 18 floats
2678
2717
 
@@ -2729,7 +2768,6 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size)
2729
2768
  }
2730
2769
 
2731
2770
  nCounter += 18; // 6 vertex, 18 floats
2732
- trisCounter += 2;
2733
2771
  }
2734
2772
  }
2735
2773
 
@@ -3223,19 +3261,6 @@ void GenMeshTangents(Mesh *mesh)
3223
3261
  TRACELOG(LOG_INFO, "MESH: Tangents data computed and uploaded for provided mesh");
3224
3262
  }
3225
3263
 
3226
- // Compute mesh binormals (aka bitangent)
3227
- void GenMeshBinormals(Mesh *mesh)
3228
- {
3229
- for (int i = 0; i < mesh->vertexCount; i++)
3230
- {
3231
- //Vector3 normal = { mesh->normals[i*3 + 0], mesh->normals[i*3 + 1], mesh->normals[i*3 + 2] };
3232
- //Vector3 tangent = { mesh->tangents[i*4 + 0], mesh->tangents[i*4 + 1], mesh->tangents[i*4 + 2] };
3233
- //Vector3 binormal = Vector3Scale(Vector3CrossProduct(normal, tangent), mesh->tangents[i*4 + 3]);
3234
-
3235
- // TODO: Register computed binormal in mesh->binormal?
3236
- }
3237
- }
3238
-
3239
3264
  // Draw a model (with texture if set)
3240
3265
  void DrawModel(Model model, Vector3 position, float scale, Color tint)
3241
3266
  {
@@ -3264,10 +3289,10 @@ void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rota
3264
3289
  Color color = model.materials[model.meshMaterial[i]].maps[MATERIAL_MAP_DIFFUSE].color;
3265
3290
 
3266
3291
  Color colorTint = WHITE;
3267
- colorTint.r = (unsigned char)((((float)color.r/255.0)*((float)tint.r/255.0))*255.0f);
3268
- colorTint.g = (unsigned char)((((float)color.g/255.0)*((float)tint.g/255.0))*255.0f);
3269
- colorTint.b = (unsigned char)((((float)color.b/255.0)*((float)tint.b/255.0))*255.0f);
3270
- colorTint.a = (unsigned char)((((float)color.a/255.0)*((float)tint.a/255.0))*255.0f);
3292
+ colorTint.r = (unsigned char)((((float)color.r/255.0f)*((float)tint.r/255.0f))*255.0f);
3293
+ colorTint.g = (unsigned char)((((float)color.g/255.0f)*((float)tint.g/255.0f))*255.0f);
3294
+ colorTint.b = (unsigned char)((((float)color.b/255.0f)*((float)tint.b/255.0f))*255.0f);
3295
+ colorTint.a = (unsigned char)((((float)color.a/255.0f)*((float)tint.a/255.0f))*255.0f);
3271
3296
 
3272
3297
  model.materials[model.meshMaterial[i]].maps[MATERIAL_MAP_DIFFUSE].color = colorTint;
3273
3298
  DrawMesh(model.meshes[i], model.materials[model.meshMaterial[i]], model.transform);
@@ -3315,7 +3340,7 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector
3315
3340
  void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint)
3316
3341
  {
3317
3342
  // NOTE: Billboard size will maintain source rectangle aspect ratio, size will represent billboard width
3318
- Vector2 sizeRatio = { size.y, size.x*(float)source.height/source.width };
3343
+ Vector2 sizeRatio = { size.x*(float)source.width/source.height, size.y };
3319
3344
 
3320
3345
  Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
3321
3346
 
@@ -3376,7 +3401,7 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
3376
3401
  bottomRight = Vector3Add(bottomRight, position);
3377
3402
  bottomLeft = Vector3Add(bottomLeft, position);
3378
3403
 
3379
- rlCheckRenderBatchLimit(4);
3404
+ rlCheckRenderBatchLimit(8);
3380
3405
 
3381
3406
  rlSetTexture(texture.id);
3382
3407
 
@@ -3620,31 +3645,12 @@ RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform)
3620
3645
  return collision;
3621
3646
  }
3622
3647
 
3623
- // Get collision info between ray and model
3624
- RayCollision GetRayCollisionModel(Ray ray, Model model)
3625
- {
3626
- RayCollision collision = { 0 };
3627
-
3628
- for (int m = 0; m < model.meshCount; m++)
3629
- {
3630
- RayCollision meshHitInfo = GetRayCollisionMesh(ray, model.meshes[m], model.transform);
3631
-
3632
- if (meshHitInfo.hit)
3633
- {
3634
- // Save the closest hit mesh
3635
- if ((!collision.hit) || (collision.distance > meshHitInfo.distance)) collision = meshHitInfo;
3636
- }
3637
- }
3638
-
3639
- return collision;
3640
- }
3641
-
3642
3648
  // Get collision info between ray and triangle
3643
3649
  // NOTE: The points are expected to be in counter-clockwise winding
3644
3650
  // NOTE: Based on https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
3645
3651
  RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3)
3646
3652
  {
3647
- #define EPSILON 0.000001 // A small number
3653
+ #define EPSILON 0.000001f // A small number
3648
3654
 
3649
3655
  RayCollision collision = { 0 };
3650
3656
  Vector3 edge1 = { 0 };
@@ -4281,7 +4287,7 @@ static Model LoadIQM(const char *fileName)
4281
4287
  }
4282
4288
 
4283
4289
  // Load IQM animation data
4284
- static ModelAnimation* LoadModelAnimationsIQM(const char *fileName, unsigned int *animCount)
4290
+ static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, unsigned int *animCount)
4285
4291
  {
4286
4292
  #define IQM_MAGIC "INTERQUAKEMODEL" // IQM file magic number
4287
4293
  #define IQM_VERSION 2 // only IQM version 2 supported
@@ -4523,7 +4529,7 @@ static Image LoadImageFromCgltfImage(cgltf_image *cgltfImage, const char *texPat
4523
4529
 
4524
4530
  cgltf_options options = { 0 };
4525
4531
  cgltf_result result = cgltf_load_buffer_base64(&options, outSize, cgltfImage->uri + i + 1, &data);
4526
-
4532
+
4527
4533
  if (result == cgltf_result_success)
4528
4534
  {
4529
4535
  image = LoadImageFromMemory(".png", (unsigned char *)data, outSize);
@@ -4551,12 +4557,12 @@ static Image LoadImageFromCgltfImage(cgltf_image *cgltfImage, const char *texPat
4551
4557
 
4552
4558
  // Check mime_type for image: (cgltfImage->mime_type == "image/png")
4553
4559
  // NOTE: Detected that some models define mime_type as "image\\/png"
4554
- if ((strcmp(cgltfImage->mime_type, "image\\/png") == 0) ||
4560
+ if ((strcmp(cgltfImage->mime_type, "image\\/png") == 0) ||
4555
4561
  (strcmp(cgltfImage->mime_type, "image/png") == 0)) image = LoadImageFromMemory(".png", data, (int)cgltfImage->buffer_view->size);
4556
4562
  else if ((strcmp(cgltfImage->mime_type, "image\\/jpeg") == 0) ||
4557
4563
  (strcmp(cgltfImage->mime_type, "image/jpeg") == 0)) image = LoadImageFromMemory(".jpg", data, (int)cgltfImage->buffer_view->size);
4558
4564
  else TRACELOG(LOG_WARNING, "MODEL: glTF image data MIME type not recognized", TextFormat("%s/%s", texPath, cgltfImage->uri));
4559
-
4565
+
4560
4566
  RL_FREE(data);
4561
4567
  }
4562
4568
 
@@ -4617,7 +4623,7 @@ static Model LoadGLTF(const char *fileName)
4617
4623
  cgltf_options options = { 0 };
4618
4624
  cgltf_data *data = NULL;
4619
4625
  cgltf_result result = cgltf_parse(&options, fileData, dataSize, &data);
4620
-
4626
+
4621
4627
  if (result == cgltf_result_success)
4622
4628
  {
4623
4629
  if (data->file_type == cgltf_file_type_glb) TRACELOG(LOG_INFO, "MODEL: [%s] Model basic data (glb) loaded successfully", fileName);
@@ -4642,10 +4648,9 @@ static Model LoadGLTF(const char *fileName)
4642
4648
  // Load our model data: meshes and materials
4643
4649
  model.meshCount = primitivesCount;
4644
4650
  model.meshes = RL_CALLOC(model.meshCount, sizeof(Mesh));
4645
- for (int i = 0; i < model.meshCount; i++) model.meshes[i].vboId = (unsigned int*)RL_CALLOC(MAX_MESH_VERTEX_BUFFERS, sizeof(unsigned int));
4646
4651
 
4647
4652
  // NOTE: We keep an extra slot for default material, in case some mesh requires it
4648
- model.materialCount = (int)data->materials_count + 1;
4653
+ model.materialCount = (int)data->materials_count + 1;
4649
4654
  model.materials = RL_CALLOC(model.materialCount, sizeof(Material));
4650
4655
  model.materials[0] = LoadMaterialDefault(); // Load default material (index: 0)
4651
4656
 
@@ -4672,13 +4677,12 @@ static Model LoadGLTF(const char *fileName)
4672
4677
  model.materials[j].maps[MATERIAL_MAP_ALBEDO].texture = LoadTextureFromImage(imAlbedo);
4673
4678
  UnloadImage(imAlbedo);
4674
4679
  }
4675
-
4676
- // Load base color factor (tint)
4677
- model.materials[j].maps[MATERIAL_MAP_ALBEDO].color.r = (unsigned char)(data->materials[i].pbr_metallic_roughness.base_color_factor[0]*255);
4678
- model.materials[j].maps[MATERIAL_MAP_ALBEDO].color.g = (unsigned char)(data->materials[i].pbr_metallic_roughness.base_color_factor[1]*255);
4679
- model.materials[j].maps[MATERIAL_MAP_ALBEDO].color.b = (unsigned char)(data->materials[i].pbr_metallic_roughness.base_color_factor[2]*255);
4680
- model.materials[j].maps[MATERIAL_MAP_ALBEDO].color.a = (unsigned char)(data->materials[i].pbr_metallic_roughness.base_color_factor[3]*255);
4681
4680
  }
4681
+ // Load base color factor (tint)
4682
+ model.materials[j].maps[MATERIAL_MAP_ALBEDO].color.r = (unsigned char)(data->materials[i].pbr_metallic_roughness.base_color_factor[0]*255);
4683
+ model.materials[j].maps[MATERIAL_MAP_ALBEDO].color.g = (unsigned char)(data->materials[i].pbr_metallic_roughness.base_color_factor[1]*255);
4684
+ model.materials[j].maps[MATERIAL_MAP_ALBEDO].color.b = (unsigned char)(data->materials[i].pbr_metallic_roughness.base_color_factor[2]*255);
4685
+ model.materials[j].maps[MATERIAL_MAP_ALBEDO].color.a = (unsigned char)(data->materials[i].pbr_metallic_roughness.base_color_factor[3]*255);
4682
4686
 
4683
4687
  // Load metallic/roughness texture
4684
4688
  if (data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture)
@@ -4689,8 +4693,8 @@ static Model LoadGLTF(const char *fileName)
4689
4693
  model.materials[j].maps[MATERIAL_MAP_ROUGHNESS].texture = LoadTextureFromImage(imMetallicRoughness);
4690
4694
  UnloadImage(imMetallicRoughness);
4691
4695
  }
4692
-
4693
- // Load metallic/roughness material properties
4696
+
4697
+ // Load metallic/roughness material properties
4694
4698
  float roughness = data->materials[i].pbr_metallic_roughness.roughness_factor;
4695
4699
  model.materials[j].maps[MATERIAL_MAP_ROUGHNESS].value = roughness;
4696
4700
 
@@ -4738,7 +4742,7 @@ static Model LoadGLTF(const char *fileName)
4738
4742
  }
4739
4743
  }
4740
4744
 
4741
- // Other possible materials not supported by raylib pipeline:
4745
+ // Other possible materials not supported by raylib pipeline:
4742
4746
  // has_clearcoat, has_transmission, has_volume, has_ior, has specular, has_sheen
4743
4747
  }
4744
4748
 
@@ -4768,7 +4772,7 @@ static Model LoadGLTF(const char *fileName)
4768
4772
 
4769
4773
  if ((attribute->component_type == cgltf_component_type_r_32f) && (attribute->type == cgltf_type_vec3))
4770
4774
  {
4771
- // Init raylib mesh vertices to copy glTF attribute data
4775
+ // Init raylib mesh vertices to copy glTF attribute data
4772
4776
  model.meshes[meshIndex].vertexCount = (int)attribute->count;
4773
4777
  model.meshes[meshIndex].vertices = RL_MALLOC(attribute->count*3*sizeof(float));
4774
4778
 
@@ -4845,7 +4849,7 @@ static Model LoadGLTF(const char *fileName)
4845
4849
  LOAD_ATTRIBUTE(attribute, 4, unsigned short, temp);
4846
4850
 
4847
4851
  // Convert data to raylib color data type (4 bytes)
4848
- for (int c = 0; c < attribute->count*4; c++) model.meshes[meshIndex].colors[c] = (unsigned char)(((float)temp[c]/65535.0f)*255.0f);
4852
+ for (unsigned int c = 0; c < attribute->count*4; c++) model.meshes[meshIndex].colors[c] = (unsigned char)(((float)temp[c]/65535.0f)*255.0f);
4849
4853
 
4850
4854
  RL_FREE(temp);
4851
4855
  }
@@ -4859,7 +4863,7 @@ static Model LoadGLTF(const char *fileName)
4859
4863
  LOAD_ATTRIBUTE(attribute, 4, float, temp);
4860
4864
 
4861
4865
  // Convert data to raylib color data type (4 bytes), we expect the color data normalized
4862
- for (int c = 0; c < attribute->count*4; c++) model.meshes[meshIndex].colors[c] = (unsigned char)(temp[c]*255.0f);
4866
+ for (unsigned int c = 0; c < attribute->count*4; c++) model.meshes[meshIndex].colors[c] = (unsigned char)(temp[c]*255.0f);
4863
4867
 
4864
4868
  RL_FREE(temp);
4865
4869
  }
@@ -4894,7 +4898,7 @@ static Model LoadGLTF(const char *fileName)
4894
4898
  LOAD_ATTRIBUTE(attribute, 1, unsigned int, temp);
4895
4899
 
4896
4900
  // Convert data to raylib indices data type (unsigned short)
4897
- for (int d = 0; d < attribute->count; d++) model.meshes[meshIndex].indices[d] = (unsigned short)temp[d];
4901
+ for (unsigned int d = 0; d < attribute->count; d++) model.meshes[meshIndex].indices[d] = (unsigned short)temp[d];
4898
4902
 
4899
4903
  TRACELOG(LOG_WARNING, "MODEL: [%s] Indices data converted from u32 to u16, possible loss of data", fileName);
4900
4904
 
@@ -4906,7 +4910,7 @@ static Model LoadGLTF(const char *fileName)
4906
4910
 
4907
4911
  // Assign to the primitive mesh the corresponding material index
4908
4912
  // NOTE: If no material defined, mesh uses the already assigned default material (index: 0)
4909
- for (int m = 0; m < data->materials_count; m++)
4913
+ for (unsigned int m = 0; m < data->materials_count; m++)
4910
4914
  {
4911
4915
  // The primitive actually keeps the pointer to the corresponding material,
4912
4916
  // raylib instead assigns to the mesh the by its index, as loaded in model.materials array
@@ -4923,6 +4927,63 @@ static Model LoadGLTF(const char *fileName)
4923
4927
  }
4924
4928
  }
4925
4929
 
4930
+ /*
4931
+ // TODO: Load glTF meshes animation data
4932
+ // REF: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#skins
4933
+ // REF: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#skinned-mesh-attributes
4934
+ //----------------------------------------------------------------------------------------------------
4935
+ for (unsigned int i = 0, meshIndex = 0; i < data->meshes_count; i++)
4936
+ {
4937
+ for (unsigned int p = 0; p < data->meshes[i].primitives_count; p++)
4938
+ {
4939
+ // NOTE: We only support primitives defined by triangles
4940
+ if (data->meshes[i].primitives[p].type != cgltf_primitive_type_triangles) continue;
4941
+
4942
+ for (unsigned int j = 0; j < data->meshes[i].primitives[p].attributes_count; j++)
4943
+ {
4944
+ // NOTE: JOINTS_1 + WEIGHT_1 will be used for +4 joints influencing a vertex -> Not supported by raylib
4945
+
4946
+ if (data->meshes[i].primitives[p].attributes[j].type == cgltf_attribute_type_joints) // JOINTS_n (vec4: 4 bones max per vertex / u8, u16)
4947
+ {
4948
+ cgltf_accessor *attribute = data->meshes[i].primitives[p].attributes[j].data;
4949
+
4950
+ if ((attribute->component_type == cgltf_component_type_r_8u) && (attribute->type == cgltf_type_vec4))
4951
+ {
4952
+ // Init raylib mesh bone ids to copy glTF attribute data
4953
+ model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount*4, sizeof(unsigned char));
4954
+
4955
+ // Load 4 components of unsigned char data type into mesh.boneIds
4956
+ // TODO: It seems LOAD_ATTRIBUTE() macro does not work as expected in some cases,
4957
+ // for cgltf_attribute_type_joints we have:
4958
+ // - data.meshes[0] (256 vertices)
4959
+ // - 256 values, provided as cgltf_type_vec4 of bytes (4 byte per joint, stride 4)
4960
+ LOAD_ATTRIBUTE(attribute, 4, unsigned char, model.meshes[meshIndex].boneIds)
4961
+ }
4962
+ else TRACELOG(LOG_WARNING, "MODEL: [%s] Joint attribute data format not supported, use vec4 u8", fileName);
4963
+ }
4964
+ else if (data->meshes[i].primitives[p].attributes[j].type == cgltf_attribute_type_weights) // WEIGHTS_n (vec4 / u8, u16, f32)
4965
+ {
4966
+ cgltf_accessor *attribute = data->meshes[i].primitives[p].attributes[j].data;
4967
+
4968
+ if ((attribute->component_type == cgltf_component_type_r_32f) && (attribute->type == cgltf_type_vec4))
4969
+ {
4970
+ // Init raylib mesh bone weight to copy glTF attribute data
4971
+ model.meshes[meshIndex].boneWeights = RL_CALLOC(model.meshes[meshIndex].vertexCount*4, sizeof(float));
4972
+
4973
+ // Load 4 components of float data type into mesh.boneWeights
4974
+ // for cgltf_attribute_type_weights we have:
4975
+ // - data.meshes[0] (256 vertices)
4976
+ // - 256 values, provided as cgltf_type_vec4 of float (4 byte per joint, stride 16)
4977
+ LOAD_ATTRIBUTE(attribute, 4, float, model.meshes[meshIndex].boneWeights)
4978
+ }
4979
+ else TRACELOG(LOG_WARNING, "MODEL: [%s] Joint weight attribute data format not supported, use vec4 float", fileName);
4980
+ }
4981
+ }
4982
+
4983
+ meshIndex++; // Move to next mesh
4984
+ }
4985
+ }
4986
+ */
4926
4987
  // Free all cgltf loaded data
4927
4988
  cgltf_free(data);
4928
4989
  }
@@ -5039,3 +5100,5 @@ static Model LoadVOX(const char *fileName)
5039
5100
  return model;
5040
5101
  }
5041
5102
  #endif
5103
+
5104
+ #endif // SUPPORT_MODULE_RMODELS