gryphn window surfaces
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "debugger/gryphn_debugger.h"
|
||||
#include "output_device/gryphn_physical_output_device.h"
|
||||
#include "output_device/gryphn_output_device.h"
|
||||
#include "window_surface/gryphn_surface.h"
|
||||
|
||||
typedef struct gnFunctions_t {
|
||||
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);
|
||||
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;
|
||||
|
||||
typedef struct gnDeviceFunctions_t {
|
||||
|
@@ -26,26 +26,3 @@ typedef struct gnInstance_t {
|
||||
|
||||
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info);
|
||||
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 "gryphn_dynamic_library.h"
|
||||
// #include <dlfcn.h>
|
||||
#include "stdio.h"
|
||||
|
||||
gnBool gnIsAPISupported(gnRenderingAPI api) {
|
||||
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->_gnRegisterOutputDevice, "gnRegisterOutputDeviceFn");
|
||||
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) {
|
||||
|
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
|
||||
#include <utils/strings/gryphn_string.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_FAILED_CREATE_INSTANCE,
|
||||
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_FRAMEBUFFER_ATTACHMENT,
|
||||
|
Reference in New Issue
Block a user