C instance creation

This commit is contained in:
Greg Wells
2025-05-20 22:35:51 -04:00
parent a4166ae5c2
commit fa58a2f2d6
12 changed files with 150 additions and 112 deletions

View File

@@ -1,4 +1,5 @@
set(CMAKE_EXPORT_COMPILE_COMMANDS on)
set(CMAKE_CXX_STANDARD 17)
project(GryphnMetalImpl)
file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS

View File

@@ -0,0 +1,19 @@
#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

@@ -0,0 +1,10 @@
#pragma once
#include <Metal/Metal.hpp>
#include <AppKit/AppKit.hpp>
struct GLFWwindow;
struct gnPlatformInstance {
NS::View* metalContentView;
MTL::RenderPipelineState* framebufferRenderer, *testSquareRenderer;
};

View File

@@ -1,3 +1,4 @@
#include "utils/gryphn_bool.h"
#include <core/gryphn_support.h>
GN_EXPORT gnBool gnAPISupportsFn(gnFeature feature) {