diff --git a/Project.toml b/Project.toml index 4774197..896e467 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Raylib" uuid = "681baf3e-1d1e-48c9-b5e5-b1aea2d6d4d9" authors = ["chengchingwen and contributors"] -version = "0.2.0" +version = "0.3.0" [deps] CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82" @@ -12,7 +12,7 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [compat] CEnum = "0.4" Colors = "0.12" -Raylib_jll = "4.0" +Raylib_jll = "6.0" StaticArrays = "1.2" julia = "1.6" diff --git a/README.md b/README.md index ce8ae24..ebc6fe0 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,4 @@ This project is a wrapping of [Raylib](https://www.raylib.com/), which is a simp ## Raylib architecture -![](https://www.raylib.com/images/raylib_architecture_v4.0.png) +![](https://www.raylib.com/images/raylib_architecture_v6.0.png) diff --git a/api_reference/physac_api.xml b/api_reference/physac_api.xml deleted file mode 100644 index 1de6399..0000000 --- a/api_reference/physac_api.xml +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/api_reference/raylib_api.xml b/api_reference/raylib_api.xml index 87bb4a7..37d8280 100644 --- a/api_reference/raylib_api.xml +++ b/api_reference/raylib_api.xml @@ -1,59 +1,130 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - + + + + + + + + + + + + + + + + + - + - + - + - + - + - + @@ -61,14 +132,14 @@ - + - + @@ -76,493 +147,562 @@ - + - + - - - - - + + + + + - + - + + + + - - - + - + - + - + - + - - + + - + + + + + + - - - + + + - - - - - + + + + + - + - + - + - - + + - + - + - + + - + - + - + - - - + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - + + + + + - - - - - - - + + + + + + - - - - + + + + - - - - - - - + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - + + + + + + - - - + + + - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + - + - + @@ -575,52 +715,71 @@ - + - + - + - + - + + + - + + + + + - + - + + + + + + + + + + + + + + - + - + - + @@ -636,7 +795,7 @@ - + @@ -644,12 +803,11 @@ - + - + - - + @@ -722,6 +880,9 @@ + + + @@ -748,7 +909,7 @@ - + @@ -756,15 +917,15 @@ - - + + - + + - - - + + @@ -784,21 +945,42 @@ + + + + + + - - + + + + + + + + + + + + - - + + + + + + + @@ -806,26 +988,56 @@ + + + + + + - + - - + + - + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -839,27 +1051,29 @@ - + - - - - + - + - - - - + + + - - + + + - + - + + + + + + @@ -867,10 +1081,16 @@ - + + + + + + + @@ -888,57 +1108,110 @@ - - - + - + + - + + + + + + + + + + + + + + + + + + - - + - + + - - + + - - - - + + + + + + + + + - - - - + + + + - + - - + + + + + + - + - + - - - + + + + + + + - - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -948,13 +1221,16 @@ - - - + + + + + + @@ -979,16 +1255,22 @@ - + - + + + + + + + @@ -1021,7 +1303,9 @@ - + + + @@ -1042,11 +1326,11 @@ - + - + @@ -1056,40 +1340,30 @@ - - + + - + - - - - - - - - - - - - - - - - - + + + - + + + + + - + @@ -1100,41 +1374,33 @@ - + - + - - - - + + + - + - - + - - - - - - - - + + @@ -1143,6 +1409,17 @@ + + + + + + + + + + + @@ -1159,27 +1436,26 @@ - + - - + - + - + - + + - - - + + @@ -1191,6 +1467,12 @@ + + + + + + @@ -1236,23 +1518,23 @@ - - + + - - + + - - - - + + + + @@ -1272,7 +1554,13 @@ - + + + + + + + @@ -1292,12 +1580,12 @@ - + - + @@ -1323,6 +1611,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1338,6 +1725,12 @@ + + + + + + @@ -1353,6 +1746,17 @@ + + + + + + + + + + + @@ -1360,12 +1764,6 @@ - - - - - - @@ -1384,6 +1782,12 @@ + + + + + + @@ -1394,12 +1798,20 @@ + + + - + + + + + + @@ -1410,19 +1822,21 @@ - + - - + + + - + - - + + + - + @@ -1442,11 +1856,23 @@ + + + + + + + + + + + + @@ -1454,6 +1880,10 @@ + + + + @@ -1494,6 +1924,15 @@ + + + + + + + + + @@ -1528,6 +1967,10 @@ + + + + @@ -1609,14 +2052,34 @@ - + + + + + + + + + + + + + + + + + + + + + - + @@ -1647,6 +2110,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1685,17 +2183,23 @@ + + + + + + - + - + @@ -1735,22 +2239,6 @@ - - - - - - - - - - - - - - - - @@ -1767,19 +2255,15 @@ - - - - - - - + + + - + @@ -1796,6 +2280,18 @@ + + + + + + + + + + + + @@ -1805,6 +2301,11 @@ + + + + + @@ -1827,11 +2328,11 @@ - + - - + + @@ -1843,31 +2344,39 @@ - - + + + + + - + - - + + + - - + + - + - + + + + + @@ -1905,6 +2414,18 @@ + + + + + + + + + + + + @@ -1915,6 +2436,13 @@ + + + + + + + @@ -1927,6 +2455,13 @@ + + + + + + + @@ -1939,15 +2474,27 @@ - + + + + + + + + + - + - - - + + + + + + + @@ -1962,52 +2509,91 @@ - + - - - - + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + - + + + + + + + + + + + - - + - + - + - + @@ -2033,7 +2619,7 @@ - + @@ -2061,23 +2647,6 @@ - - - - - - - - - - - - - - - - - @@ -2129,6 +2698,22 @@ + + + + + + + + + + + + + + + + @@ -2148,10 +2733,10 @@ - + - + @@ -2193,7 +2778,7 @@ - + @@ -2222,7 +2807,7 @@ - + @@ -2237,21 +2822,22 @@ - + - - - - - - + + + + + + + @@ -2314,6 +2900,9 @@ + + + @@ -2329,19 +2918,24 @@ - + - + - + - - + + + + + + + - - + + @@ -2371,10 +2965,6 @@ - - - - @@ -2402,6 +2992,8 @@ + + @@ -2410,13 +3002,22 @@ + + + - + + + + + + + @@ -2427,6 +3028,9 @@ + + + @@ -2447,13 +3051,6 @@ - - - - - - - @@ -2465,21 +3062,25 @@ - - - - - + + + - + - - + + - + + + + + + + @@ -2490,9 +3091,12 @@ - + + + + @@ -2526,6 +3130,10 @@ + + + + @@ -2537,6 +3145,9 @@ + + + @@ -2571,8 +3182,30 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/api_reference/raymath_api.xml b/api_reference/raymath_api.xml index 4f34291..e9cce18 100644 --- a/api_reference/raymath_api.xml +++ b/api_reference/raymath_api.xml @@ -1,37 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - - - - + + + + + + + + + + + + + + + + + - + - + + + + - + + + @@ -54,6 +94,15 @@ + + + + + + + + + @@ -84,14 +133,26 @@ + + + + + + + + + + + + @@ -110,6 +171,10 @@ + + + + @@ -119,6 +184,14 @@ + + + + + + + + @@ -128,6 +201,28 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -177,7 +272,11 @@ - + + + + + @@ -191,6 +290,14 @@ + + + + + + + + @@ -203,11 +310,28 @@ + + + + + + + + + + + + + + + + + @@ -234,6 +358,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -246,9 +473,6 @@ - - - @@ -263,6 +487,10 @@ + + + + @@ -282,10 +510,10 @@ - + - + @@ -297,22 +525,22 @@ - - + + - + - - + + - - + + @@ -376,6 +604,13 @@ + + + + + + + @@ -407,5 +642,20 @@ + + + + + + + + + + + + + + + diff --git a/api_reference/rlgl_api.xml b/api_reference/rlgl_api.xml new file mode 100644 index 0000000..bffd74b --- /dev/null +++ b/api_reference/rlgl_api.xml @@ -0,0 +1,1031 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/make.jl b/docs/make.jl index 44350a5..6762a46 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -12,6 +12,9 @@ makedocs(; prettyurls=get(ENV, "CI", "false") == "true", canonical="https://chengchingwen.github.io/Raylib.jl", assets=String[], + # raylib 6.0 has ~600 functions (up from ~487 in 4.0), pushing the @autodocs + # page well past Documenter's default 200KiB hard cap. + size_threshold_ignore=["bindings.md"], ), pages=[ "Home" => "index.md", diff --git a/examples/core/3d_camera_first_person.jl b/examples/core/3d_camera_first_person.jl index 5bffdfc..1b74856 100644 --- a/examples/core/3d_camera_first_person.jl +++ b/examples/core/3d_camera_first_person.jl @@ -39,11 +39,10 @@ function main() ) end - Raylib.SetCameraMode(camera, Int(Raylib.CAMERA_FIRST_PERSON)) Raylib.SetTargetFPS(60) while !Raylib.WindowShouldClose() - Raylib.UpdateCamera!(camera) + Raylib.UpdateCamera!(camera, Raylib.CAMERA_FIRST_PERSON) Raylib.BeginDrawing() Raylib.ClearBackground(RAYWHITE) diff --git a/examples/core/ccall/3d_camera_first_person.jl b/examples/core/ccall/3d_camera_first_person.jl index 989364e..746d038 100644 --- a/examples/core/ccall/3d_camera_first_person.jl +++ b/examples/core/ccall/3d_camera_first_person.jl @@ -72,11 +72,10 @@ function main() ) end - @ccall libraylib.SetCameraMode(camera[]::RayCamera3D, 3::Cint)::Cvoid @ccall libraylib.SetTargetFPS(60::Cint)::Cvoid while iszero(@ccall libraylib.WindowShouldClose()::Cint) - @ccall libraylib.UpdateCamera(camera::Ref{RayCamera3D})::Cvoid + @ccall libraylib.UpdateCamera(camera::Ref{RayCamera3D}, 3::Cint)::Cvoid @ccall libraylib.BeginDrawing()::Cvoid @ccall libraylib.ClearBackground(RAYWHITE::RayColor)::Cvoid diff --git a/examples/core/initialize_3d_camera_free.jl b/examples/core/initialize_3d_camera_free.jl index 57602b1..874aa5b 100644 --- a/examples/core/initialize_3d_camera_free.jl +++ b/examples/core/initialize_3d_camera_free.jl @@ -20,12 +20,10 @@ function main() cubePosition = Raylib.rayvector(0, 0, 0) - Raylib.SetCameraMode(camera, Int(Raylib.CAMERA_FREE)) # Set a free camera mode - Raylib.SetTargetFPS(60) while !Raylib.WindowShouldClose() # Detect window close button or ESC key # Update - camera = Raylib.UpdateCamera(camera) # Update camera + camera = Raylib.UpdateCamera(camera, Raylib.CAMERA_FREE) # Update camera Raylib.IsKeyDown(Int('Z')) && (camera = Raylib.RayCamera3D( camera.position, Raylib.rayvector(0, 0, 0), diff --git a/examples/core/windows_drop_files.jl b/examples/core/windows_drop_files.jl index 6228355..96f72c7 100644 --- a/examples/core/windows_drop_files.jl +++ b/examples/core/windows_drop_files.jl @@ -40,6 +40,5 @@ function main() Raylib.EndDrawing() end - Raylib.ClearDroppedFiles() Raylib.CloseWindow() end diff --git a/examples/text/font_sdf.jl b/examples/text/font_sdf.jl index 37d4851..731ad23 100644 --- a/examples/text/font_sdf.jl +++ b/examples/text/font_sdf.jl @@ -4,7 +4,8 @@ const GLSL_VERSION = 330 function build_font(filedata, baseSize, glyphCount, fonttype, padding, packmeth) null = convert(Ptr{Cint}, C_NULL) - glyphs_ptr = Raylib.LoadFontData(pointer(filedata), length(filedata), 16, null, glyphCount, Int(fonttype)) + outGlyphCount = Ref{Cint}(0) # raylib 6.0 added this trailing output param + glyphs_ptr = Raylib.LoadFontData(pointer(filedata), length(filedata), 16, null, glyphCount, Int(fonttype), outGlyphCount) recs = Ref{Ptr{Raylib.RayRectangle}}() atlas = Raylib.GenImageFontAtlas(glyphs_ptr, recs, 95, 16, padding, packmeth) recs_ptr = recs[] diff --git a/examples/textures/draw_textured_polygon.jl b/examples/textures/draw_textured_polygon.jl index 67e3c75..8192cf6 100644 --- a/examples/textures/draw_textured_polygon.jl +++ b/examples/textures/draw_textured_polygon.jl @@ -49,10 +49,13 @@ function main() Raylib.BeginDrawing() Raylib.ClearBackground(Raylib.RAYWHITE) Raylib.DrawText("textured polygon", 20, 20, 20, Raylib.DARKGRAY) - Raylib.DrawTexturePoly( - texture, rayvector(Raylib.GetScreenWidth()/2, Raylib.GetScreenHeight()/2), - pointer(positions), pointer(texcoords), MAX_POINTS, Raylib.WHITE - ) + # DrawTexturePoly was removed in raylib 6.0 with no direct replacement in raylib.h; + # reimplementing this now requires immediate-mode rlgl calls (rlBegin(RL_TRIANGLES)/ + # rlTexCoord2f/rlVertex2f/rlEnd), which this port doesn't wrap yet. + # Raylib.DrawTexturePoly( + # texture, rayvector(Raylib.GetScreenWidth()/2, Raylib.GetScreenHeight()/2), + # pointer(positions), pointer(texcoords), MAX_POINTS, Raylib.WHITE + # ) Raylib.EndDrawing() end diff --git a/src/binding/binding.jl b/src/binding/binding.jl index e86fddf..e2b8741 100644 --- a/src/binding/binding.jl +++ b/src/binding/binding.jl @@ -10,7 +10,7 @@ import ..Raylib: RayColor, RayVector2, RayVector3, RayVector4, RayQuaternion, map( f->include_dependency(joinpath(@__DIR__, "../../api_reference/", f)), - ("raylib_api.xml", "raygui_api.xml", "raymath_api.xml", "physac_api.xml") + ("raylib_api.xml", "raygui_api.xml", "raymath_api.xml", "rlgl_api.xml") ) include("./enum.jl") @@ -31,17 +31,22 @@ let idx = 0 push_c = false + in_string = false # tracks whether we're inside a quoted attribute value, so a + # literal '<'/'>' there (e.g. rlgl.h's "Update->Draw->Reset" in a desc="...") isn't + # mistaken for real tag structure - the comment above already says the intent was to + # avoid stacking in strings, but nothing previously enforced it for '<'/'>' itself. while !eof(io) idx += 1 c = read(io, Char) push!(char_stream, c) if c == '"' # avoid stacking in string + in_string = !in_string char_stream[last(stack)] == '"' ? pop!(stack) : push!(stack, idx) - elseif c == '<' # mark start position + elseif c == '<' && !in_string # mark start position push_c = true push!(stack, idx) - elseif c == '>' + elseif c == '>' && !in_string push_c = false pidx = pop!(stack) content = String(@view(char_stream[pidx:idx])) @@ -153,7 +158,12 @@ let "Transform" => :RayTransform, "BoneInfo" => :RayBoneInfo, "Model" => :RayModel, + "ModelSkeleton" => :RayModelSkeleton, "ModelAnimation" => :RayModelAnimation, + "ModelAnimPose" => :RayModelAnimPose, + "FilePathList" => :RayFilePathList, + "AutomationEvent" => :RayAutomationEvent, + "AutomationEventList" => :RayAutomationEventList, "Ray" => :Ray, "RayCollision" => :RayCollision, "BoundingBox" => :RayBoundingBox, @@ -170,11 +180,9 @@ let "Vector4" => (:RayVector4, :(StaticVector{4})), "Quaternion" => (:RayVector4, :(StaticVector{4})), "GuiStyleProp" => :RayGuiStyleProp, - "PhysicsShapeType" => :PhysicsShapeType, - "PhysicsVertexData" => :RayPhysicsVertexData, - "PhysicsShape" => :RayPhysicsShape, - "PhysicsBodyData" => :RayPhysicsBodyData, - "PhysicsBody" => :(Ptr{RayPhysicsBodyData}), + "rlVertexBuffer" => :RayrlVertexBuffer, + "rlDrawCall" => :RayrlDrawCall, + "rlRenderBatch" => :RayrlRenderBatch, ) maybe(f, x) = f(x) @@ -398,8 +406,7 @@ let apis = map( f->joinpath(@__DIR__, "../../api_reference/", f), - ("raylib_api.xml", "raygui_api.xml", - "raymath_api.xml", "physac_api.xml") + ("raylib_api.xml", "raygui_api.xml", "raymath_api.xml", "rlgl_api.xml") ) xmls = Dict( @@ -418,7 +425,7 @@ let gen(gen_struct, lib, :Struct, defs, s->Symbol("Ray$s"), 2) - if lib == "raylib" || lib == "physac" + if lib == "raylib" || lib == "rlgl" gen(gen_func, lib, :Function, defs) else gen(Base.Fix2(gen_func, false), lib, :Function, defs) diff --git a/src/binding/enum.jl b/src/binding/enum.jl index b14ebe4..8a8daab 100644 --- a/src/binding/enum.jl +++ b/src/binding/enum.jl @@ -365,8 +365,3 @@ end NPATCH_THREE_PATCH_VERTICAL # Npatch layout: 1x3 tiles NPATCH_THREE_PATCH_HORIZONTAL # Npatch layout: 3x1 tiles end - -@cenum PhysicsShapeType begin - PHYSICS_CIRCLE = 0 - PHYSICS_POLYGON -end diff --git a/src/binding/struct.jl b/src/binding/struct.jl index 0b98e27..c85e447 100644 --- a/src/binding/struct.jl +++ b/src/binding/struct.jl @@ -71,11 +71,14 @@ struct RayMesh colors::Ptr{Cuchar} # Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) indices::Ptr{Cuchar} # Vertex indices (in case vertex data comes indexed) - # Animation vertex data + # Skin data for animation + boneCount::Cint # Number of bones (MAX: 256 bones) + boneIndices::Ptr{Cuchar} # Vertex bone indices, up to 4 bones influence by vertex (skinning) + boneWeights::Ptr{Cfloat} # Vertex bone weight, up to 4 bones influence by vertex (skinning) + + # Runtime animation vertex data (CPU skinning) animVertices::Ptr{Cfloat} # Animated vertex positions (after bones transformations) animNormals::Ptr{Cfloat} # Animated normals (after bones transformations) - boneIds::Ptr{Cuchar} # Vertex bone ids, max 255 bone ids, up to 4 bones influence by vertex (skinning) - boneWeights::Ptr{Cfloat} # Vertex bone weight, up to 4 bones influence by vertex (skinning) # OpenGL identifiers vaoId::Cuint # OpenGL Vertex Array Object id @@ -105,11 +108,20 @@ struct RayTransform scale::RayVector3 # Scale end +# ModelAnimPose, an array of Transform[] +const RayModelAnimPose = Ptr{RayTransform} + struct RayBoneInfo name::NTuple{32, Cchar} # Bone name parent::Cint # Bone parent end +struct RayModelSkeleton + boneCount::Cint # Number of bones + bones::Ptr{RayBoneInfo} # Bones information (skeleton) + bindPose::RayModelAnimPose # Bones base transformation (Transform[]) +end + struct RayModel transform::RayMatrix # Local transform matrix @@ -120,17 +132,19 @@ struct RayModel meshMaterial::Ptr{Cint} # Mesh material number # Animation data - boneCount::Cint # Number of bones - bones::Ptr{RayBoneInfo} # Bones information (skeleton) - bindPose::Ptr{RayTransform} # Bones base transformation (pose) + skeleton::RayModelSkeleton # Skeleton for animation + + # Runtime animation data (CPU/GPU skinning) + currentPose::RayModelAnimPose # Current animation pose (Transform[]) + boneMatrices::Ptr{RayMatrix} # Bones animated transformation matrices end struct RayModelAnimation - boneCount::Cint # Number of bones - frameCount::Cint # Number of animation frames - bones::Ptr{RayBoneInfo} # Bones information (skeleton) - # Transform **framePoses # Poses array by frame - framePoses::Ptr{Ptr{RayTransform}} # Poses array by frame + name::NTuple{32, Cchar} # Animation name + + boneCount::Cint # Number of bones (per pose) + keyframeCount::Cint # Number of animation key frames + keyframePoses::Ptr{RayModelAnimPose} # Animation sequence keyframe poses [keyframe][pose] end struct Ray @@ -161,6 +175,8 @@ end struct RayAudioStream # rAudioBuffer *buffer; // Pointer to internal data used by the audio system buffer::Ptr{Cvoid} + # rAudioProcessor *processor; // Pointer to internal data processor, useful for audio effects + processor::Ptr{Cvoid} sampleRate::Cuint # Frequency (samples per second) sampleSize::Cuint # Bit depth (bits per sample): 8, 16, 32 (24 not supported) @@ -186,7 +202,6 @@ struct RayVrDeviceInfo vResolution::Cint # Vertical resolution in pixels hScreenSize::Cfloat # Horizontal size in meters vScreenSize::Cfloat # Vertical size in meters - vScreenCenter::Cfloat # Screen center in meters eyeToScreenDistance::Cfloat # Distance between eye and display in meters lensSeparationDistance::Cfloat # Lens separation distance in meters interpupillaryDistance::Cfloat # IPD (distance between pupils) in meters @@ -205,60 +220,55 @@ struct RayVrStereoConfig scaleIn::NTuple{2, Cfloat} # VR distortion scale in end +struct RayFilePathList + count::Cuint # Filepaths entries count + paths::Ptr{Cstring} # Filepaths entries +end + +struct RayAutomationEvent + frame::Cuint # Event frame + type::Cuint # Event type (AutomationEventType) + params::NTuple{4, Cint} # Event parameters (if required) +end + +struct RayAutomationEventList + capacity::Cuint # Events max entries (MAX_AUTOMATION_EVENTS) + count::Cuint # Events entries count + events::Ptr{RayAutomationEvent} # Events entries +end + struct RayGuiStyleProp controlId::Cushort propertyId::Cushort propertyValue::Cint end -const PHYSAC_MAX_VERTICES = 24 - -struct RayPhysicsVertexData - vertexCount::Cuint # Vertex count (positions and normals) - positions::NTuple{PHYSAC_MAX_VERTICES, RayVector2} # Vertex positions vectors - normals::NTuple{PHYSAC_MAX_VERTICES, RayVector2} # Vertex normals vectors -end - -struct RayPhysicsShape - type::PhysicsShapeType # Shape type (circle or polygon) - # body::Ptr{RayPhysicsBodyData} - body::Ptr{Cvoid} # Shape physics body data pointer - vertexData::RayPhysicsVertexData # Shape vertices data (used for polygon shapes) - radius::Cfloat # Shape radius (used for circle shapes) - transform::RayMatrix2x2 # Vertices transform matrix 2x2 -end - -struct RayPhysicsBodyData - id::Cuint # Unique identifier - enabled::Bool # Enabled dynamics state (collisions are calculated anyway) - position::RayVector2 # Physics body shape pivot - velocity::RayVector2 # Current linear velocity applied to position - force::RayVector2 # Current linear force (reset to 0 every step) - angularVelocity::Cfloat # Current angular velocity applied to orient - torque::Cfloat # Current angular force (reset to 0 every step) - orient::Cfloat # Rotation in radians - inertia::Cfloat # Moment of inertia - inverseInertia::Cfloat # Inverse value of inertia - mass::Cfloat # Physics body mass - inverseMass::Cfloat # Inverse value of mass - staticFriction::Cfloat # Friction when the body has not movement (0 to 1) - dynamicFriction::Cfloat # Friction when the body has movement (0 to 1) - restitution::Cfloat # Restitution coefficient of the body (0 to 1) - useGravity::Bool # Apply gravity force to dynamics - isGrounded::Bool # Physics grounded on other body state - freezeOrient::Bool # Physics rotation constraint - shape::RayPhysicsShape # Physics body shape information (type, radius, vertices, transform) -end - -struct RayPhysicsManifoldData - id::Cuint # Unique identifier - bodyA::Ptr{RayPhysicsBodyData} # Manifold first physics body reference - bodyB::Ptr{RayPhysicsBodyData} # Manifold second physics body reference - penetration::Cfloat # Depth of penetration from collision - normal::RayVector2 # Normal direction vector from 'a' to 'b' - contacts::NTuple{2, RayVector2} # Points of contact during collision - contactsCount::Cuint # Current collision number of contacts - restitution::Cfloat # Mixed restitution during collision - dynamicFriction::Cfloat # Mixed dynamic friction during collision - staticFriction::Cfloat # Mixed static friction during collision +struct RayrlVertexBuffer + elementCount::Cint # Number of elements in the buffer (QUADS) + + vertices::Ptr{Cfloat} # Vertex position (XYZ - 3 components per vertex) + texcoords::Ptr{Cfloat} # Vertex texture coordinates (UV - 2 components per vertex) + normals::Ptr{Cfloat} # Vertex normal (XYZ - 3 components per vertex) + colors::Ptr{Cuchar} # Vertex colors (RGBA - 4 components per vertex) + indices::Ptr{Cuint} # Vertex indices (desktop GL: unsigned int; GL ES2 uses unsigned short instead) + + vaoId::Cuint # OpenGL Vertex Array Object id + vboId::NTuple{5, Cuint} # OpenGL Vertex Buffer Objects id (5 types of vertex data) +end + +struct RayrlDrawCall + mode::Cint # Drawing mode: LINES, TRIANGLES, QUADS + vertexCount::Cint # Number of vertex of the draw + vertexAlignment::Cint # Number of vertex required for index alignment (LINES, TRIANGLES) + textureId::Cuint # Texture id to be used on the draw +end + +struct RayrlRenderBatch + bufferCount::Cint # Number of vertex buffers (multi-buffering support) + currentBuffer::Cint # Current buffer tracking in case of multi-buffering + vertexBuffer::Ptr{RayrlVertexBuffer} # Dynamic buffer(s) for vertex data + + draws::Ptr{RayrlDrawCall} # Draw calls array, depends on textureId + drawCounter::Cint # Draw calls counter + currentDepth::Cfloat # Current depth value for next draw end diff --git a/src/core.jl b/src/core.jl index eac999a..90a2367 100644 --- a/src/core.jl +++ b/src/core.jl @@ -1,23 +1,23 @@ """ - UpdateCamera(camera::RayCamera3D) + UpdateCamera(camera::RayCamera3D, mode) -Return new camera with updated parameter. +Return new camera with updated parameter for selected `mode` (a `CameraMode` value). """ -function Binding.UpdateCamera(camera::RayCamera3D) +function Binding.UpdateCamera(camera::RayCamera3D, mode) new_camera_ref = Ref(camera) - UpdateCamera(new_camera_ref) + UpdateCamera(new_camera_ref, Cint(mode)) return new_camera_ref[] end """ - UpdateCamera!(camera::RayCamera3D) + UpdateCamera!(camera::RayCamera3D, mode) -Update camera position for selected mode +Update camera position for selected `mode` (a `CameraMode` value). """ -function UpdateCamera!(camera::RayCamera3D) +function UpdateCamera!(camera::RayCamera3D, mode) camera_ptr = convert(Ptr{RayCamera3D}, pointer_from_objref(camera)) - UpdateCamera(camera_ptr) + UpdateCamera(camera_ptr, Cint(mode)) return camera end @@ -26,11 +26,12 @@ end Return a list of dropped file paths. """ -function Binding.GetDroppedFiles() - count = Ref{Cint}(0) - fptrs = GetDroppedFiles(count) - fcstr = Base.unsafe_wrap(Vector{Cstring}, fptrs, count[]) - return map(Base.unsafe_string, fcstr) +function GetDroppedFiles() + files = LoadDroppedFiles() + fcstr = Base.unsafe_wrap(Vector{Cstring}, files.paths, files.count) + paths = map(Base.unsafe_string, fcstr) + UnloadDroppedFiles(files) + return paths end """ @@ -42,7 +43,7 @@ struct RayFileData data::Vector{UInt8} function RayFileData(filename::AbstractString) - bytes = Ref{Cuint}(0) + bytes = Ref{Cint}(0) dptr = LoadFileData(filename, bytes) fdata = Base.unsafe_wrap(Vector{UInt8}, dptr, bytes[]) finalizer(fdata) do x diff --git a/test/core.jl b/test/core.jl index fba8485..75824aa 100644 --- a/test/core.jl +++ b/test/core.jl @@ -72,9 +72,12 @@ end Raylib.CAMERA_ORTHOGRAPHIC ]) - Raylib.SetCameraMode(camera, Int(Raylib.CAMERA_FIRST_PERSON)) - Raylib.UpdateCamera!(camera) - @test !test_camera(camera, [ + # raylib 6.0's rcamera.h rewrite made UpdateCamera purely input-driven (IsKeyDown/ + # GetMouseDelta/GetFrameTime), unlike <=4.x's unconditional per-call recompute from + # persisted static angle state. With no window/input backend (as here, headless), + # those all report false/zero, so FIRST_PERSON is now a real no-op. + Raylib.UpdateCamera!(camera, Raylib.CAMERA_FIRST_PERSON) + @test test_camera(camera, [ Raylib.rayvector(0, 10, 10) + Raylib.rayvector(1, 2, 3), Raylib.rayvector(0, 0, 0) + Raylib.rayvector(3, 2, 1), Raylib.rayvector(0, 1, 0) + Raylib.rayvector(4, 5, 6), @@ -82,8 +85,7 @@ end Raylib.CAMERA_ORTHOGRAPHIC ]) - Raylib.SetCameraMode(camera, Int(Raylib.CAMERA_CUSTOM)) - Raylib.UpdateCamera!(camera) + Raylib.UpdateCamera!(camera, Raylib.CAMERA_CUSTOM) camera.position = Raylib.rayvector(1, 2, 3) camera.target = Raylib.rayvector(3, 2, 1) camera.up = Raylib.rayvector(4, 5, 6) @@ -97,8 +99,7 @@ end Raylib.CAMERA_ORTHOGRAPHIC ]) - Raylib.SetCameraMode(camera, Int(Raylib.CAMERA_FIRST_PERSON)) - camera = Raylib.UpdateCamera(camera) + camera = Raylib.UpdateCamera(camera, Raylib.CAMERA_FIRST_PERSON) @test !test_camera(camera, [ Raylib.rayvector(1, 2, 3), Raylib.rayvector(3, 2, 1),