core: remove verbose comments
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
09d39fb694
commit
1c0434a948
3 changed files with 10 additions and 33 deletions
11
src/Core.zig
11
src/Core.zig
|
|
@ -5,6 +5,8 @@ const build_options = @import("build-options");
|
||||||
const mach = @import("main.zig");
|
const mach = @import("main.zig");
|
||||||
const gpu = mach.gpu;
|
const gpu = mach.gpu;
|
||||||
const log = std.log.scoped(.mach);
|
const log = std.log.scoped(.mach);
|
||||||
|
|
||||||
|
// TODO: move to Linux.zig
|
||||||
const gamemode_log = std.log.scoped(.gamemode);
|
const gamemode_log = std.log.scoped(.gamemode);
|
||||||
|
|
||||||
const Platform = switch (build_options.core_platform) {
|
const Platform = switch (build_options.core_platform) {
|
||||||
|
|
@ -134,9 +136,11 @@ state: enum {
|
||||||
deinitializing,
|
deinitializing,
|
||||||
exited,
|
exited,
|
||||||
} = .running,
|
} = .running,
|
||||||
linux_gamemode: ?bool = null,
|
|
||||||
frame: mach.time.Frequency,
|
frame: mach.time.Frequency,
|
||||||
|
|
||||||
|
// TODO: move to Linux.zig
|
||||||
|
linux_gamemode: ?bool = null,
|
||||||
|
|
||||||
// Might be accessed by Platform backend
|
// Might be accessed by Platform backend
|
||||||
input: mach.time.Frequency,
|
input: mach.time.Frequency,
|
||||||
swap_chain_update: std.Thread.ResetEvent = .{},
|
swap_chain_update: std.Thread.ResetEvent = .{},
|
||||||
|
|
@ -291,6 +295,7 @@ fn init(core: *Mod, entities: *mach.Entities.Mod) !void {
|
||||||
try core.set(state.main_window, .width, state.platform.size.width);
|
try core.set(state.main_window, .width, state.platform.size.width);
|
||||||
try core.set(state.main_window, .height, state.platform.size.height);
|
try core.set(state.main_window, .height, state.platform.size.height);
|
||||||
|
|
||||||
|
// TODO: move to Linux.zig
|
||||||
if (builtin.os.tag == .linux and !options.is_app and
|
if (builtin.os.tag == .linux and !options.is_app and
|
||||||
state.linux_gamemode == null and try wantGamemode(options.allocator))
|
state.linux_gamemode == null and try wantGamemode(options.allocator))
|
||||||
state.linux_gamemode = initLinuxGamemode();
|
state.linux_gamemode = initLinuxGamemode();
|
||||||
|
|
@ -374,6 +379,7 @@ pub fn deinit(entities: *mach.Entities.Mod, core: *Mod) !void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: move to Linux.zig
|
||||||
if (builtin.os.tag == .linux and
|
if (builtin.os.tag == .linux and
|
||||||
state.linux_gamemode != null and
|
state.linux_gamemode != null and
|
||||||
state.linux_gamemode.?)
|
state.linux_gamemode.?)
|
||||||
|
|
@ -1009,6 +1015,7 @@ pub inline fn printUnhandledErrorCallback(_: void, ty: gpu.ErrorType, message: [
|
||||||
std.process.exit(1);
|
std.process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: move to Linux.zig
|
||||||
/// Check if gamemode should be activated
|
/// Check if gamemode should be activated
|
||||||
pub fn wantGamemode(allocator: std.mem.Allocator) error{ OutOfMemory, InvalidWtf8 }!bool {
|
pub fn wantGamemode(allocator: std.mem.Allocator) error{ OutOfMemory, InvalidWtf8 }!bool {
|
||||||
const use_gamemode = std.process.getEnvVarOwned(
|
const use_gamemode = std.process.getEnvVarOwned(
|
||||||
|
|
@ -1023,6 +1030,7 @@ pub fn wantGamemode(allocator: std.mem.Allocator) error{ OutOfMemory, InvalidWtf
|
||||||
return !(std.ascii.eqlIgnoreCase(use_gamemode, "off") or std.ascii.eqlIgnoreCase(use_gamemode, "false"));
|
return !(std.ascii.eqlIgnoreCase(use_gamemode, "off") or std.ascii.eqlIgnoreCase(use_gamemode, "false"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: move to Linux.zig
|
||||||
pub fn initLinuxGamemode() bool {
|
pub fn initLinuxGamemode() bool {
|
||||||
mach.gamemode.start();
|
mach.gamemode.start();
|
||||||
if (!mach.gamemode.isActive()) return false;
|
if (!mach.gamemode.isActive()) return false;
|
||||||
|
|
@ -1030,6 +1038,7 @@ pub fn initLinuxGamemode() bool {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: move to Linux.zig
|
||||||
pub fn deinitLinuxGamemode() void {
|
pub fn deinitLinuxGamemode() void {
|
||||||
mach.gamemode.stop();
|
mach.gamemode.stop();
|
||||||
gamemode_log.info("gamemode: deactivated", .{});
|
gamemode_log.info("gamemode: deactivated", .{});
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ pub fn run(comptime on_each_update_fn: anytype, args_tuple: std.meta.ArgsTuple(@
|
||||||
// TODO: support UIKit.
|
// TODO: support UIKit.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called on the main thread
|
|
||||||
pub fn init(
|
pub fn init(
|
||||||
darwin: *Darwin,
|
darwin: *Darwin,
|
||||||
core: *Core.Mod,
|
core: *Core.Mod,
|
||||||
|
|
@ -130,77 +129,62 @@ pub fn deinit(darwin: *Darwin) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called on the main thread
|
|
||||||
pub fn update(_: *Darwin) !void {
|
pub fn update(_: *Darwin) !void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setTitle(_: *Darwin, _: [:0]const u8) void {
|
pub fn setTitle(_: *Darwin, _: [:0]const u8) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setDisplayMode(_: *Darwin, _: DisplayMode) void {
|
pub fn setDisplayMode(_: *Darwin, _: DisplayMode) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setBorder(_: *Darwin, _: bool) void {
|
pub fn setBorder(_: *Darwin, _: bool) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setHeadless(_: *Darwin, _: bool) void {
|
pub fn setHeadless(_: *Darwin, _: bool) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setVSync(_: *Darwin, _: VSyncMode) void {
|
pub fn setVSync(_: *Darwin, _: VSyncMode) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setSize(_: *Darwin, _: Size) void {
|
pub fn setSize(_: *Darwin, _: Size) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn size(_: *Darwin) Size {
|
pub fn size(_: *Darwin) Size {
|
||||||
return Size{ .width = 100, .height = 100 };
|
return Size{ .width = 100, .height = 100 };
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setCursorMode(_: *Darwin, _: CursorMode) void {
|
pub fn setCursorMode(_: *Darwin, _: CursorMode) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setCursorShape(_: *Darwin, _: CursorShape) void {
|
pub fn setCursorShape(_: *Darwin, _: CursorShape) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn keyPressed(_: *Darwin, _: Key) bool {
|
pub fn keyPressed(_: *Darwin, _: Key) bool {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn keyReleased(_: *Darwin, _: Key) bool {
|
pub fn keyReleased(_: *Darwin, _: Key) bool {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn mousePressed(_: *Darwin, _: MouseButton) bool {
|
pub fn mousePressed(_: *Darwin, _: MouseButton) bool {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn mouseReleased(_: *Darwin, _: MouseButton) bool {
|
pub fn mouseReleased(_: *Darwin, _: MouseButton) bool {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn mousePosition(_: *Darwin) Position {
|
pub fn mousePosition(_: *Darwin) Position {
|
||||||
return Position{ .x = 0, .y = 0 };
|
return Position{ .x = 0, .y = 0 };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ refresh_rate: u32,
|
||||||
size: Size,
|
size: Size,
|
||||||
surface_descriptor: gpu.Surface.Descriptor,
|
surface_descriptor: gpu.Surface.Descriptor,
|
||||||
|
|
||||||
// Called on the main thread
|
|
||||||
pub fn init(
|
pub fn init(
|
||||||
nul: *Null,
|
nul: *Null,
|
||||||
core: *Core.Mod,
|
core: *Core.Mod,
|
||||||
|
|
@ -54,77 +53,62 @@ pub fn deinit(_: *Null) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called on the main thread
|
|
||||||
pub fn update(_: *Null) !void {
|
pub fn update(_: *Null) !void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setTitle(_: *Null, _: [:0]const u8) void {
|
pub fn setTitle(_: *Null, _: [:0]const u8) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setDisplayMode(_: *Null, _: DisplayMode) void {
|
pub fn setDisplayMode(_: *Null, _: DisplayMode) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setBorder(_: *Null, _: bool) void {
|
pub fn setBorder(_: *Null, _: bool) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setHeadless(_: *Null, _: bool) void {
|
pub fn setHeadless(_: *Null, _: bool) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setVSync(_: *Null, _: VSyncMode) void {
|
pub fn setVSync(_: *Null, _: VSyncMode) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setSize(_: *Null, _: Size) void {
|
pub fn setSize(_: *Null, _: Size) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn size(_: *Null) Size {
|
pub fn size(_: *Null) Size {
|
||||||
return Size{ .width = 100, .height = 100 };
|
return Size{ .width = 100, .height = 100 };
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setCursorMode(_: *Null, _: CursorMode) void {
|
pub fn setCursorMode(_: *Null, _: CursorMode) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn setCursorShape(_: *Null, _: CursorShape) void {
|
pub fn setCursorShape(_: *Null, _: CursorShape) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn keyPressed(_: *Null, _: Key) bool {
|
pub fn keyPressed(_: *Null, _: Key) bool {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn keyReleased(_: *Null, _: Key) bool {
|
pub fn keyReleased(_: *Null, _: Key) bool {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn mousePressed(_: *Null, _: MouseButton) bool {
|
pub fn mousePressed(_: *Null, _: MouseButton) bool {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn mouseReleased(_: *Null, _: MouseButton) bool {
|
pub fn mouseReleased(_: *Null, _: MouseButton) bool {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// May be called from any thread.
|
|
||||||
pub fn mousePosition(_: *Null) Position {
|
pub fn mousePosition(_: *Null) Position {
|
||||||
return Position{ .x = 0, .y = 0 };
|
return Position{ .x = 0, .y = 0 };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue