add raylib-zig as a proper submodule
This commit is contained in:
parent
ac6c1e2064
commit
df4dadc29d
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "libs/raylib-zig"]
|
||||||
|
path = libs/raylib-zig
|
||||||
|
url = git@github.com:Not-Nik/raylib-zig.git
|
@ -1,11 +1,9 @@
|
|||||||
const std = @import("std");
|
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 {
|
pub fn build(b: *std.Build) !void {
|
||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
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
|
// TODO: Figure out how to build project for WASM. Tried to do it but standard memory allocators
|
||||||
// didn't work.
|
// 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 });
|
const exe = b.addExecutable(.{ .name = "chip8-zig", .root_source_file = .{ .path = "src/main.zig" }, .optimize = optimize, .target = target });
|
||||||
|
|
||||||
rl.link(b, exe, target, optimize);
|
rl.link(b, exe, target, optimize);
|
||||||
exe.addModule("raylib", raylib);
|
exe.addModule("raylib", rl.getModule(b, "libs/raylib-zig"));
|
||||||
exe.addModule("raylib-math", raylib_math);
|
exe.addModule("raylib-math", rl.math.getModule(b, "libs/raylib-zig"));
|
||||||
|
|
||||||
const run_cmd = b.addRunArtifact(exe);
|
const run_cmd = b.addRunArtifact(exe);
|
||||||
const run_step = b.step("run", "Run chip8-zig");
|
const run_step = b.step("run", "Run chip8-zig");
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
const rl = @import("raylib");
|
const rl = @import("raylib");
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const assert = @import("std").debug.assert;
|
|
||||||
const ChipContext = @import("chip.zig");
|
const ChipContext = @import("chip.zig");
|
||||||
const RaylibChip = @import("raylib-chip.zig");
|
const RaylibChip = @import("raylib-chip.zig");
|
||||||
|
|
||||||
|
const assert = std.debug.assert;
|
||||||
|
|
||||||
pub fn gen_sin_wave(wave: *rl.Wave, frequency: f32) void {
|
pub fn gen_sin_wave(wave: *rl.Wave, frequency: f32) void {
|
||||||
assert(wave.sampleSize == 16); // Only 16 bits are supported
|
assert(wave.sampleSize == 16); // Only 16 bits are supported
|
||||||
|
|
||||||
@ -24,7 +26,7 @@ fn megabytes(amount: usize) usize {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn main() anyerror!void {
|
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);
|
var fba = std.heap.FixedBufferAllocator.init(program_memory);
|
||||||
const allocator = fba.allocator();
|
const allocator = fba.allocator();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user