add a helper function
This commit is contained in:
@@ -5,6 +5,14 @@
|
||||
#include "stdlib.h"
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
gnReturnCode vulkanCodeToGryphnCode(VkResult result) {
|
||||
if (result != VK_SUCCESS) {
|
||||
printf("Unknown instance fail mr gregory please diagnose this: %u", result);
|
||||
return GN_FAILED_TO_FIND_LIBARY;
|
||||
}
|
||||
return GN_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t gnInternalIsApiSupported(gnVersion gryphnVersion) {
|
||||
if (gryphnVersion != gnCreateVersion(1, 0, 0)) return 0;
|
||||
|
||||
@@ -83,10 +91,5 @@ gnReturnCode initBackend(gnInstance instance, gnInstanceCreateInfo* info) {
|
||||
VkInstance vulkanInstance;
|
||||
VkResult result = vkCreateInstance(&createInfo, NULL, &vulkanInstance);
|
||||
instance->internalData = vulkanInstance;
|
||||
|
||||
if (result != VK_SUCCESS) {
|
||||
printf("Unknown instance fail mr gregory please diagnose this");
|
||||
return GN_FAILED_TO_FIND_LIBARY;
|
||||
}
|
||||
return GN_SUCCESS;
|
||||
return vulkanCodeToGryphnCode(result);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
#include "gryphn_return_code.h"
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
gnReturnCode vulkanCodeToGryphnCode(VkResult result);
|
||||
@@ -55,28 +55,28 @@ void createInstance() {
|
||||
void createDevice() {
|
||||
uint32_t physicalDeviceCount;
|
||||
CHECK(gnEnumeratePhysicalDevices(instance, &physicalDeviceCount, nullptr));
|
||||
gnPhysicalDevice* devices = (gnPhysicalDevice*)malloc(sizeof(gnPhysicalDevice) * physicalDeviceCount);
|
||||
CHECK(gnEnumeratePhysicalDevices(instance, &physicalDeviceCount, devices));
|
||||
// gnPhysicalDevice* devices = (gnPhysicalDevice*)malloc(sizeof(gnPhysicalDevice) * physicalDeviceCount);
|
||||
// CHECK(gnEnumeratePhysicalDevices(instance, &physicalDeviceCount, devices));
|
||||
|
||||
std::cout << "Found " << physicalDeviceCount << " physical devices:\n";
|
||||
for (int i = 0; i < physicalDeviceCount; i++) {
|
||||
gnPhysicalDeviceProperties properties;
|
||||
gnGetPhysicalDeviceProperties(devices[i], &properties);
|
||||
std::cout << "Name: " << properties.deviceName << "\n";
|
||||
}
|
||||
// std::cout << "Found " << physicalDeviceCount << " physical devices:\n";
|
||||
// for (int i = 0; i < physicalDeviceCount; i++) {
|
||||
// gnPhysicalDeviceProperties properties;
|
||||
// gnGetPhysicalDeviceProperties(devices[i], &properties);
|
||||
// std::cout << "Name: " << properties.deviceName << "\n";
|
||||
// }
|
||||
|
||||
pysicalDevice = devices[0];
|
||||
// pysicalDevice = devices[0];
|
||||
|
||||
const char* extensions[1] = {
|
||||
"GN_EXT_swapchain"
|
||||
};
|
||||
// const char* extensions[1] = {
|
||||
// "GN_EXT_swapchain"
|
||||
// };
|
||||
|
||||
gnDeviceCreateInfo createInfo = {
|
||||
.physicalDevice = pysicalDevice,
|
||||
.enabledExtensionCount = 1,
|
||||
.enabledExtensions = extensions
|
||||
};
|
||||
CHECK(gnCreateDevice(instance, &createInfo, &device));
|
||||
// gnDeviceCreateInfo createInfo = {
|
||||
// .physicalDevice = pysicalDevice,
|
||||
// .enabledExtensionCount = 1,
|
||||
// .enabledExtensions = extensions
|
||||
// };
|
||||
// CHECK(gnCreateDevice(instance, &createInfo, &device));
|
||||
}
|
||||
|
||||
void createSurface() {
|
||||
@@ -115,7 +115,7 @@ int main() {
|
||||
|
||||
try {
|
||||
createInstance();
|
||||
// createDevice();
|
||||
createDevice();
|
||||
// createSurface();
|
||||
// createSwapchain();
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
|
||||
Reference in New Issue
Block a user