From 05b31fa2944ef8c1faa06e1bcfe19bafc73e2a25 Mon Sep 17 00:00:00 2001 From: JingYu Ning Date: Wed, 17 Nov 2021 16:46:31 +0800 Subject: [PATCH] test `UpdateCamera!` --- test/core.jl | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/test/core.jl b/test/core.jl index b2d6a2b..0f12934 100644 --- a/test/core.jl +++ b/test/core.jl @@ -1,5 +1,5 @@ function test_camera(camera::Raylib.RayCamera2D, ans::Vector) - @test all([ + return all([ camera.offset == ans[1], camera.target == ans[2], camera.rotation == ans[3], @@ -8,7 +8,7 @@ function test_camera(camera::Raylib.RayCamera2D, ans::Vector) end function test_camera(camera::Raylib.RayCamera3D, ans::Vector) - @test all([ + return all([ camera.position == ans[1], camera.target == ans[2], camera.up == ans[3], @@ -17,14 +17,14 @@ function test_camera(camera::Raylib.RayCamera3D, ans::Vector) ]) end -@testset "core" begin +@testset "set camera properties" begin camera = Raylib.RayCamera2D( Raylib.rayvector(1, 2), # camera offset Raylib.rayvector(3, 4), # camera target 0, # camera rotation 1, # camera zoom ) - test_camera(camera, [ + @test test_camera(camera, [ Raylib.rayvector(1, 2), Raylib.rayvector(3, 4), 0, @@ -35,7 +35,7 @@ end camera.target += Raylib.rayvector(7, 8) camera.rotation = 45 camera.zoom = 3 - test_camera(camera, [ + @test test_camera(camera, [ Raylib.rayvector(1, 2) + Raylib.rayvector(5, 6), Raylib.rayvector(3, 4) + Raylib.rayvector(7, 8), 45, @@ -49,7 +49,7 @@ end 45, # camera field-of-view Y Raylib.CAMERA_PERSPECTIVE, # camera mode type ) - test_camera(camera, [ + @test test_camera(camera, [ Raylib.rayvector(0, 10, 10), Raylib.rayvector(0, 0, 0), Raylib.rayvector(0, 1, 0), @@ -61,8 +61,8 @@ end camera.target += Raylib.rayvector(3, 2, 1) camera.up += Raylib.rayvector(4, 5, 6) camera.fovy = 60 - camera.projection = Int(Raylib.CAMERA_ORTHOGRAPHIC) - test_camera(camera, [ + camera.projection = Raylib.CAMERA_ORTHOGRAPHIC + @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), @@ -70,4 +70,28 @@ end Raylib.CAMERA_ORTHOGRAPHIC ]) + Raylib.SetCameraMode(camera, Int(Raylib.CAMERA_FIRST_PERSON)) + Raylib.UpdateCamera!(camera) + @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), + 60, + Raylib.CAMERA_ORTHOGRAPHIC + ]) + + Raylib.SetCameraMode(camera, Int(Raylib.CAMERA_CUSTOM)) + Raylib.UpdateCamera!(camera) + camera.position = Raylib.rayvector(1, 2, 3) + camera.target = Raylib.rayvector(3, 2, 1) + camera.up = Raylib.rayvector(4, 5, 6) + camera.fovy = 60 + camera.projection = Raylib.CAMERA_ORTHOGRAPHIC + @test test_camera(camera, [ + Raylib.rayvector(1, 2, 3), + Raylib.rayvector(3, 2, 1), + Raylib.rayvector(4, 5, 6), + 60, + Raylib.CAMERA_ORTHOGRAPHIC + ]) end