1 | /******************************************************************************************* |
2 | * |
3 | * raylib [core] example - Basic window (adapted for HTML5 platform) |
4 | * |
5 | * This example is prepared to compile for PLATFORM_WEB, PLATFORM_DESKTOP and PLATFORM_RPI |
6 | * As you will notice, code structure is slightly diferent to the other examples... |
7 | * To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning |
8 | * |
9 | * This example has been created using raylib 1.3 (www.raylib.com) |
10 | * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) |
11 | * |
12 | * Copyright (c) 2015 Ramon Santamaria (@raysan5) |
13 | * |
14 | ********************************************************************************************/ |
15 | |
16 | #include "raylib.h" |
17 | |
18 | //#define PLATFORM_WEB |
19 | |
20 | #if defined(PLATFORM_WEB) |
21 | #include <emscripten/emscripten.h> |
22 | #endif |
23 | |
24 | //---------------------------------------------------------------------------------- |
25 | // Global Variables Definition |
26 | //---------------------------------------------------------------------------------- |
27 | int screenWidth = 800; |
28 | int screenHeight = 450; |
29 | |
30 | //---------------------------------------------------------------------------------- |
31 | // Module Functions Declaration |
32 | //---------------------------------------------------------------------------------- |
33 | void UpdateDrawFrame(void); // Update and Draw one frame |
34 | |
35 | //---------------------------------------------------------------------------------- |
36 | // Main Enry Point |
37 | //---------------------------------------------------------------------------------- |
38 | int main() |
39 | { |
40 | // Initialization |
41 | //-------------------------------------------------------------------------------------- |
42 | InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window" ); |
43 | |
44 | #if defined(PLATFORM_WEB) |
45 | emscripten_set_main_loop(UpdateDrawFrame, 0, 1); |
46 | #else |
47 | SetTargetFPS(60); // Set our game to run at 60 frames-per-second |
48 | //-------------------------------------------------------------------------------------- |
49 | |
50 | // Main game loop |
51 | while (!WindowShouldClose()) // Detect window close button or ESC key |
52 | { |
53 | UpdateDrawFrame(); |
54 | } |
55 | #endif |
56 | |
57 | // De-Initialization |
58 | //-------------------------------------------------------------------------------------- |
59 | CloseWindow(); // Close window and OpenGL context |
60 | //-------------------------------------------------------------------------------------- |
61 | |
62 | return 0; |
63 | } |
64 | |
65 | //---------------------------------------------------------------------------------- |
66 | // Module Functions Definition |
67 | //---------------------------------------------------------------------------------- |
68 | void UpdateDrawFrame(void) |
69 | { |
70 | // Update |
71 | //---------------------------------------------------------------------------------- |
72 | // TODO: Update your variables here |
73 | //---------------------------------------------------------------------------------- |
74 | |
75 | // Draw |
76 | //---------------------------------------------------------------------------------- |
77 | BeginDrawing(); |
78 | |
79 | ClearBackground(RAYWHITE); |
80 | |
81 | DrawText("Congrats! You created your first window!" , 190, 200, 20, LIGHTGRAY); |
82 | |
83 | EndDrawing(); |
84 | //---------------------------------------------------------------------------------- |
85 | } |