diff options
| author | Max Danielsson <max@autious.net> | 2018-03-27 19:58:42 +0200 |
|---|---|---|
| committer | Max Danielsson <max@autious.net> | 2018-03-27 19:58:42 +0200 |
| commit | e38d28543a6bcb451a3b1176a159d4fc0ff15326 (patch) | |
| tree | c7fd2e2f1349e4b856c2d667d0862d561e2c5ca5 /examples | |
| parent | d91179f8ab50b608b2dfc04bccbddbd2cd9b68e5 (diff) | |
| download | raylib-e38d28543a6bcb451a3b1176a159d4fc0ff15326.tar.gz raylib-e38d28543a6bcb451a3b1176a159d4fc0ff15326.zip | |
Remove state bool in camera projection type example.
Changes made based on commentary in pull request 513
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/models/models_orthographic_projection.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/examples/models/models_orthographic_projection.c b/examples/models/models_orthographic_projection.c index 214fc969..b28aa0ae 100644 --- a/examples/models/models_orthographic_projection.c +++ b/examples/models/models_orthographic_projection.c @@ -19,12 +19,13 @@ int main() //-------------------------------------------------------------------------------------- int screenWidth = 800; int screenHeight = 450; - bool view_ortho = true; InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes"); + const Camera perspective_camera = (Camera){{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, CAMERA_PERSPECTIVE }; + const Camera orthographic_camera = (Camera){{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 10.0f, CAMERA_ORTHOGRAPHIC }; // Define the camera to look into our 3d world - Camera camera; + Camera camera = perspective_camera; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -42,21 +43,20 @@ int main() //---------------------------------------------------------------------------------- if(IsKeyPressed(KEY_SPACE)) { - view_ortho = !view_ortho; + if(camera.type == CAMERA_PERSPECTIVE) + { + camera = orthographic_camera; + } + else + { + camera = perspective_camera; + } } // Draw //---------------------------------------------------------------------------------- - if(view_ortho) - { - camera = (Camera){{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 10.0f, CAMERA_ORTHOGRAPHIC }; - } - else - { - camera = (Camera){{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, CAMERA_PERSPECTIVE }; - } BeginDrawing(); @@ -86,11 +86,11 @@ int main() DrawText("Press Spacebar to switch camera type", 10, 40, 24, BLACK); - if(view_ortho) + if(camera.type == CAMERA_ORTHOGRAPHIC) { DrawText("Orthographic", 10, 65, 24, BLACK); } - else + else if(camera.type == CAMERA_PERSPECTIVE) { DrawText("Perspective", 10, 65, 24, BLACK); } |
