Debian Codegraph @

projects/Zig/src/core_basic_window.zig

raw
1 //*******************************************************************************************
2 //*
3 //* raylib [core] example - Basic window (adapted for HTML5 platform)
4 //*
5 //* This example is prepared to compile for PLATFORM_WEB and PLATFORM_DESKTOP
6 //* As you will notice, code structure is slightly different 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 6.0 (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 //* Rewrite in Zig by HaxSam (@haxsam)
14 //*
15 //*******************************************************************************************
16
17 const rl = @import("raylib");
18 const std = @import("std");
19 const builtin = @import("builtin");
20
21 //----------------------------------------------------------------------------------
22 // Global Variables Definition
23 //----------------------------------------------------------------------------------
24 const screenWidth: c_int = 800;
25 const screenHeight: c_int = 450;
26
27 //----------------------------------------------------------------------------------
28 // Program main entry point
29 //----------------------------------------------------------------------------------
30 pub fn main() void {
31 // Initialization
32 //--------------------------------------------------------------------------------------
33 rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
34
35 if (builtin.os.tag == .emscripten) {
36 std.os.emscripten.emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
37 } else {
38 rl.SetTargetFPS(60); // Set our game to run at 60 frames-per-second
39 //--------------------------------------------------------------------------------------
40
41 // Main game loop
42 while (!rl.WindowShouldClose()) // Detect window close button or ESC key
43 {
44 UpdateDrawFrame();
45 }
46 }
47
48 // De-Initialization
49 //--------------------------------------------------------------------------------------
50 rl.CloseWindow(); // Close window and OpenGL context
51 //--------------------------------------------------------------------------------------
52 }
53
54 //----------------------------------------------------------------------------------
55 // Module Functions Definition
56 //----------------------------------------------------------------------------------
57 fn UpdateDrawFrame() callconv(.c) void {
58 // Update
59 //----------------------------------------------------------------------------------
60 // TODO: Update your variables here
61 //----------------------------------------------------------------------------------
62
63 // Draw
64 //----------------------------------------------------------------------------------
65 rl.BeginDrawing();
66
67 rl.ClearBackground(rl.RAYWHITE);
68
69 rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LIGHTGRAY);
70
71 rl.EndDrawing();
72 //----------------------------------------------------------------------------------
73 }