feat: initial commit
This commit is contained in:
82
src/HelloTriangleApplication.h
Normal file
82
src/HelloTriangleApplication.h
Normal file
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// Created by rick on 08-05-20.
|
||||
//
|
||||
|
||||
#ifndef VULKANTEST_HELLOTRIANGLEAPPLICATION_H
|
||||
#define VULKANTEST_HELLOTRIANGLEAPPLICATION_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#define GLFW_INCLUDE_VULKAN
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
const int MAX_FRAMES_IN_FLIGHT = 2;
|
||||
|
||||
const int WIDTH = 800;
|
||||
const int HEIGHT = 600;
|
||||
|
||||
class HelloTriangleApplication {
|
||||
public:
|
||||
void run();
|
||||
|
||||
private:
|
||||
GLFWwindow* window;
|
||||
VkInstance instance;
|
||||
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
|
||||
VkDevice device;
|
||||
VkQueue graphicsQueue;
|
||||
VkQueue presentQueue;
|
||||
VkSurfaceKHR surface;
|
||||
VkDebugUtilsMessengerEXT debugMessenger;
|
||||
VkSwapchainKHR swapChain;
|
||||
std::vector<VkImage> swapChainImages;
|
||||
std::vector<VkImageView> swapChainImageViews;
|
||||
VkFormat swapChainImageFormat;
|
||||
VkExtent2D swapChainExtent;
|
||||
VkRenderPass renderPass;
|
||||
VkPipelineLayout pipelineLayout;
|
||||
VkPipeline graphicsPipeline;
|
||||
std::vector<VkFramebuffer> swapChainFrameBuffers;
|
||||
VkCommandPool commandPool;
|
||||
std::vector<VkCommandBuffer> commandBuffers;
|
||||
|
||||
std::vector<VkSemaphore> imageAvailableSemaphores;
|
||||
std::vector<VkSemaphore> renderFinishedSemaphores;
|
||||
std::vector<VkFence> inFlightFences;
|
||||
std::vector<VkFence> imagesInFlight;
|
||||
|
||||
int currentFrame = 0;
|
||||
|
||||
// window creation
|
||||
void initWindow();
|
||||
|
||||
// Vulkan initialisation
|
||||
void createInstance();
|
||||
void pickPhysicalDevice();
|
||||
void createLogicalDevice();
|
||||
void createSurface();
|
||||
void createSwapChain();
|
||||
void createImageViews();
|
||||
void createRenderPass();
|
||||
void createGraphicsPipeline();
|
||||
void createFrameBuffers();
|
||||
void createCommandPool();
|
||||
void createCommandBuffers();
|
||||
void createSyncObjects();
|
||||
void initVulkan();
|
||||
|
||||
// main loop
|
||||
void mainLoop();
|
||||
void drawFrame();
|
||||
|
||||
// clean up
|
||||
void cleanup();
|
||||
|
||||
// utility functions
|
||||
std::vector<const char*> getRequiredExtensions();
|
||||
VkShaderModule createShaderModule(const std::vector<char> &code);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //VULKANTEST_HELLOTRIANGLEAPPLICATION_H
|
||||
Reference in New Issue
Block a user