redo folder structure

This commit is contained in:
Gregory Wells
2026-05-25 12:27:10 -04:00
parent a252a9cf6b
commit dd3c50be07
10 changed files with 65 additions and 9 deletions
@@ -6,7 +6,7 @@
#include "stdint.h"
#include "device/gryphn_physical_device.h"
#include "device/gryphn_device.h"
#include "surface/gryphn_surface.h"
#include "ext/instance/surface/gryphn_surface.h"
gnReturnCode metalEnumeratePhysicalDevices(gnInstance instance, uint32_t* deviceCount, gnPhysicalDevice* devices);
gnReturnCode metalGetPhysicalDeviceProperties(gnPhysicalDevice device, gnPhysicalDeviceProperties* properties);
@@ -4,7 +4,7 @@
#include "../vulkan_functions.h"
#include <vulkan/vulkan_core.h>
#include "instance/gryphn_instance.h"
#include "surface/gryphn_surface.h"
#include "ext/instance/surface/gryphn_surface.h"
#include "../vulkan_helpers.h"
#include "stdlib.h"
#include <stdio.h>
+1 -1
View File
@@ -6,7 +6,7 @@ extern "C" {
#include "GryphnLoader/src/instance/gryphn_instance.h"
#include "GryphnLoader/src/device/gryphn_physical_device.h"
#include "GryphnLoader/src/device/gryphn_device.h"
#include "GryphnLoader/src/surface/gryphn_surface.h"
#include "GryphnLoader/src/ext/instance/surface/gryphn_surface.h"
#ifdef __cplusplus
}
#endif
+62 -6
View File
@@ -1,5 +1,5 @@
#define GN_USE_SURFACE_XLIB
#include "Gryphn/gryphn.h"
#include <Gryphn/gryphn.h>
#include "stdlib.h"
#include "iostream"
#define GLFW_EXPOSE_NATIVE_X11
@@ -21,6 +21,12 @@ gnInstance instance;
gnPhysicalDevice pysicalDevice;
gnDevice device;
gnSurface surface;
gnSwapchain swapchain;
int min(int a, int b) {
if (a < b) return a;
return b;
}
void createInstance() {
uint32_t backendCount = 0;
@@ -85,13 +91,63 @@ void createSurface() {
};
CHECK(gnCreateXlibSurface(instance, &createInfo, &surface));
gnSurfaceCapabilities capabilites;
gnGetSurfaceCapabilities(pysicalDevice, surface, &capabilites);
}
void createSwapchain() {
gnSurfaceFormat getSurfaceFormat() {
uint32_t surfaceFormatCount = 0;
CHECK(gnGetSurfaceFormats(pysicalDevice, surface, &surfaceFormatCount, NULL));
if (surfaceFormatCount == 0)
throw std::runtime_error("Gryphn returned 0 avaliable surface formats");
gnSurfaceFormat* formats = (gnSurfaceFormat*)malloc(sizeof(gnSurfaceFormat) * surfaceFormatCount);
CHECK(gnGetSurfaceFormats(pysicalDevice, surface, &surfaceFormatCount, formats));
for (int i = 0; i < surfaceFormatCount; i++)
if (formats[i].format == GN_FORMAT_BGRA8_SRGB && formats[i].colorSpace == GN_COLOR_SPACE_SRGB_NONLINEAR) return formats[i];
return formats[0];
return (gnSurfaceFormat){
.format = GN_FORMAT_UNDEFINED,
.colorSpace = GN_COLOR_SPACE_UNKNOWN
};
}
gnPresentMode getPresentMode() {
uint32_t presentModeCount = 0;
CHECK(gnGetSurfacePresentModes(pysicalDevice, surface, &presentModeCount, NULL));
if (presentModeCount == 0)
throw std::runtime_error("Gryphn returned 0 avaliable presentMode");
gnPresentMode* presentModes = (gnPresentMode*)malloc(sizeof(gnPresentMode) * presentModeCount);
CHECK(gnGetSurfacePresentModes(pysicalDevice, surface, &presentModeCount, presentModes));
for (int i = 0; i < presentModeCount; i++)
if (presentModes[i] == GN_PRESENT_MODE_MAILBOX) return presentModes[i];
return presentModes[0];
}
void createSwapchain() {
// gnSurfaceCapabilities capabilites;
// gnGetSurfaceCapabilities(pysicalDevice, surface, &capabilites);
// gnSurfaceFormat chosenFormat = getSurfaceFormat();
// gnPresentMode chosenMode = getPresentMode();
// int width, height;
// glfwGetWindowSize(window, &width, &height);
// gnSwapchainCreateInfo createInfo = {
// .surface = surface,
// .minImageCount = min(capabilites.minImageCount + 1, capabilites.maxImageCount),
// .imageFormat = chosenFormat.format,
// .imageColorSpace = chosenFormat.colorSpace,
// .imageExtent = { width, height },
// .imageArrayLayers = 1,
// .presentMode = chosenMode,
// };
// CHECK(gnCreateSwapchain(device, &createInfo, &swapchain));
}
int main() {
@@ -111,7 +167,7 @@ int main() {
createInstance();
createDevice();
createSurface();
// createSwapchain();
createSwapchain();
while (!glfwWindowShouldClose(window)) {
glfwPollEvents();
}