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