1 | /******************************************************************************************* |
2 | * |
3 | * raylib [models] example - Draw some basic geometric shapes (cube, sphere, cylinder...) |
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 | |
14 | int main(void) |
15 | { |
16 | // Initialization |
17 | //-------------------------------------------------------------------------------------- |
18 | const int screenWidth = 800; |
19 | const int screenHeight = 450; |
20 | |
21 | InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes" ); |
22 | |
23 | // Define the camera to look into our 3d world |
24 | Camera camera = { 0 }; |
25 | camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; |
26 | camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; |
27 | camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; |
28 | camera.fovy = 45.0f; |
29 | camera.type = CAMERA_PERSPECTIVE; |
30 | |
31 | SetTargetFPS(60); // Set our game to run at 60 frames-per-second |
32 | //-------------------------------------------------------------------------------------- |
33 | |
34 | // Main game loop |
35 | while (!WindowShouldClose()) // Detect window close button or ESC key |
36 | { |
37 | // Update |
38 | //---------------------------------------------------------------------------------- |
39 | // TODO: Update your variables here |
40 | //---------------------------------------------------------------------------------- |
41 | |
42 | // Draw |
43 | //---------------------------------------------------------------------------------- |
44 | BeginDrawing(); |
45 | |
46 | ClearBackground(RAYWHITE); |
47 | |
48 | BeginMode3D(camera); |
49 | |
50 | DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED); |
51 | DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD); |
52 | DrawCubeWires((Vector3){-4.0f, 0.0f, -2.0f}, 3.0f, 6.0f, 2.0f, MAROON); |
53 | |
54 | DrawSphere((Vector3){-1.0f, 0.0f, -2.0f}, 1.0f, GREEN); |
55 | DrawSphereWires((Vector3){1.0f, 0.0f, 2.0f}, 2.0f, 16, 16, LIME); |
56 | |
57 | DrawCylinder((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, SKYBLUE); |
58 | DrawCylinderWires((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, DARKBLUE); |
59 | DrawCylinderWires((Vector3){4.5f, -1.0f, 2.0f}, 1.0f, 1.0f, 2.0f, 6, BROWN); |
60 | |
61 | DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD); |
62 | DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK); |
63 | |
64 | DrawGrid(10, 1.0f); // Draw a grid |
65 | |
66 | EndMode3D(); |
67 | |
68 | DrawFPS(10, 10); |
69 | |
70 | EndDrawing(); |
71 | //---------------------------------------------------------------------------------- |
72 | } |
73 | |
74 | // De-Initialization |
75 | //-------------------------------------------------------------------------------------- |
76 | CloseWindow(); // Close window and OpenGL context |
77 | //-------------------------------------------------------------------------------------- |
78 | |
79 | return 0; |
80 | } |