add small wrapper for raylib

Fabien Freling 2022-04-07 14:12:23 +02:00
parent 749661ec36
commit 4d9b82f289
5 changed files with 21 additions and 18 deletions

2
3rdparty/raygui vendored

@ -1 +1 @@
Subproject commit fd0d50bdb01e43f21b5ca33b9ef0f7f43f55e3f1
Subproject commit 865bb293764073c01e74314ef647464f1f10fd96

View File

@ -17,8 +17,9 @@ pub fn build(b: *std.build.Builder) void {
const ray = raylib.addRaylib(b, exe.target);
exe.linkLibrary(ray);
exe.addIncludeDir("./3rdparty/raylib/src");
exe.addIncludeDir("./3rdparty/raygui/src");
exe.addIncludeDir("3rdparty/raylib/src");
exe.addIncludeDir("3rdparty/raygui/src");
exe.addCSourceFile("src/raylib.c", &[_][]u8{});
exe.setBuildMode(mode);
exe.install();

View File

@ -1,26 +1,20 @@
const std = @import("std");
const ray = @cImport({
@cInclude("raylib.h");
});
const raygui = @cImport({
@cDefine("RAYGUI_IMPLEMENTATION", {});
@cInclude("raygui.h");
});
const r = @import("raylib.zig");
pub fn main() anyerror!void {
std.log.info("All your codebase are belong to us.", .{});
ray.InitWindow(800, 450, "ray [core] example - basic window");
defer ray.CloseWindow();
r.InitWindow(800, 450, "ray [core] example - basic window");
defer r.CloseWindow();
while (!ray.WindowShouldClose()) {
ray.BeginDrawing();
defer ray.EndDrawing();
while (!r.WindowShouldClose()) {
r.BeginDrawing();
defer r.EndDrawing();
ray.ClearBackground(ray.RAYWHITE);
ray.DrawText("Congrats! You created your first window!", 190, 200, 20, ray.LIGHTGRAY);
r.ClearBackground(r.RAYWHITE);
r.DrawText("Congrats! You created your first window!", 190, 200, 20, r.LIGHTGRAY);
if (raygui.GuiButton(raygui.Rectangle{ .x = 190, .y = 250, .width = 150, .height = 30 }, "Button")) {
if (r.GuiButton(r.Rectangle{ .x = 190, .y = 250, .width = 150, .height = 30 }, "Button")) {
std.log.info("Button pressed", .{});
}
}

4
src/raylib.c Normal file
View File

@ -0,0 +1,4 @@
#include <raylib.h>
#define RAYGUI_IMPLEMENTATION
#include <raygui.h>

4
src/raylib.zig Normal file
View File

@ -0,0 +1,4 @@
pub usingnamespace @cImport({
@cInclude("raylib.h");
@cInclude("raygui.h");
});