Created vulkan instance.
This commit is contained in:
parent
562f4ceda2
commit
ce710dcd24
4 changed files with 67 additions and 0 deletions
|
|
@ -1,3 +1,11 @@
|
|||
# Yet Another Vulkan Engine.
|
||||
This project has been created with the sole purpose of teaching me how Vulkan
|
||||
works.
|
||||
|
||||
# Installing Dependancies.
|
||||
To build the project on redhat based distros these dependancies or their
|
||||
equivelents are required.
|
||||
'''
|
||||
sudo dnf install vulkan-tools vulkan-loader-devel vulkan-validation-layers-devel
|
||||
glfw-devel glm-devel glslc
|
||||
'''
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
#include "application.hpp"
|
||||
#include "yave_vulkan_instance.hpp"
|
||||
|
||||
namespace yave {
|
||||
|
||||
void Application::run() {
|
||||
yaveVulkanInstance VI = yaveVulkanInstance();
|
||||
|
||||
while (!yaveWindow.shouldClose()) {
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
|
|
|||
35
src/yave_vulkan_instance.cpp
Normal file
35
src/yave_vulkan_instance.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#include "yave_vulkan_instance.hpp"
|
||||
|
||||
namespace yave {
|
||||
|
||||
YaveVulkanInstance::YaveVulkanInstance() { createInstance(); }
|
||||
|
||||
void YaveVulkanInstance::createInstance() {
|
||||
VkApplicationInfo appInfo{};
|
||||
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
||||
appInfo.pApplicationName = "Hello Triangle";
|
||||
appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
|
||||
appInfo.pEngineName = "Yave";
|
||||
appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
|
||||
appInfo.apiVersion = VK_API_VERSION_1_0;
|
||||
|
||||
VkInstanceCreateInfo createInfo{};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||
createInfo.pApplicationInfo = &appInfo;
|
||||
|
||||
uint32_t glfwExtensionCount = 0;
|
||||
const char **glfwExtensions;
|
||||
|
||||
glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);
|
||||
|
||||
createInfo.enabledExtensionCount = glfwExtensionCount;
|
||||
createInfo.ppEnabledExtensionNames = glfwExtensions;
|
||||
|
||||
createInfo.enabledLayerCount = 0;
|
||||
|
||||
if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS) {
|
||||
throw std::runtime_error("failed to create vulkan instance!");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace yave
|
||||
21
src/yave_vulkan_instance.hpp
Normal file
21
src/yave_vulkan_instance.hpp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#define GLFW_INCLUDE_VULKAN
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
namespace yave {
|
||||
class YaveVulkanInstance {
|
||||
|
||||
private:
|
||||
VkInstance instance;
|
||||
|
||||
void createInstance();
|
||||
|
||||
public:
|
||||
YaveVulkanInstance();
|
||||
|
||||
};
|
||||
} // namespace yave
|
||||
Loading…
Reference in a new issue