1
0

add raylib-zig as a proper submodule

This commit is contained in:
Rokas Puzonas 2023-09-02 22:31:23 +03:00
parent ac6c1e2064
commit df4dadc29d
4 changed files with 10 additions and 7 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "libs/raylib-zig"]
path = libs/raylib-zig
url = git@github.com:Not-Nik/raylib-zig.git

View File

@ -1,11 +1,9 @@
const std = @import("std");
const rl = @import("raylib-zig/build.zig");
const rl = @import("libs/raylib-zig/build.zig");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
var raylib = rl.getModule(b, "raylib-zig");
var raylib_math = rl.math.getModule(b, "raylib-zig");
// TODO: Figure out how to build project for WASM. Tried to do it but standard memory allocators
// didn't work.
@ -34,8 +32,8 @@ pub fn build(b: *std.Build) !void {
const exe = b.addExecutable(.{ .name = "chip8-zig", .root_source_file = .{ .path = "src/main.zig" }, .optimize = optimize, .target = target });
rl.link(b, exe, target, optimize);
exe.addModule("raylib", raylib);
exe.addModule("raylib-math", raylib_math);
exe.addModule("raylib", rl.getModule(b, "libs/raylib-zig"));
exe.addModule("raylib-math", rl.math.getModule(b, "libs/raylib-zig"));
const run_cmd = b.addRunArtifact(exe);
const run_step = b.step("run", "Run chip8-zig");

View File

@ -1,9 +1,11 @@
const rl = @import("raylib");
const std = @import("std");
const assert = @import("std").debug.assert;
const ChipContext = @import("chip.zig");
const RaylibChip = @import("raylib-chip.zig");
const assert = std.debug.assert;
pub fn gen_sin_wave(wave: *rl.Wave, frequency: f32) void {
assert(wave.sampleSize == 16); // Only 16 bits are supported
@ -24,7 +26,7 @@ fn megabytes(amount: usize) usize {
}
pub fn main() anyerror!void {
var program_memory = try std.heap.page_allocator.alloc(u8, megabytes(1));
var program_memory = try std.heap.page_allocator.alloc(u8, megabytes(2));
var fba = std.heap.FixedBufferAllocator.init(program_memory);
const allocator = fba.allocator();