Repository navigation
Expand file tree
/
Copy pathhello_world.zig
More file actions
62 lines (52 loc) · 1.5 KB
/
Copy pathhello_world.zig
File metadata and controls
62 lines (52 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const std = @import("std");
const Example = @import("../example.zig").Example;
const raylib = @import("raylib");
pub const example = Example{
.initFn = init,
.updateFn = update,
};
fn init(_: std.mem.Allocator) !void {
raylib.InitWindow(800, 800, "hello world!");
raylib.SetConfigFlags(.{ .FLAG_WINDOW_RESIZABLE = true });
raylib.SetTargetFPS(60);
}
fn update(_: f32) !void {
raylib.BeginDrawing();
defer raylib.EndDrawing();
raylib.ClearBackground(raylib.BLACK);
raylib.DrawFPS(10, 10);
raylib.DrawText(
"hello world!",
100,
100,
30,
raylib.YELLOW,
);
var buf: [1024]u8 = undefined;
const raylibVersion = try std.fmt.bufPrintZ(&buf, "raylib {s}", .{raylib.RAYLIB_VERSION});
raylib.DrawText(
raylibVersion,
100,
150,
20,
raylib.YELLOW,
);
const rlGlVersion = try std.fmt.bufPrintZ(&buf, "rlgl {s}", .{raylib.RLGL_VERSION});
raylib.DrawText(
rlGlVersion,
100,
180,
20,
raylib.YELLOW,
);
const glslVersion = try std.fmt.bufPrintZ(&buf, "GL_SHADING_LANGUAGE_VERSION {d}", .{raylib.GL_SHADING_LANGUAGE_VERSION});
raylib.DrawText(
glslVersion,
100,
210,
20,
raylib.YELLOW,
);
raylib.DrawText("zig build --help\n\nto see a list of examples", 100, 300, 18, raylib.BLUE);
raylib.DrawText("zig build run -Dexample=6\n\nto run a specific example", 400, 400, 18, raylib.ORANGE);
}