get image count and preferred surface format
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#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>
|
#include <core/window_surface/gryphn_surface.h>
|
||||||
|
#include <core/window_surface/gryphn_surface_create_functions.h>
|
||||||
#include <core/presentation_queue/gryphn_presentation_queue.h>
|
#include <core/presentation_queue/gryphn_presentation_queue.h>
|
||||||
|
|
||||||
// #pragma once
|
// #pragma once
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueue* presentationQueue, const gnOutputDevice* device, struct gnPresentationQueueInfo_t presentationInfo) {
|
gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueue* presentationQueue, const gnOutputDevice* device, struct gnPresentationQueueInfo_t presentationInfo) {
|
||||||
vkSwapchainSupportDetails details = vkGetSwapchainSupport(device->physicalDevice.physicalDevice->device, presentationInfo.surface.windowSurface->surface);
|
vkSwapchainSupportDetails details = vkGetSwapchainSupport(device->physicalDevice.physicalDevice->device, presentationInfo.surface.windowSurface->surface);
|
||||||
|
|
||||||
if (details.formatCount == 0) {
|
if (details.formatCount == 0) {
|
||||||
gnDebuggerSetErrorMessage(device->instance->debugger,
|
gnDebuggerSetErrorMessage(device->instance->debugger,
|
||||||
(gnMessageData){
|
(gnMessageData){
|
||||||
@@ -15,7 +14,6 @@ gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueue* presentationQueue,
|
|||||||
);
|
);
|
||||||
return GN_NO_SUPPORTED_FORMATS;
|
return GN_NO_SUPPORTED_FORMATS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (details.presentModeCount == 0) {
|
if (details.presentModeCount == 0) {
|
||||||
gnDebuggerSetErrorMessage(device->instance->debugger,
|
gnDebuggerSetErrorMessage(device->instance->debugger,
|
||||||
(gnMessageData){
|
(gnMessageData){
|
||||||
@@ -25,6 +23,28 @@ gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueue* presentationQueue,
|
|||||||
return GN_NO_SUPPORTED_PRESENT_MODES;
|
return GN_NO_SUPPORTED_PRESENT_MODES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int index = -1;
|
||||||
|
VkFormat convertedFormat = vkGryphnFormatToVulkanFormat(presentationInfo.format.format);
|
||||||
|
VkColorSpaceKHR convertedColorSpace = vkGryphnColorSpaceToVulkanColorSpace(presentationInfo.format.colorSpace);
|
||||||
|
for (int i = 0; i < details.formatCount; i++) {
|
||||||
|
if (details.formats[i].format == convertedFormat && details.formats[i].colorSpace == convertedColorSpace) {
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index == -1) {
|
||||||
|
gnDebuggerSetErrorMessage(device->instance->debugger, (gnMessageData){
|
||||||
|
.message = gnCreateString("Unsupported color format passed to Gryphn")
|
||||||
|
});
|
||||||
|
return GN_UNKNOWN_IMAGE_FORMAT;
|
||||||
|
}
|
||||||
|
VkPresentModeKHR presentMode = VK_PRESENT_MODE_FIFO_KHR;
|
||||||
|
VkExtent2D extent = {
|
||||||
|
.width = presentationInfo.ImageSize.x,
|
||||||
|
.height = presentationInfo.ImageSize.y
|
||||||
|
};
|
||||||
|
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,11 +59,8 @@ void gnDestroyWindowSurfaceFn(struct gnWindowSurface_t* windowSurface) {
|
|||||||
vkDestroySurfaceKHR(windowSurface->instance->instance->vk_instance, windowSurface->windowSurface->surface, NULL);
|
vkDestroySurfaceKHR(windowSurface->instance->instance->vk_instance, windowSurface->windowSurface->surface, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct gnSurfaceFormat_t* vkGetSurfaceFormats(
|
||||||
struct gnSurfaceFormat_t* gnGetSupportedSurfaceFormatsFn(
|
struct gnWindowSurface_t* windowSurface, struct gnPhysicalDevice_t device, uint32_t* formatCount
|
||||||
struct gnWindowSurface_t* windowSurface,
|
|
||||||
struct gnPhysicalDevice_t device,
|
|
||||||
uint32_t* formatCount
|
|
||||||
) {
|
) {
|
||||||
struct gnSurfaceFormat_t* formats = NULL;
|
struct gnSurfaceFormat_t* formats = NULL;
|
||||||
|
|
||||||
@@ -88,3 +85,34 @@ struct gnSurfaceFormat_t* gnGetSupportedSurfaceFormatsFn(
|
|||||||
|
|
||||||
return formats;
|
return formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct gnSurfaceDetails_t gnGetSurfaceDetailsFn(
|
||||||
|
// struct gnWindowSurface_t* windowSurface,
|
||||||
|
// struct gnPhysicalDevice_t device,
|
||||||
|
// uint32_t* formatCount
|
||||||
|
struct gnWindowSurface_t* windowSurface, struct gnPhysicalDevice_t device
|
||||||
|
) {
|
||||||
|
struct gnSurfaceDetails_t surfaceDetails;
|
||||||
|
surfaceDetails.formats = vkGetSurfaceFormats(windowSurface, device, &surfaceDetails.formatCount);
|
||||||
|
|
||||||
|
VkSurfaceCapabilitiesKHR details;
|
||||||
|
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device.physicalDevice->device, windowSurface->windowSurface->surface, &details);
|
||||||
|
|
||||||
|
surfaceDetails.minImageCount = details.minImageCount;
|
||||||
|
surfaceDetails.maxImageCount = details.maxImageCount;
|
||||||
|
|
||||||
|
return surfaceDetails;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VkFormat vkGryphnFormatToVulkanFormat(gnImageFormat format) {
|
||||||
|
switch (format) {
|
||||||
|
case GN_FORMAT_BGRA8_SRGB: { return VK_FORMAT_B8G8R8A8_SRGB; }
|
||||||
|
default: return VK_FORMAT_UNDEFINED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
VkColorSpaceKHR vkGryphnColorSpaceToVulkanColorSpace(gnColorSpace colorSpace) {
|
||||||
|
switch (colorSpace) {
|
||||||
|
case GN_COLOR_SPACE_SRGB_NONLINEAR: { return VK_COLOR_SPACE_SRGB_NONLINEAR_KHR; }
|
||||||
|
}
|
||||||
|
}
|
@@ -5,3 +5,6 @@
|
|||||||
typedef struct gnPlatformWindowSurface_t {
|
typedef struct gnPlatformWindowSurface_t {
|
||||||
VkSurfaceKHR surface;
|
VkSurfaceKHR surface;
|
||||||
} gnPlatformWindowSurface;
|
} gnPlatformWindowSurface;
|
||||||
|
|
||||||
|
VkFormat vkGryphnFormatToVulkanFormat(gnImageFormat format);
|
||||||
|
VkColorSpaceKHR vkGryphnColorSpaceToVulkanColorSpace(gnColorSpace colorSpace);
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#ifdef GN_PLATFORM_MACOS
|
#ifdef GN_PLATFORM_MACOS
|
||||||
#include "vulkan_surface.h"
|
#include "vulkan_surface.h"
|
||||||
|
#include "core/window_surface/gryphn_surface_create_functions.h"
|
||||||
#include "../instance/vulkan_instance.h"
|
#include "../instance/vulkan_instance.h"
|
||||||
#include <AppKit/AppKit.h>
|
#include <AppKit/AppKit.h>
|
||||||
#include <vulkan/vulkan_metal.h>
|
#include <vulkan/vulkan_metal.h>
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
#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"
|
#include "window_surface/gryphn_surface.h"
|
||||||
|
#include "window_surface/gryphn_surface_create_functions.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);
|
||||||
@@ -42,7 +43,7 @@ typedef struct gnFunctions_t {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void (*_gnDestroyWindowSurface)(struct gnWindowSurface_t* windowSurface);
|
void (*_gnDestroyWindowSurface)(struct gnWindowSurface_t* windowSurface);
|
||||||
struct gnSurfaceFormat_t* (*_gnGetSupportedSurfaceFormats)(struct gnWindowSurface_t* windowSurface, struct gnPhysicalDevice_t device, uint32_t* formatCount);
|
struct gnSurfaceDetails_t (*_gnGetSurfaceDetails)(struct gnWindowSurface_t* windowSurface, struct gnPhysicalDevice_t device);
|
||||||
} gnFunctions;
|
} gnFunctions;
|
||||||
|
|
||||||
#include "core/presentation_queue/gryphn_presentation_queue.h"
|
#include "core/presentation_queue/gryphn_presentation_queue.h"
|
||||||
|
@@ -65,7 +65,7 @@ void gnLoadFunctions(struct gnDynamicLibrary_t* lib, struct gnFunctions_t* funct
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
gnLoadDLLFunction(lib, functions->_gnDestroyWindowSurface, "gnDestroyWindowSurfaceFn");
|
gnLoadDLLFunction(lib, functions->_gnDestroyWindowSurface, "gnDestroyWindowSurfaceFn");
|
||||||
gnLoadDLLFunction(lib, functions->_gnGetSupportedSurfaceFormats, "gnGetSupportedSurfaceFormatsFn");
|
gnLoadDLLFunction(lib, functions->_gnGetSurfaceDetails, "gnGetSurfaceDetailsFn");
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFunctions_t* functions) {
|
void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFunctions_t* functions) {
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <gryphn/gryphn_utils.h>
|
#include <gryphn/gryphn_utils.h>
|
||||||
#include "core/output_device/gryphn_output_device.h"
|
#include <core/output_device/gryphn_output_device.h>
|
||||||
#include <core/window_surface/gryphn_surface.h>
|
#include <core/window_surface/gryphn_surface.h>
|
||||||
#include <utils/types/gryphn_image_format.h>
|
#include <utils/types/gryphn_image_format.h>
|
||||||
|
|
||||||
typedef struct gnPresentationQueueInfo_t {
|
typedef struct gnPresentationQueueInfo_t {
|
||||||
gnUInt ImageCount;
|
uint32_t ImageCount;
|
||||||
gnUInt2 ImageSize;
|
struct gnUInt2_t ImageSize;
|
||||||
struct gnWindowSurface_t surface;
|
struct gnWindowSurface_t surface;
|
||||||
struct gnSurfaceFormat_t format;
|
struct gnSurfaceFormat_t format;
|
||||||
} gnPresentationQueueInfo;
|
} gnPresentationQueueInfo;
|
||||||
|
@@ -1,34 +1,6 @@
|
|||||||
|
|
||||||
#include "gryphn_surface.h"
|
#include "gryphn_surface.h"
|
||||||
#include "core/gryphn_platform_functions.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) {
|
void gnDestroyWindowSurface(struct gnWindowSurface_t *windowSurface) {
|
||||||
windowSurface->instance->functions->_gnDestroyWindowSurface(windowSurface);
|
windowSurface->instance->functions->_gnDestroyWindowSurface(windowSurface);
|
||||||
}
|
}
|
||||||
@@ -38,5 +10,54 @@ struct gnSurfaceFormat_t* gnGetSupportedSurfaceFormats(
|
|||||||
struct gnPhysicalDevice_t device,
|
struct gnPhysicalDevice_t device,
|
||||||
uint32_t* formatCount
|
uint32_t* formatCount
|
||||||
) {
|
) {
|
||||||
return windowSurface->instance->functions->_gnGetSupportedSurfaceFormats(windowSurface, device, formatCount);
|
struct gnSurfaceDetails_t surfaceDetails = windowSurface->instance->functions->_gnGetSurfaceDetails(windowSurface, device);
|
||||||
|
*formatCount = surfaceDetails.formatCount;
|
||||||
|
return surfaceDetails.formats;
|
||||||
|
}
|
||||||
|
|
||||||
|
gnBool gnIsSurfaceFormatSupported(
|
||||||
|
struct gnWindowSurface_t* windowSurface,
|
||||||
|
struct gnPhysicalDevice_t device,
|
||||||
|
struct gnSurfaceFormat_t format
|
||||||
|
) {
|
||||||
|
uint32_t formatCount = 0;
|
||||||
|
gnSurfaceFormat* formats = gnGetSupportedSurfaceFormats(windowSurface, device, &formatCount);
|
||||||
|
for (int i = 0; i < formatCount; i++) {
|
||||||
|
if (formats[i].format == format.format && formats[i].colorSpace == format.colorSpace) {
|
||||||
|
return gnTrue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return gnFalse;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct gnSurfaceFormat_t gnGetPreferredSurfaceFormat(
|
||||||
|
struct gnWindowSurface_t* windowSurface,
|
||||||
|
struct gnPhysicalDevice_t device,
|
||||||
|
struct gnSurfaceFormat_t format
|
||||||
|
) {
|
||||||
|
uint32_t formatCount = 0;
|
||||||
|
gnSurfaceFormat* formats = gnGetSupportedSurfaceFormats(windowSurface, device, &formatCount);
|
||||||
|
for (int i = 0; i < formatCount; i++) {
|
||||||
|
if (formats[i].format == format.format && formats[i].colorSpace == format.colorSpace) {
|
||||||
|
return formats[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// will attempt to give you a simmilar format that either matches the Image format and the Color space
|
||||||
|
for (int i = 0; i < formatCount; i++) {
|
||||||
|
if (formats[i].format == format.format || formats[i].colorSpace == format.colorSpace) {
|
||||||
|
return formats[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return formats[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
int gnGetMinImageCount(struct gnWindowSurface_t surface, struct gnPhysicalDevice_t device) {
|
||||||
|
struct gnSurfaceDetails_t surfaceDetails = surface.instance->functions->_gnGetSurfaceDetails(&surface, device);
|
||||||
|
return surfaceDetails.minImageCount;
|
||||||
|
}
|
||||||
|
int gnGetMaxImageCount(struct gnWindowSurface_t surface, struct gnPhysicalDevice_t device) {
|
||||||
|
struct gnSurfaceDetails_t surfaceDetails = surface.instance->functions->_gnGetSurfaceDetails(&surface, device);
|
||||||
|
return surfaceDetails.maxImageCount;
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,13 @@ typedef struct gnSurfaceFormat_t {
|
|||||||
gnColorSpace colorSpace;
|
gnColorSpace colorSpace;
|
||||||
} gnSurfaceFormat;
|
} gnSurfaceFormat;
|
||||||
|
|
||||||
|
typedef struct gnSurfaceDetails_t {
|
||||||
|
uint32_t formatCount;
|
||||||
|
struct gnSurfaceFormat_t* formats;
|
||||||
|
|
||||||
|
int minImageCount, maxImageCount;
|
||||||
|
} gnSufaceDetails;
|
||||||
|
|
||||||
typedef struct gnWindowSurface_t {
|
typedef struct gnWindowSurface_t {
|
||||||
struct gnPlatformWindowSurface_t* windowSurface;
|
struct gnPlatformWindowSurface_t* windowSurface;
|
||||||
gnInstance* instance;
|
gnInstance* instance;
|
||||||
@@ -21,40 +28,18 @@ struct gnSurfaceFormat_t* gnGetSupportedSurfaceFormats(
|
|||||||
struct gnPhysicalDevice_t device,
|
struct gnPhysicalDevice_t device,
|
||||||
uint32_t* formatCount
|
uint32_t* formatCount
|
||||||
);
|
);
|
||||||
|
gnBool gnIsSurfaceFormatSupported(
|
||||||
#ifdef GN_PLATFORM_LINUX
|
struct gnWindowSurface_t* windowSurface,
|
||||||
#ifdef GN_WINDOW_X11
|
struct gnPhysicalDevice_t device,
|
||||||
typedef struct gnX11WindowSurfaceInfo_t {
|
struct gnSurfaceFormat_t format
|
||||||
Display* display;
|
);
|
||||||
Window* window;
|
// this function will give you you're preferred surface format
|
||||||
} gnX11WindowSurfaceCreateInfo;
|
// unless its not supported then it will give you the first supported surface format
|
||||||
|
// at some point this function will attempt to give you the most simmilar surface format
|
||||||
gnReturnCode gnCreateX11WindowSurface(struct gnWindowSurface_t* windowSurface, gnInstance* instance, struct gnX11WindowSurfaceInfo_t createInfo);
|
struct gnSurfaceFormat_t gnGetPreferredSurfaceFormat(
|
||||||
#endif
|
struct gnWindowSurface_t* windowSurface,
|
||||||
#ifdef GN_WINDOW_WAYLAND
|
struct gnPhysicalDevice_t device,
|
||||||
typedef struct gnWaylandWindowSurfaceInfo_t {
|
struct gnSurfaceFormat_t format
|
||||||
wl_display* display;
|
);
|
||||||
wl_surface* surface;
|
int gnGetMinImageCount(struct gnWindowSurface_t surface, struct gnPhysicalDevice_t device);
|
||||||
} gnWaylandWindowSurfaceInfo;
|
int gnGetMaxImageCount(struct gnWindowSurface_t surface, struct gnPhysicalDevice_t device);
|
||||||
|
|
||||||
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
|
|
||||||
|
30
src/core/window_surface/gryphn_surface_create_functions.c
Normal file
30
src/core/window_surface/gryphn_surface_create_functions.c
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#include "gryphn_surface_create_functions.h"
|
||||||
|
#include "core/instance/gryphn_instance.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
|
39
src/core/window_surface/gryphn_surface_create_functions.h
Normal file
39
src/core/window_surface/gryphn_surface_create_functions.h
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "gryphn_surface.h"
|
||||||
|
|
||||||
|
#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
|
@@ -12,7 +12,8 @@ typedef enum gnReturnCode_t {
|
|||||||
GN_INVALID_INSTANCE,
|
GN_INVALID_INSTANCE,
|
||||||
GN_DEBUGGER_EXISTS,
|
GN_DEBUGGER_EXISTS,
|
||||||
GN_NO_SUPPORTED_FORMATS,
|
GN_NO_SUPPORTED_FORMATS,
|
||||||
GN_NO_SUPPORTED_PRESENT_MODES
|
GN_NO_SUPPORTED_PRESENT_MODES,
|
||||||
|
GN_UNKNOWN_IMAGE_FORMAT
|
||||||
|
|
||||||
// GN_UNKNOWN_ERROR,
|
// GN_UNKNOWN_ERROR,
|
||||||
// GN_UNKNOWN_FRAMEBUFFER_ATTACHMENT,
|
// GN_UNKNOWN_FRAMEBUFFER_ATTACHMENT,
|
||||||
@@ -45,5 +46,6 @@ static const char* gnErrorCodeToCString(enum gnReturnCode_t returnCode) {
|
|||||||
case GN_DEBUGGER_EXISTS: return "GN_DEBUGGER_EXISTS";
|
case GN_DEBUGGER_EXISTS: return "GN_DEBUGGER_EXISTS";
|
||||||
case GN_NO_SUPPORTED_FORMATS: return "GN_NO_SUPPORTED_FORMATS";
|
case GN_NO_SUPPORTED_FORMATS: return "GN_NO_SUPPORTED_FORMATS";
|
||||||
case GN_NO_SUPPORTED_PRESENT_MODES: return "GN_NO_SUPPORTED_PRESENT_MODES";
|
case GN_NO_SUPPORTED_PRESENT_MODES: return "GN_NO_SUPPORTED_PRESENT_MODES";
|
||||||
|
case GN_UNKNOWN_IMAGE_FORMAT: return "GN_UNKNOWN_IMAGE_FORMAT";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
|
|
||||||
typedef struct gnVec2 {
|
typedef struct gnVec2_t {
|
||||||
union {
|
union {
|
||||||
struct { float a, b; };
|
struct { float a, b; };
|
||||||
struct { float x, y; };
|
struct { float x, y; };
|
||||||
@@ -28,7 +28,7 @@ typedef struct gnVec2 {
|
|||||||
typedef gnVec2 gnFVec2;
|
typedef gnVec2 gnFVec2;
|
||||||
typedef gnVec2 gnFloat2;
|
typedef gnVec2 gnFloat2;
|
||||||
|
|
||||||
typedef struct gnUInt2 {
|
typedef struct gnUInt2_t {
|
||||||
union {
|
union {
|
||||||
struct { uint32_t a, b; };
|
struct { uint32_t a, b; };
|
||||||
struct { uint32_t x, y; };
|
struct { uint32_t x, y; };
|
||||||
@@ -52,7 +52,7 @@ typedef struct gnUInt2 {
|
|||||||
#endif
|
#endif
|
||||||
} gnUInt2;
|
} gnUInt2;
|
||||||
|
|
||||||
typedef struct gnInt2 {
|
typedef struct gnInt2_t {
|
||||||
union {
|
union {
|
||||||
struct { int a, b; };
|
struct { int a, b; };
|
||||||
struct { int x, y; };
|
struct { int x, y; };
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
typedef enum gnImageFormat_e {
|
typedef enum gnImageFormat_e {
|
||||||
|
GN_FORMAT_NONE,
|
||||||
GN_FORMAT_BGRA8_SRGB
|
GN_FORMAT_BGRA8_SRGB
|
||||||
} gnImageFormat;
|
} gnImageFormat;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user