got bored wrote some objectice C

This commit is contained in:
Greg Wells
2025-05-24 15:19:45 -04:00
parent e955775ba0
commit 12223b0bf3
3 changed files with 18 additions and 25 deletions

View File

@@ -1,19 +0,0 @@
#include <gryphn/gryphn.h>
#include <gryphn/gryphn_utils.h>
// #include "bridge/metal_bridge.h"
#include "metal_instance.h"
GN_EXPORT gnReturnCode gnCreateInstanceFn(gnInstance* instance) {
if (instance->instance == nullptr) instance->instance = new gnPlatformInstance();
return GN_SUCCESS;
}
GN_EXPORT void gnDestroyInstanceFn(gnInstance& instance) {
}
GN_EXPORT gnReturnCode gnCreateMacOSWindowSurfaceFn(gnInstance& instance, NS::Window* window, NS::View* view) {
if (instance.instance == nullptr) instance.instance = new gnPlatformInstance();
instance.instance->metalContentView = view;
return GN_SUCCESS;
}

View File

@@ -1,10 +1,8 @@
#pragma once
#include <Metal/Metal.hpp>
#include <AppKit/AppKit.hpp>
struct GLFWwindow;
#include <Metal/MTLRenderPipeline.h>
#include <AppKit/AppKit.h>
typedef struct gnPlatformInstance_t {
NS::View* metalContentView;
MTL::RenderPipelineState* framebufferRenderer, *testSquareRenderer;
NSView* metalContentView;
id<MTLRenderPipelineState> framebufferRenderer;
} gnPlatformInstance;

View File

@@ -0,0 +1,14 @@
#include <gryphn/gryphn.h>
#include <gryphn/gryphn_utils.h>
#include "metal_instance.h"
// #include "bridge/metal_bridge.h"
gnReturnCode gnCreateInstanceFn(gnInstance* instance, gnInstanceInfo instanceInfo) {
if (instance->instance == NULL) instance->instance = malloc(sizeof(gnPlatformInstance));
return GN_SUCCESS;
}
void gnDestroyInstanceFn(gnInstance* instance) {
free(instance->instance);
}