rename to projects (DOES NOT COMPILE)
This commit is contained in:
23
projects/platform/gryphn_platform_include.h
Normal file
23
projects/platform/gryphn_platform_include.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "gryphn_rendering_api.h"
|
||||
|
||||
#ifdef GN_PLATFORM_LINUX
|
||||
#include <platform/platform_linux/gryphn_platform_linux.h>
|
||||
#endif
|
||||
|
||||
#ifdef GN_PLATFORM_MACOS
|
||||
#include <platform/platform_macos/gryphn_platform_macos.h>
|
||||
#endif
|
||||
|
||||
#ifdef GN_PLATFORM_WINDOWS
|
||||
#include "platform_windows/gryphn_platform_windows.h"
|
||||
#endif
|
||||
|
||||
gnRenderingAPI* gnGetSupportedRenderingAPIs(int* count);
|
||||
|
||||
// #ifdef __cplusplus
|
||||
// template <typename function>
|
||||
// void gnPlatformLoadDLLFunction(void *dll, function& func, gnString name) {
|
||||
// func = (function)gnLoadFunctionPtr(dll, name);
|
||||
// }
|
||||
// #endif
|
32
projects/platform/platform_linux/gryphn_platform_linux.c
Normal file
32
projects/platform/platform_linux/gryphn_platform_linux.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifdef GN_PLATFORM_LINUX
|
||||
#include "gryphn_platform_linux.h"
|
||||
#include "core/gryphn_rendering_api.h"
|
||||
#include "core/instance/init/gryphn_dynamic_library.h"
|
||||
#include "dlfcn.h"
|
||||
|
||||
gnRenderingAPI renderingAPIs[2] = {
|
||||
GN_RENDERINGAPI_VULKAN,
|
||||
GN_RENDERINGAPI_SOFTWARE
|
||||
};
|
||||
|
||||
gnRenderingAPI* gnGetSupportedRenderingAPIs(int* count) {
|
||||
*count = 2;
|
||||
return renderingAPIs;
|
||||
}
|
||||
|
||||
struct gnDynamicLibrary_t* gnLoadDynamicLibrary(const gnString path) {
|
||||
struct gnDynamicLibrary_t* dll = malloc(sizeof(struct gnDynamicLibrary_t));
|
||||
dll->dllPtr = dlopen(gnToCString(gnCombineStrings(path, ".so")), RTLD_LAZY),
|
||||
dll->isValid = gnTrue;
|
||||
if (dll->dllPtr == NULL) dll->isValid = gnFalse;
|
||||
return dll;
|
||||
}
|
||||
void* gnLoadFunctionPtr(struct gnDynamicLibrary_t* dll, const char* name) {
|
||||
if (dll->isValid == gnFalse) return NULL;
|
||||
return dlsym(dll->dllPtr, name);
|
||||
}
|
||||
void gnUnloadDynamicLibrary(struct gnDynamicLibrary_t* dll) {
|
||||
if (dll->isValid) dlclose(dll->dllPtr);
|
||||
}
|
||||
|
||||
#endif
|
8
projects/platform/platform_linux/gryphn_platform_linux.h
Normal file
8
projects/platform/platform_linux/gryphn_platform_linux.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
#include <X11/Xlib.h>
|
||||
// #ifdef GN_WINDOW_X11
|
||||
// #endif
|
||||
|
||||
// #ifdef GN_WINDOW_WAYLAND
|
||||
// #include <wayland-client.h>
|
||||
// #endif
|
24
projects/platform/platform_macos/gryphn_platform_macos.h
Normal file
24
projects/platform/platform_macos/gryphn_platform_macos.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include <utils/gryphn_string.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#ifdef __OBJC__
|
||||
@class NSWindow;
|
||||
@class CAMetalLayer;
|
||||
@class MTKView;
|
||||
#else
|
||||
typedef void NSWindow;
|
||||
typedef void CAMetalLayer;
|
||||
typedef void MTKView;
|
||||
#endif
|
||||
|
||||
// MTKView* gnCreateMTKView(NSWindow* window);
|
||||
// void gnWindowSetMTKView(NSWindow* window, MTKView* view);
|
||||
CAMetalLayer* gnCreateCAMetalLayer(NSWindow* window);
|
||||
CAMetalLayer* gnGetCAMetalLayer(NSWindow* window);
|
||||
void gnAttachMetalLayer(NSWindow* window, CAMetalLayer* layer);
|
||||
|
||||
// CAMetalLayer* gnCreateMetalLayer(NSWindow* window);
|
||||
// void gnAttachMetalLayer(NSWindow* window, CAMetalLayer* layer);
|
||||
// void gnMetalLayerSetBounds(CAMetalLayer* layer, NSWindow* window);
|
||||
// CAMetalLayer* gnGetMetalLayer(NSWindow* window);
|
113
projects/platform/platform_macos/gryphn_platform_macos.m
Normal file
113
projects/platform/platform_macos/gryphn_platform_macos.m
Normal file
@@ -0,0 +1,113 @@
|
||||
#ifdef GN_PLATFORM_MACOS
|
||||
#undef GN_UTILS_CPP
|
||||
#include "core/gryphn_rendering_api.h"
|
||||
#include "core/instance/init/gryphn_dynamic_library.h"
|
||||
#include "dlfcn.h"
|
||||
#include "gryphn_platform_macos.h"
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <MetalKit/MetalKit.h>
|
||||
|
||||
gnRenderingAPI renderingAPIs[3] = {
|
||||
GN_RENDERINGAPI_METAL,
|
||||
GN_RENDERINGAPI_VULKAN,
|
||||
GN_RENDERINGAPI_SOFTWARE
|
||||
};
|
||||
|
||||
gnRenderingAPI* gnGetSupportedRenderingAPIs(int* count) {
|
||||
*count = 3;
|
||||
return renderingAPIs;
|
||||
}
|
||||
|
||||
struct gnDynamicLibrary_t* gnLoadDynamicLibrary(const gnString path) {
|
||||
struct gnDynamicLibrary_t* dll = malloc(sizeof(struct gnDynamicLibrary_t));
|
||||
dll->dllPtr = dlopen(gnToCString(gnCombineStrings(path, ".dylib")), RTLD_LAZY),
|
||||
dll->isValid = true;
|
||||
if (dll->dllPtr == NULL) dll->isValid = false;
|
||||
return dll;
|
||||
}
|
||||
void* gnLoadFunctionPtr(struct gnDynamicLibrary_t* dll, const char* name) {
|
||||
if (dll->isValid == false) return NULL;
|
||||
return dlsym(dll->dllPtr, name);
|
||||
}
|
||||
void gnUnloadDynamicLibrary(struct gnDynamicLibrary_t* dll) {
|
||||
if (dll->isValid) dlclose(dll->dllPtr);
|
||||
}
|
||||
|
||||
MTKView* gnCreateMTKView(NSWindow* window) {
|
||||
MTKView* view = [[MTKView alloc] initWithFrame:window.frame];
|
||||
[view setColorPixelFormat:MTLPixelFormatBGRA8Unorm_sRGB];
|
||||
[view setPreferredFramesPerSecond:120];
|
||||
CGSize rect = { window.frame.size.width * window.backingScaleFactor, window.frame.size.height * window.backingScaleFactor };
|
||||
[view setClearColor:MTLClearColorMake(1.0f, 0.0f, 0.0f, 1.0f)];
|
||||
[view setDrawableSize:rect];
|
||||
return view;
|
||||
}
|
||||
|
||||
void gnWindowSetMTKView(NSWindow* window, MTKView* view) {
|
||||
[window setContentView:view];
|
||||
}
|
||||
|
||||
CAMetalLayer* gnCreateCAMetalLayer(NSWindow* window) {
|
||||
NSView* view = window.contentView;
|
||||
CAMetalLayer* layer = [CAMetalLayer layer];
|
||||
[layer setContentsScale:[window backingScaleFactor]];
|
||||
[layer setFramebufferOnly:YES];
|
||||
[view setLayer:layer];
|
||||
[view setWantsLayer:YES];
|
||||
return layer;
|
||||
}
|
||||
|
||||
CAMetalLayer* gnGetCAMetalLayer(NSWindow* window) {
|
||||
return (CAMetalLayer*)window.contentView.layer;
|
||||
}
|
||||
|
||||
void gnAttachMetalLayer(NSWindow* window, CAMetalLayer* layer) {
|
||||
// CGSize newSize = window.contentView.bounds.size;
|
||||
// CGFloat scale = window.contentView.window.backingScaleFactor;
|
||||
// layer.drawableSize = CGSizeMake(newSize.width * scale, newSize.height * scale);
|
||||
// CAMetalLayer* layer = [CAMetalLayer layer];
|
||||
// layer.pixelFormat = MTLPixelFormatBGRA8Unorm;
|
||||
// layer.frame = window.contentView.layer.bounds;
|
||||
// window.contentView.wantsLayer = YES;
|
||||
// window.contentView.layer = layer;
|
||||
layer.drawableSize = CGSizeMake(window.frame.size.width, window.frame.size.height);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
CAMetalLayer* gnCreateMetalLayer(NSWindow* window) {
|
||||
// CAMetalLayer* layer = [CAMetalLayer layer];
|
||||
// [window.contentView setWantsLayer:YES];
|
||||
// [layer setContentsScale:[window backingScaleFactor]];
|
||||
// [layer setFrame:window.contentView.bounds];
|
||||
// [window.contentView setLayer:layer];
|
||||
// return layer;
|
||||
|
||||
CAMetalLayer* layer = [CAMetalLayer layer];
|
||||
|
||||
// if (window.scaleFramebuffer)
|
||||
// [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
|
||||
|
||||
[window.contentView layer];
|
||||
[window.contentView setWantsLayer:YES];
|
||||
return layer;
|
||||
}
|
||||
|
||||
void gnAttachMetalLayer(NSWindow* window, CAMetalLayer* layer) {
|
||||
// [window.contentView setWantsLayer:YES];
|
||||
// // [window.contentView setLayer:layer];
|
||||
// [layer setFrame:window.contentView.bounds];
|
||||
// [layer setContentsScale:[window backingScaleFactor]];
|
||||
}
|
||||
|
||||
void gnMetalLayerSetBounds(CAMetalLayer* layer, NSWindow* window) {
|
||||
// CGSize size = window.contentView.bounds.size;
|
||||
// CGFloat scale = window.backingScaleFactor;
|
||||
|
||||
// [layer setFrame:window.contentView.bounds];
|
||||
// [layer setDrawableSize:CGSizeMake(size.width * scale, size.height * scale)];
|
||||
// [layer setContentsScale:[window backingScaleFactor]];
|
||||
}
|
||||
*/
|
||||
#endif
|
@@ -0,0 +1,4 @@
|
||||
#ifdef GN_PLATFORM_WINDOWS
|
||||
#include "windows.h"
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user