gryphn window surfaces
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#include <core/instance/gryphn_instance.h>
|
#include <core/instance/gryphn_instance.h>
|
||||||
#include <core/debugger/gryphn_debugger.h>
|
#include <core/debugger/gryphn_debugger.h>
|
||||||
#include <core/output_device/gryphn_physical_output_device.h>
|
#include <core/output_device/gryphn_physical_output_device.h>
|
||||||
|
#include <core/window_surface/gryphn_surface.h>
|
||||||
|
|
||||||
// #pragma once
|
// #pragma once
|
||||||
|
|
||||||
|
@@ -101,6 +101,5 @@ GN_EXPORT gnReturnCode gnCreateInstanceFn(gnInstance* instance, gnInstanceInfo i
|
|||||||
|
|
||||||
GN_EXPORT void gnDestroyInstanceFn(gnInstance& instance) {
|
GN_EXPORT void gnDestroyInstanceFn(gnInstance& instance) {
|
||||||
instance.valid = false;
|
instance.valid = false;
|
||||||
vkDestroySurfaceKHR(instance.instance->vk_instance, instance.instance->window_surface, nullptr);
|
|
||||||
vkDestroyInstance(instance.instance->vk_instance, nullptr);
|
vkDestroyInstance(instance.instance->vk_instance, nullptr);
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#ifdef GN_PLATFORM_MACOS
|
|
||||||
#include <instance/vulkan_macos_bridge.h>
|
|
||||||
#endif
|
|
||||||
#include "vector"
|
#include "vector"
|
||||||
#include "core/debugger/gryphn_debugger.h"
|
#include "core/debugger/gryphn_debugger.h"
|
||||||
|
|
||||||
@@ -15,7 +12,7 @@ struct gnInstanceMessage {
|
|||||||
struct gnPlatformInstance {
|
struct gnPlatformInstance {
|
||||||
VkInstance vk_instance;
|
VkInstance vk_instance;
|
||||||
VkApplicationInfo appInfo;
|
VkApplicationInfo appInfo;
|
||||||
VkSurfaceKHR window_surface;
|
// VkSurfaceKHR window_surface;
|
||||||
|
|
||||||
std::vector<const char*> extensions;
|
std::vector<const char*> extensions;
|
||||||
std::vector<gnInstanceMessage> instanceMessages;
|
std::vector<gnInstanceMessage> instanceMessages;
|
||||||
|
@@ -1,2 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
void* macosBridge(void* window, void* view);
|
|
@@ -1,18 +0,0 @@
|
|||||||
#include "vulkan_macos_bridge.h"
|
|
||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
#import <QuartzCore/CAMetalLayer.h>
|
|
||||||
#import <QuartzCore/QuartzCore.h>
|
|
||||||
#import <Metal/Metal.h>
|
|
||||||
|
|
||||||
// kinda borrowed from cocoa_window.m in GLFW
|
|
||||||
void* macosBridge(void* inputWindow, void* inputView) {
|
|
||||||
NSWindow* window = (__bridge NSWindow*)inputView;
|
|
||||||
NSView* view = (__bridge NSView*)inputView;
|
|
||||||
|
|
||||||
CAMetalLayer* layer = [CAMetalLayer layer];
|
|
||||||
[layer setContentsScale:[window backingScaleFactor]];
|
|
||||||
|
|
||||||
[view setLayer:layer];
|
|
||||||
[view setWantsLayer:YES];
|
|
||||||
return layer;
|
|
||||||
}
|
|
@@ -1,70 +0,0 @@
|
|||||||
// #include "vulkan_instance.h"
|
|
||||||
|
|
||||||
// #ifdef GN_PLATFORM_LINUX
|
|
||||||
// #ifdef GN_WINDOW_X11
|
|
||||||
// #include <vulkan/vulkan_xlib.h>
|
|
||||||
// #include <X11/Xlib.h>
|
|
||||||
|
|
||||||
// GN_EXPORT gnReturnCode gnCreateX11WindowSurfaceFn(gnInstance& instance, Display* display, Window* window) {
|
|
||||||
// VkXlibSurfaceCreateInfoKHR info{};
|
|
||||||
// info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
|
|
||||||
// info.dpy = display;
|
|
||||||
// info.window = window;
|
|
||||||
|
|
||||||
// VkResult result = vkCreateXlibSurfaceKHR(instance.instance->vk_instance, &info, nullptr, &instance.instance->window_surface);
|
|
||||||
// if (result != VK_SUCCESS)
|
|
||||||
// return gnReturnError(GN_FAILED_TO_ATTACH_WINDOW, result);
|
|
||||||
// return GN_SUCCESS;
|
|
||||||
// }
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
// #ifdef GN_WINFDOW_WAYLAND
|
|
||||||
// #include <vulkan/vulkan_wayland.h>
|
|
||||||
// #include <wayland-client.h>
|
|
||||||
// GN_EXPORT gnReturnCode gnCreateWaylandWindowSurfaceFn(gnInstance& instance, wl_display* display, wl_surface* surface) {
|
|
||||||
// VkWaylandSurfaceCreateInfoKHR info{};
|
|
||||||
// info.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
|
|
||||||
// info.display = display;
|
|
||||||
// info.surface = surface;
|
|
||||||
|
|
||||||
// VkSurfaceKHR surface;
|
|
||||||
// VkResult result = vkCreateWaylandSurfaceKHR(instance.instance->vk_instance, &info, nullptr, &instance.instance->window_surface);
|
|
||||||
// if (result != VK_SUCCESS)
|
|
||||||
// return gnReturnError(GN_FAILED_TO_ATTACH_WINDOW, result);
|
|
||||||
// return GN_SUCCESS;
|
|
||||||
// }
|
|
||||||
// #endif
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
// #ifdef GN_PLATFORM_WINDOWS
|
|
||||||
// #include "vulkan/vulkan_win32.h"
|
|
||||||
// GN_EXPORT gnReturnCode gnCreateWindowsWindowSurfaceFn(gnInstance& instance, HWND* window, HINSTANCE* instance) {
|
|
||||||
// VkWin32SurfaceCreateInfoKHR info{};
|
|
||||||
// info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
|
|
||||||
// info.hwnd = window;
|
|
||||||
// info.hinstance = instance;
|
|
||||||
|
|
||||||
// VkSurfaceKHR surface;
|
|
||||||
// VkResult result = vkCreateWin32SurfaceKHR(instance.instance->vk_instance, &info, nullptr, &instance.instance->window_surface);
|
|
||||||
// if (result != VK_SUCCESS)
|
|
||||||
// return gnReturnError(GN_FAILED_TO_ATTACH_WINDOW, result);
|
|
||||||
// return GN_SUCCESS;
|
|
||||||
// }
|
|
||||||
// #endif
|
|
||||||
// #include "vulkan/vulkan_metal.h"
|
|
||||||
|
|
||||||
// #ifdef GN_PLATFORM_MACOS
|
|
||||||
// GN_EXPORT gnReturnCode gnCreateMacOSWindowSurfaceFn(gnInstance& instance, NS::Window* window, NS::View* view) {
|
|
||||||
// VkMetalSurfaceCreateInfoEXT surfaceCreateInfo = {};
|
|
||||||
// surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
|
|
||||||
// surfaceCreateInfo.pNext = nullptr;
|
|
||||||
// surfaceCreateInfo.flags = 0;
|
|
||||||
// surfaceCreateInfo.pLayer = macosBridge(window, view);
|
|
||||||
|
|
||||||
// VkSurfaceKHR surface;
|
|
||||||
// VkResult result = vkCreateMetalSurfaceEXT(instance.instance->vk_instance, &surfaceCreateInfo, nullptr, &instance.instance->window_surface);
|
|
||||||
// if (result != VK_SUCCESS)
|
|
||||||
// return gnReturnError(GN_FAILED_TO_ATTACH_WINDOW, result);
|
|
||||||
// return GN_SUCCESS;
|
|
||||||
// }
|
|
||||||
// #endif
|
|
7
rendering_api/vulkan/src/vulkan_surface/vulkan_surface.h
Normal file
7
rendering_api/vulkan/src/vulkan_surface/vulkan_surface.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <core/window_surface/gryphn_surface.h>
|
||||||
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
|
struct gnPlatformWindowSurface {
|
||||||
|
VkSurfaceKHR surface;
|
||||||
|
};
|
36
rendering_api/vulkan/src/vulkan_surface/vulkan_surface.mm
Normal file
36
rendering_api/vulkan/src/vulkan_surface/vulkan_surface.mm
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#include "vulkan_surface.h"
|
||||||
|
#include "../instance/vulkan_instance.h"
|
||||||
|
#include <AppKit/AppKit.h>
|
||||||
|
#include <vulkan/vulkan_metal.h>
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import <QuartzCore/CAMetalLayer.h>
|
||||||
|
#import <QuartzCore/QuartzCore.h>
|
||||||
|
#import <Metal/Metal.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef GN_PLATFORM_MACOS
|
||||||
|
#include "vulkan/vulkan_metal.h"
|
||||||
|
GN_EXPORT gnReturnCode gnCreateMacOSWindowSurfaceFn(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnMacOSWindowSurfaceInfo_t createInfo) {
|
||||||
|
NSWindow* window = (__bridge NSWindow*)createInfo.window;
|
||||||
|
NSView* view = [window contentView];
|
||||||
|
|
||||||
|
CAMetalLayer* layer = [CAMetalLayer layer];
|
||||||
|
[layer setContentsScale:[window backingScaleFactor]];
|
||||||
|
[layer setFramebufferOnly:YES];
|
||||||
|
|
||||||
|
[view setLayer:layer];
|
||||||
|
[view setWantsLayer:YES];
|
||||||
|
|
||||||
|
windowSurface->windowSurface = new gnPlatformWindowSurface();
|
||||||
|
VkMetalSurfaceCreateInfoEXT surfaceCreateInfo = {};
|
||||||
|
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
|
||||||
|
surfaceCreateInfo.pNext = nullptr;
|
||||||
|
surfaceCreateInfo.flags = 0;
|
||||||
|
surfaceCreateInfo.pLayer = layer;
|
||||||
|
|
||||||
|
VkResult result = vkCreateMetalSurfaceEXT(instance->instance->vk_instance, &surfaceCreateInfo, nullptr, &windowSurface->windowSurface->surface);
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
return GN_FAILED_TO_ATTACH_WINDOW;
|
||||||
|
return GN_SUCCESS;
|
||||||
|
}
|
||||||
|
#endif
|
60
rendering_api/vulkan/src/vulkan_surface/vulkan_surfance.cpp
Normal file
60
rendering_api/vulkan/src/vulkan_surface/vulkan_surfance.cpp
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#include <instance/vulkan_instance.h>
|
||||||
|
#include "vulkan_surface.h"
|
||||||
|
|
||||||
|
#ifdef GN_PLATFORM_LINUX
|
||||||
|
#ifdef GN_WINDOW_X11
|
||||||
|
#include <vulkan/vulkan_xlib.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
GN_EXPORT gnReturnCode gnCreateX11WindowSurfaceFn(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnX11WindowSurfaceInfo_t createInfo) {
|
||||||
|
windowSurface->windowSurface = new gnPlatformWindowSurface();
|
||||||
|
VkXlibSurfaceCreateInfoKHR info{};
|
||||||
|
info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
|
||||||
|
info.dpy = createInfo.display;
|
||||||
|
info.window = createInfo.window;
|
||||||
|
|
||||||
|
VkResult result = vkCreateXlibSurfaceKHR(instance->instance->vk_instance, &info, nullptr, &windowSurface->windowSurface->surface);
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
return GN_FAILED_TO_ATTACH_WINDOW;
|
||||||
|
return GN_SUCCESS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GN_WINFDOW_WAYLAND
|
||||||
|
#include <vulkan/vulkan_wayland.h>
|
||||||
|
#include <wayland-client.h>
|
||||||
|
GN_EXPORT gnReturnCode gnCreateWaylandWindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWaylandWindowSurfaceInfo_t createInfo) {
|
||||||
|
windowSurface->windowSurface = new gnPlatformWindowSurface();
|
||||||
|
VkWaylandSurfaceCreateInfoKHR info{};
|
||||||
|
info.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
|
||||||
|
info.display = createInfo.display;
|
||||||
|
info.surface = createInfo.surface;
|
||||||
|
|
||||||
|
VkResult result = vkCreateWaylandSurfaceKHR(instance->instance->vk_instance, &info, nullptr, &windowSurface->windowSurface->surface);
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
return GN_FAILED_TO_ATTACH_WINDOW;
|
||||||
|
return GN_SUCCESS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GN_PLATFORM_WINDOWS
|
||||||
|
#include "vulkan/vulkan_win32.h"
|
||||||
|
GN_EXPORT gnReturnCode gnCreateWin32WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWin32WindowSurfaceInfo_t createInfo) {
|
||||||
|
windowSurface->windowSurface = new gnPlatformWindowSurface();
|
||||||
|
VkWin32SurfaceCreateInfoKHR info{};
|
||||||
|
info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
|
||||||
|
info.hwnd = createInfo.window;
|
||||||
|
info.hinstance = createInfo.instance;
|
||||||
|
|
||||||
|
VkResult result = vkCreateWin32SurfaceKHR(instance->instance->vk_instance, &info, nullptr, &windowSurface->windowSurface->surface);
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
return GN_FAILED_TO_ATTACH_WINDOW;
|
||||||
|
return GN_SUCCESS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
GN_EXPORT void gnDestroyWindowSurfaceFn(struct gnWindowSurface_t* windowSurface) {
|
||||||
|
vkDestroySurfaceKHR(windowSurface->instance->instance->vk_instance, windowSurface->windowSurface->surface, nullptr);
|
||||||
|
}
|
@@ -5,6 +5,7 @@
|
|||||||
#include "debugger/gryphn_debugger.h"
|
#include "debugger/gryphn_debugger.h"
|
||||||
#include "output_device/gryphn_physical_output_device.h"
|
#include "output_device/gryphn_physical_output_device.h"
|
||||||
#include "output_device/gryphn_output_device.h"
|
#include "output_device/gryphn_output_device.h"
|
||||||
|
#include "window_surface/gryphn_surface.h"
|
||||||
|
|
||||||
typedef struct gnFunctions_t {
|
typedef struct gnFunctions_t {
|
||||||
gnReturnCode (*_gnCreateInstance)(gnInstance* instance, struct gnInstanceInfo_t info);
|
gnReturnCode (*_gnCreateInstance)(gnInstance* instance, struct gnInstanceInfo_t info);
|
||||||
@@ -18,6 +19,26 @@ typedef struct gnFunctions_t {
|
|||||||
|
|
||||||
gnReturnCode (*_gnRegisterOutputDevice)(gnOutputDevice* outputDevice, gnInstance* instance, const gnPhysicalDevice physicalDevice);
|
gnReturnCode (*_gnRegisterOutputDevice)(gnOutputDevice* outputDevice, gnInstance* instance, const gnPhysicalDevice physicalDevice);
|
||||||
void (*_gnDestroyOutputDevice)(gnOutputDevice* device);
|
void (*_gnDestroyOutputDevice)(gnOutputDevice* device);
|
||||||
|
|
||||||
|
#ifdef GN_PLATFORM_LINUX
|
||||||
|
#ifdef GN_WINDOW_X11
|
||||||
|
gnReturnCode (*_gnCreateX11WindowSurface)(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnX11WindowSurfaceInfo_t createInfo);
|
||||||
|
#endif
|
||||||
|
#ifdef GN_WINDOW_WAYLAND
|
||||||
|
gnReturnCode (*_gnCreateWaylandWindowSurface)(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWaylandWindowSurfaceInfo_t createInfo);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef GN_PLATFORM_WIN32
|
||||||
|
gnReturnCode (*_gnCreateWin32WindowSurface)(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWin32WindowSurfaceInfo_t createInfo);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GN_PLATFORM_MACOS
|
||||||
|
gnReturnCode (*_gnCreateMacOSWindowSurface)(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnMacOSWindowSurfaceInfo_t createInfo);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void (*_gnDestroyWindowSurface)(struct gnWindowSurface_t* windowSurface);
|
||||||
} gnFunctions;
|
} gnFunctions;
|
||||||
|
|
||||||
typedef struct gnDeviceFunctions_t {
|
typedef struct gnDeviceFunctions_t {
|
||||||
|
@@ -26,26 +26,3 @@ typedef struct gnInstance_t {
|
|||||||
|
|
||||||
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info);
|
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info);
|
||||||
void gnDestroyInstance(gnInstance* instance);
|
void gnDestroyInstance(gnInstance* instance);
|
||||||
|
|
||||||
// // inline gnReturnCode (*gnInstanceSetWindow)(gnInstance& instance, GLFWwindow* window);
|
|
||||||
|
|
||||||
// #ifdef GN_PLATFORM_LINUX
|
|
||||||
// #ifdef GN_WINDOW_X11
|
|
||||||
// inline gnReturnCode (*gnCreateX11WindowSurface)(gnInstance& instance, Display* display, Window* window);
|
|
||||||
// #endif
|
|
||||||
// #ifdef GN_WINDOW_WAYLAND
|
|
||||||
// inline gnReturnCode (*gnCreateWaylandWindowSurface)(gnInstance& instance, wl_display* display, wl_surface* surface);
|
|
||||||
// #endif
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
|
|
||||||
// #ifdef GN_PLATFORM_WIN32
|
|
||||||
// inline gnReturnCode (*gnCreateWindowsWindowSurface)(gnInstance& instance, HWND* window, HINSTANCE* instance);
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
// #ifdef GN_PLATFORM_MACOS
|
|
||||||
// typedef void* NSWindow;
|
|
||||||
// typedef void* NSView;
|
|
||||||
|
|
||||||
// inline gnReturnCode (*gnCreateMacOSWindowSurface)(gnInstance& instance, NSWindow window, NSView view);
|
|
||||||
// #endif
|
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
#include <platform/gryphn_platform_include.h>
|
#include <platform/gryphn_platform_include.h>
|
||||||
#include "gryphn_dynamic_library.h"
|
#include "gryphn_dynamic_library.h"
|
||||||
// #include <dlfcn.h>
|
// #include <dlfcn.h>
|
||||||
|
#include "stdio.h"
|
||||||
|
|
||||||
gnBool gnIsAPISupported(gnRenderingAPI api) {
|
gnBool gnIsAPISupported(gnRenderingAPI api) {
|
||||||
int renderingAPICount = 0;
|
int renderingAPICount = 0;
|
||||||
@@ -44,6 +45,28 @@ void gnLoadFunctions(struct gnDynamicLibrary_t* lib, struct gnFunctions_t* funct
|
|||||||
gnLoadDLLFunction(lib, functions->_gnDeviceSupportsAPI, "gnDeviceSupportsAPIFn");
|
gnLoadDLLFunction(lib, functions->_gnDeviceSupportsAPI, "gnDeviceSupportsAPIFn");
|
||||||
gnLoadDLLFunction(lib, functions->_gnRegisterOutputDevice, "gnRegisterOutputDeviceFn");
|
gnLoadDLLFunction(lib, functions->_gnRegisterOutputDevice, "gnRegisterOutputDeviceFn");
|
||||||
gnLoadDLLFunction(lib, functions->_gnDestroyOutputDevice, "gnDestroyOutputDeviceFn");
|
gnLoadDLLFunction(lib, functions->_gnDestroyOutputDevice, "gnDestroyOutputDeviceFn");
|
||||||
|
|
||||||
|
#ifdef GN_PLATFORM_LINUX
|
||||||
|
#ifdef GN_WINDOW_X11
|
||||||
|
gnLoadDLLFunction(lib, functions->_gnCreateX11WindowSurface, "gnCreateX11WindowSurfaceFn");
|
||||||
|
#endif
|
||||||
|
#ifdef GN_WINDOW_WAYLAND
|
||||||
|
gnLoadDLLFunction(lib, functions->_gnCreateWaylandWindowSurface, "gnCreateWaylandWindowSurfaceFn");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef GN_PLATFORM_WIN32
|
||||||
|
gnLoadDLLFunction(lib, functions->_gnCreateWin32WindowSurface, "gnCreateWin32WindowSurfaceFn");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GN_PLATFORM_MACOS
|
||||||
|
gnLoadDLLFunction(lib, functions->_gnCreateMacOSWindowSurface, "gnCreateMacOSWindowSurfaceFn");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gnLoadDLLFunction(lib, functions->_gnDestroyWindowSurface, "gnDestroyWindowSurfaceFn");
|
||||||
|
|
||||||
|
printf("_gnDestroyWindowSurface location: %p\n", functions->_gnDestroyWindowSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFunctions_t* functions) {
|
void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFunctions_t* functions) {
|
||||||
|
34
src/core/window_surface/gryphn_surface.c
Normal file
34
src/core/window_surface/gryphn_surface.c
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
|
||||||
|
#include "gryphn_surface.h"
|
||||||
|
#include "core/gryphn_platform_functions.h"
|
||||||
|
|
||||||
|
#ifdef GN_PLATFORM_LINUX
|
||||||
|
#ifdef GN_WINDOW_X11
|
||||||
|
gnReturnCode gnCreateX11WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnX11WindowSurfaceInfo_t createInfo) {
|
||||||
|
return instance->functions->_gnCreateX11WindowSurface(windowSurface, instance, createInfo);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef GN_WINDOW_WAYLAND
|
||||||
|
gnReturnCode gnCreateWaylandWindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWaylandWindowSurfaceInfo_t createInfo) {
|
||||||
|
return instance->functions->_gnCreateWaylandWindowSurface(windowSurface, instance, createInfo);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef GN_PLATFORM_WIN32
|
||||||
|
gnReturnCode gnCreateWin32WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWin32WindowSurfaceInfo_t createInfo) {
|
||||||
|
return instance->functions->_gnCreateWin32WindowSurface(windowSurface, instance, createInfo);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GN_PLATFORM_MACOS
|
||||||
|
gnReturnCode gnCreateMacOSWindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnMacOSWindowSurfaceInfo_t createInfo) {
|
||||||
|
windowSurface->instance = instance;
|
||||||
|
return instance->functions->_gnCreateMacOSWindowSurface(windowSurface, instance, createInfo);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void gnDestroyWindowSurface(struct gnWindowSurface_t *windowSurface) {
|
||||||
|
windowSurface->instance->functions->_gnDestroyWindowSurface(windowSurface);
|
||||||
|
}
|
48
src/core/window_surface/gryphn_surface.h
Normal file
48
src/core/window_surface/gryphn_surface.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <core/instance/gryphn_instance.h>
|
||||||
|
#include <platform/gryphn_platform_include.h>
|
||||||
|
|
||||||
|
struct gnPlatformWindowSurface;
|
||||||
|
|
||||||
|
typedef struct gnWindowSurface_t {
|
||||||
|
struct gnPlatformWindowSurface* windowSurface;
|
||||||
|
gnInstance* instance;
|
||||||
|
} gnWindowSurface;
|
||||||
|
void gnDestroyWindowSurface(struct gnWindowSurface_t* windowSurface);
|
||||||
|
|
||||||
|
#ifdef GN_PLATFORM_LINUX
|
||||||
|
#ifdef GN_WINDOW_X11
|
||||||
|
typedef struct gnX11WindowSurfaceInfo_t {
|
||||||
|
Display* display;
|
||||||
|
Window* window;
|
||||||
|
} gnX11WindowSurfaceCreateInfo;
|
||||||
|
|
||||||
|
gnReturnCode gnCreateX11WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnX11WindowSurfaceInfo_t createInfo);
|
||||||
|
#endif
|
||||||
|
#ifdef GN_WINDOW_WAYLAND
|
||||||
|
typedef struct gnWaylandWindowSurfaceInfo_t {
|
||||||
|
wl_display* display;
|
||||||
|
wl_surface* surface;
|
||||||
|
} gnWaylandWindowSurfaceInfo;
|
||||||
|
|
||||||
|
gnReturnCode gnCreateWaylandWindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWaylandWindowSurfaceInfo_t createInfo);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef GN_PLATFORM_WIN32
|
||||||
|
typedef struct gnWin32WindowSurfaceInfo_t {
|
||||||
|
HWND* window;
|
||||||
|
HINSTANCE* instance;
|
||||||
|
} gnWin32WindowSurfaceInfo;
|
||||||
|
|
||||||
|
gnReturnCode gnCreateWin32WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnWin32WindowSurfaceInfo_t createInfo);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GN_PLATFORM_MACOS
|
||||||
|
typedef struct gnMacOSWindowSurfaceInfo_t {
|
||||||
|
NSWindow* window;
|
||||||
|
} gnMacOSWindowSurfaceInfo;
|
||||||
|
|
||||||
|
gnReturnCode gnCreateMacOSWindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnMacOSWindowSurfaceInfo_t createInfo);
|
||||||
|
#endif
|
@@ -1,3 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <utils/strings/gryphn_string.h>
|
#include <utils/strings/gryphn_string.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
@class NSWindow;
|
||||||
|
#else
|
||||||
|
typedef void NSWindow;
|
||||||
|
#endif
|
||||||
|
@@ -0,0 +1,4 @@
|
|||||||
|
#ifdef GN_PLATFORM_WINDOWS
|
||||||
|
#include "windows.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@@ -7,7 +7,8 @@ typedef enum gnReturnCode_t {
|
|||||||
GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY,
|
GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY,
|
||||||
GN_FAILED_CREATE_INSTANCE,
|
GN_FAILED_CREATE_INSTANCE,
|
||||||
GN_FAILED_TO_CREATE_DEBUGGER,
|
GN_FAILED_TO_CREATE_DEBUGGER,
|
||||||
GN_FAILED_TO_CREATE_DEVICE
|
GN_FAILED_TO_CREATE_DEVICE,
|
||||||
|
GN_FAILED_TO_ATTACH_WINDOW
|
||||||
|
|
||||||
// GN_UNKNOWN_ERROR,
|
// GN_UNKNOWN_ERROR,
|
||||||
// GN_UNKNOWN_FRAMEBUFFER_ATTACHMENT,
|
// GN_UNKNOWN_FRAMEBUFFER_ATTACHMENT,
|
||||||
|
Reference in New Issue
Block a user