gryphn window surfaces
This commit is contained in:
@@ -101,6 +101,5 @@ GN_EXPORT gnReturnCode gnCreateInstanceFn(gnInstance* instance, gnInstanceInfo i
|
||||
|
||||
GN_EXPORT void gnDestroyInstanceFn(gnInstance& instance) {
|
||||
instance.valid = false;
|
||||
vkDestroySurfaceKHR(instance.instance->vk_instance, instance.instance->window_surface, nullptr);
|
||||
vkDestroyInstance(instance.instance->vk_instance, nullptr);
|
||||
}
|
||||
|
@@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
#include <vulkan/vulkan.h>
|
||||
#ifdef GN_PLATFORM_MACOS
|
||||
#include <instance/vulkan_macos_bridge.h>
|
||||
#endif
|
||||
#include "vector"
|
||||
#include "core/debugger/gryphn_debugger.h"
|
||||
|
||||
@@ -15,7 +12,7 @@ struct gnInstanceMessage {
|
||||
struct gnPlatformInstance {
|
||||
VkInstance vk_instance;
|
||||
VkApplicationInfo appInfo;
|
||||
VkSurfaceKHR window_surface;
|
||||
// VkSurfaceKHR window_surface;
|
||||
|
||||
std::vector<const char*> extensions;
|
||||
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
|
Reference in New Issue
Block a user