Debian Codegraph @

projects/VSCode/main.c

raw symbols SCIP
1 /*******************************************************************************************
2 *
3 * raylib [core] example - Basic 3d example
4 *
5 * Welcome to raylib!
6 *
7 * To compile example, just press F5.
8 * Note that compiled executable is placed in the same folder as .c file
9 *
10 * You can find all basic examples on C:\raylib\raylib\examples folder or
11 * raylib official webpage: www.raylib.com
12 *
13 * Enjoy using raylib. :)
14 *
15 * This example has been created using raylib 1.0 (www.raylib.com)
16 * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
17 *
18 * Copyright (c) 2013-2026 Ramon Santamaria (@raysan5)
19 *
20 ********************************************************************************************/
21
22 #include "raylib.h"
23
24 #if defined(PLATFORM_WEB)
25 #include <emscripten/emscripten.h>
26 #endif
27
28 //----------------------------------------------------------------------------------
29 // Global Variables Definition (local to this module)
30 //----------------------------------------------------------------------------------
31 Camera camera = { 0 };
32 Vector3 cubePosition = { 0 };
33
34 //----------------------------------------------------------------------------------
35 // Module Functions Declaration
36 //----------------------------------------------------------------------------------
37 static void UpdateDrawFrame(void); // Update and draw one frame
38
39 //----------------------------------------------------------------------------------
40 // Program main entry point
41 //----------------------------------------------------------------------------------
42 int main()
43 {
44 // Initialization
45 //--------------------------------------------------------------------------------------
46 const int screenWidth = 800;
47 const int screenHeight = 450;
48
49 InitWindow(screenWidth, screenHeight, "raylib");
50
51 camera.position = (Vector3){ 10.0f, 10.0f, 8.0f };
52 camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
53 camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
54 camera.fovy = 60.0f;
55 camera.projection = CAMERA_PERSPECTIVE;
56
57 //--------------------------------------------------------------------------------------
58
59 #if defined(PLATFORM_WEB)
60 emscripten_set_main_loop(UpdateDrawFrame, 60, 1);
61 #else
62 SetTargetFPS(60); // Set our game to run at 60 frames-per-second
63 //--------------------------------------------------------------------------------------
64
65 // Main game loop
66 while (!WindowShouldClose()) // Detect window close button or ESC key
67 {
68 UpdateDrawFrame();
69 }
70 #endif
71
72 // De-Initialization
73 //--------------------------------------------------------------------------------------
74 CloseWindow(); // Close window and OpenGL context
75 //--------------------------------------------------------------------------------------
76
77 return 0;
78 }
79
80 // Update and draw game frame
81 static void UpdateDrawFrame(void)
82 {
83 // Update
84 //----------------------------------------------------------------------------------
85 UpdateCamera(&camera, CAMERA_ORBITAL);
86 //----------------------------------------------------------------------------------
87
88 // Draw
89 //----------------------------------------------------------------------------------
90 BeginDrawing();
91
92 ClearBackground(RAYWHITE);
93
94 BeginMode3D(camera);
95
96 DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
97 DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
98 DrawGrid(10, 1.0f);
99
100 EndMode3D();
101
102 DrawText("This is a raylib example", 10, 40, 20, DARKGRAY);
103
104 DrawFPS(10, 10);
105
106 EndDrawing();
107 //----------------------------------------------------------------------------------
108 }