Skip to content

Commit

Permalink
Fixing core to work with win32 #1257
Browse files Browse the repository at this point in the history
  • Loading branch information
hordurj committed Aug 25, 2024
1 parent 17450fd commit 951d45d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/core/custom-entrypoint/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn main() !void {
// possible on all platforms.
if (mach.Core.supports_non_blocking) {
mach.Core.non_blocking = true;
while (mach.mods.mod.mach_core.state != .exited) {
while (mach.mods.mod.mach_core.state().state != .exited) {
// Execute systems until a frame has been finished.
try mach.mods.dispatchUntil(stack_space, .mach_core, .frame_finished);
}
Expand Down
8 changes: 6 additions & 2 deletions src/Core.zig
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ pub fn start(core: *Mod) !void {
const stack_space = try core.state().allocator.alloc(u8, 8 * 1024 * 1024);

if (supports_non_blocking) {
while (mach.mods.mod.mach_core.state != .exited) {
try mach.mods.dispatchUntil(stack_space, .mach_core, .frame_finished);
while (core.state().state != .exited) {
dispatch(stack_space);
}
// Don't return, because Platform.run wouldn't either (marked noreturn due to underlying
// platform APIs never returning.)
Expand All @@ -348,6 +348,10 @@ pub fn start(core: *Mod) !void {
}
}

fn dispatch(stack_space: []u8) void {
mach.mods.dispatchUntil(stack_space, .mach_core, .frame_finished) catch { @panic("Dispatch in Core failed"); };
}

fn platform_update_callback(core: *Mod, stack_space: []u8) !bool {
// Execute systems until .mach_core.frame_finished is dispatched, signalling a frame was
// finished.
Expand Down
1 change: 1 addition & 0 deletions src/core/win32.zig
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ pub fn init(
self.border = options.border;
self.headless = options.headless;
self.refresh_rate = 60; // TODO (win32) get monitor refresh rate
self.vsync_mode = .triple;

_ = w.SetWindowLongPtrW(window, w.GWLP_USERDATA, @bitCast(@intFromPtr(self)));
if (!options.headless) {
Expand Down

0 comments on commit 951d45d

Please sign in to comment.