Files
VulkanTest/src/HelloTriangleApplication.h
2020-05-31 15:15:03 +02:00

72 lines
1.7 KiB
C++

//
// Created by rick on 08-05-20.
//
#ifndef VULKANTEST_HELLOTRIANGLEAPPLICATION_H
#define VULKANTEST_HELLOTRIANGLEAPPLICATION_H
#include "MyVkInstance.h"
#include <vector>
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
const int MAX_FRAMES_IN_FLIGHT = 2;
class HelloTriangleApplication {
public:
void run();
bool frameBufferResized = false;
private:
MyVkInstance *myVkInstance;
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;
// Vulkan initialisation
void createSwapChain();
void createImageViews();
void createRenderPass();
void createGraphicsPipeline();
void createFrameBuffers();
void createCommandPool();
void createCommandBuffers();
void createSyncObjects();
void initVulkan();
void recreateSwapChain();
void cleanupSwapChain();
// main loop
void mainLoop();
void drawFrame();
// clean up
void cleanup();
// utility functions
VkShaderModule createShaderModule(const std::vector<char> &code);
static void frameBufferResizeCallback(void *thisptr, int width, int height);
};
#endif //VULKANTEST_HELLOTRIANGLEAPPLICATION_H