From 0319db3e53f677ed21533f41e9dfc5c351a64c9d Mon Sep 17 00:00:00 2001 From: contribuewwt <38278035+undefinedDarkness@users.noreply.github.com> Date: Sun, 25 Jun 2023 14:48:26 +0530 Subject: [PATCH] core: add is_headless to specify hidden window before init (#816) Co-authored-by: Stephen Gutekanst --- libs/core/src/Core.zig | 1 + libs/core/src/platform/native/Core.zig | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/libs/core/src/Core.zig b/libs/core/src/Core.zig index 1dcc4333..df749c04 100644 --- a/libs/core/src/Core.zig +++ b/libs/core/src/Core.zig @@ -9,6 +9,7 @@ internal: platform.Core, pub const Options = struct { is_app: bool = false, + is_headless: bool = false, title: [*:0]const u8 = "Mach Engine", size: Size = .{ .width = 1920 / 2, .height = 1080 / 2 }, power_preference: gpu.PowerPreference = .undefined, diff --git a/libs/core/src/platform/native/Core.zig b/libs/core/src/platform/native/Core.zig index 93186aae..87222a09 100644 --- a/libs/core/src/platform/native/Core.zig +++ b/libs/core/src/platform/native/Core.zig @@ -87,6 +87,10 @@ pub fn init(core: *Core, allocator: std.mem.Allocator, options: Options) !void { // Create the test window and discover adapters using it (esp. for OpenGL) var hints = util.glfwWindowHintsForBackend(backend_type); hints.cocoa_retina_framebuffer = true; + if (options.is_headless) { + hints.visible = false; // Hiding window before creation otherwise you get the window showing up for a little bit then hiding. + } + const window = glfw.Window.create( options.size.width, options.size.height,