1/*******************************************************************************************
2*
3* raylib [core] example - Initialize 3d camera mode
4*
5* This example has been created using raylib 1.0 (www.raylib.com)
6* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
7*
8* Copyright (c) 2014 Ramon Santamaria (@raysan5)
9*
10********************************************************************************************/
11
12#include "raylib.h"
13
14int main(void)
15{
16 // Initialization
17 //--------------------------------------------------------------------------------------
18 const int screenWidth = 800;
19 const int screenHeight = 450;
20
21 InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera mode");
22
23 // Define the camera to look into our 3d world
24 Camera3D camera = { 0 };
25 camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position
26 camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
27 camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
28 camera.fovy = 45.0f; // Camera field-of-view Y
29 camera.type = CAMERA_PERSPECTIVE; // Camera mode type
30
31 Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
32
33 SetTargetFPS(60); // Set our game to run at 60 frames-per-second
34 //--------------------------------------------------------------------------------------
35
36 // Main game loop
37 while (!WindowShouldClose()) // Detect window close button or ESC key
38 {
39 // Update
40 //----------------------------------------------------------------------------------
41 // TODO: Update your variables here
42 //----------------------------------------------------------------------------------
43
44 // Draw
45 //----------------------------------------------------------------------------------
46 BeginDrawing();
47
48 ClearBackground(RAYWHITE);
49
50 BeginMode3D(camera);
51
52 DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
53 DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
54
55 DrawGrid(10, 1.0f);
56
57 EndMode3D();
58
59 DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY);
60
61 DrawFPS(10, 10);
62
63 EndDrawing();
64 //----------------------------------------------------------------------------------
65 }
66
67 // De-Initialization
68 //--------------------------------------------------------------------------------------
69 CloseWindow(); // Close window and OpenGL context
70 //--------------------------------------------------------------------------------------
71
72 return 0;
73}