From f3443459adc25ec4d46a00ba6a582a24fea9c9a3 Mon Sep 17 00:00:00 2001 From: Robert Konrad Date: Fri, 6 Oct 2023 12:14:28 +0200 Subject: [PATCH] Make Kong work on macOS --- .../Metal/Sources/kinc/backend/graphics5/shader.m.h | 6 ++++++ Backends/System/macOS/Sources/kinc/backend/system.m.h | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/Backends/Graphics5/Metal/Sources/kinc/backend/graphics5/shader.m.h b/Backends/Graphics5/Metal/Sources/kinc/backend/graphics5/shader.m.h index 97106f8a2..a495855b0 100644 --- a/Backends/Graphics5/Metal/Sources/kinc/backend/graphics5/shader.m.h +++ b/Backends/Graphics5/Metal/Sources/kinc/backend/graphics5/shader.m.h @@ -15,6 +15,11 @@ void kinc_g5_shader_destroy(kinc_g5_shader_t *shader) { } void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *source, size_t length, kinc_g5_shader_type_t type) { +#ifdef KINC_KONG + strcpy(shader->impl.name, (const char *)source); + shader->impl.mtlFunction = (__bridge_retained void *)[getMetalLibrary() newFunctionWithName:[NSString stringWithCString:shader->impl.name + encoding:NSUTF8StringEncoding]]; +#else shader->impl.name[0] = 0; { @@ -51,5 +56,6 @@ void kinc_g5_shader_init(kinc_g5_shader_t *shader, const void *source, size_t le } shader->impl.mtlFunction = (__bridge_retained void *)[library newFunctionWithName:[NSString stringWithCString:shader->impl.name encoding:NSUTF8StringEncoding]]; +#endif assert(shader->impl.mtlFunction); } diff --git a/Backends/System/macOS/Sources/kinc/backend/system.m.h b/Backends/System/macOS/Sources/kinc/backend/system.m.h index 5dd6dce14..783169ed2 100644 --- a/Backends/System/macOS/Sources/kinc/backend/system.m.h +++ b/Backends/System/macOS/Sources/kinc/backend/system.m.h @@ -174,6 +174,10 @@ static void addMenubar(void) { [NSApp setMainMenu:menubar]; } +#ifdef KINC_KONG +void kong_init(void); +#endif + int kinc_init(const char *name, int width, int height, kinc_window_options_t *win, kinc_framebuffer_options_t *frame) { @autoreleasepool { myapp = [KincApplication sharedApplication]; @@ -208,6 +212,11 @@ int kinc_init(const char *name, int width, int height, kinc_window_options_t *wi int windowId = createWindow(win); kinc_g4_internal_init(); kinc_g4_internal_init_window(windowId, frame->depth_bits, frame->stencil_bits, true); + +#ifdef KINC_KONG + kong_init(); +#endif + return 0; }