plumageRender/base/vulkanexamplebase.h

106 lines
1.9 KiB
C++

/*
* Vulkan Example base class
*
* Copyright (C) 2016 by Sascha Willems - www.saschawillems.de
*
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/
#pragma once
#include <iostream>
#include <chrono>
#include <sys/stat.h>
#include <string>
#include <sstream>
#include <array>
#include <numeric>
#include "vulkan/vulkan.h"
#include "VulkanTools.h"
#include "camera.hpp"
#include "keycodes.hpp"
#include "VulkanDevice.hpp"
#include "VulkanSwapChain.hpp"
//#include "imgui/imgui.h"
class VulkanExampleBase
{
private:
uint32_t frameCounter = 0;
bool resizing = false;
//void handleMouseMove(int32_t x, int32_t y);
PFN_vkCreateDebugReportCallbackEXT vkCreateDebugReportCallback;
PFN_vkDestroyDebugReportCallbackEXT vkDestroyDebugReportCallback;
VkDebugReportCallbackEXT debugReportCallback;
protected:
VkInstance instance;
VkPhysicalDeviceProperties deviceProperties;
VkPhysicalDeviceMemoryProperties deviceMemoryProperties;
VkQueue queue;
VkFormat depthFormat;
VkCommandPool cmdPool;
std::vector<VkFramebuffer>frameBuffers;
uint32_t currentBuffer = 0;
//VulkanSwapChain swapChain;
void windowResize();
public:
static std::vector<const char*> args;
uint32_t selectedPhysicalDeviceIndex = 0;
bool prepared = false;
uint32_t width = 1280;
uint32_t height = 720;
bool paused = false;
struct GamePadState {
glm::vec2 axisLeft = glm::vec2(0.0f);
glm::vec2 axisRight = glm::vec2(0.0f);
} gamePadState;
VulkanExampleBase();
virtual ~VulkanExampleBase();
//virtual void render() = 0;
virtual void windowResized();
virtual void setupFrameBuffer();
void createSwapChainFramebuffer();
virtual void prepare();
virtual void fileDropped(std::string filename);
void initSwapchain();
void setupSwapChain();
VkFormat findDepthFormat();
VkFormat findSupportedFormat(const std::vector<VkFormat>& candidates, VkImageTiling tiling, VkFormatFeatureFlags features);
};