Skip to content

Commit

Permalink
test UpdateCamera!
Browse files Browse the repository at this point in the history
  • Loading branch information
foldfelis committed Nov 17, 2021
1 parent 5eeeff6 commit 05b31fa
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions test/core.jl
Original file line number Diff line number Diff line change
@@ -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],
Expand All @@ -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],
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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),
Expand All @@ -61,13 +61,37 @@ 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),
60,
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

0 comments on commit 05b31fa

Please # to comment.