Skip to content

Commit

Permalink
Make Kong work on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Oct 6, 2023
1 parent 780025b commit f344345
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

{
Expand Down Expand Up @@ -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);
}
9 changes: 9 additions & 0 deletions Backends/System/macOS/Sources/kinc/backend/system.m.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit f344345

Please sign in to comment.