switch from raylib to capy

This commit is contained in:
Fabien Freling 2024-05-04 19:03:50 +02:00
parent f5a5157e80
commit b4202d4120
11 changed files with 56 additions and 103 deletions

View file

@ -1,40 +1,20 @@
const std = @import("std");
const r = @import("raylib.zig");
const capy = @import("capy");
pub fn main() anyerror!void {
r.InitWindow(800, 450, "doggo");
defer r.CloseWindow();
// This is required for your app to build to WebAssembly and other particular architectures
pub usingnamespace capy.cross_platform;
// var selected_filename: [512]u8 = undefined;
var file_dialog_state = r.InitGuiFileDialog(420, 310, r.GetWorkingDirectory(), false);
pub fn main() !void {
try capy.backend.init();
while (!r.WindowShouldClose()) {
// Update
if (file_dialog_state.SelectFilePressed) {
std.log.info("{s} / {s}", .{ file_dialog_state.dirPathText, file_dialog_state.fileNameText });
}
var window = try capy.Window.init();
try window.set(
capy.label(.{ .text = "Hello, World", .alignment = .Center }),
);
// Draw
r.BeginDrawing();
defer r.EndDrawing();
window.setTitle("Hello");
window.setPreferredSize(250, 100);
window.show();
r.ClearBackground(r.RAYWHITE);
r.DrawText("Congrats! You created your first window!", 190, 200, 20, r.LIGHTGRAY);
if (file_dialog_state.fileDialogActive) {
r.GuiLock();
}
if (r.GuiButton(r.Rectangle{ .x = 190, .y = 250, .width = 150, .height = 30 }, "Button")) {
std.log.info("Button pressed", .{});
file_dialog_state.fileDialogActive = true;
}
r.GuiUnlock();
r.GuiFileDialog(&file_dialog_state);
}
}
test "basic test" {
try std.testing.expectEqual(10, 3 + 7);
capy.runEventLoop();
}

View file

@ -1,6 +0,0 @@
#define RAYGUI_IMPLEMENTATION
#include <raygui.h>
#undef RAYGUI_IMPLEMENTATION // Avoid including raygui implementation again
#define GUI_FILE_DIALOG_IMPLEMENTATION
#include <custom_file_dialog/gui_file_dialog.h>

View file

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