101 lines
3 KiB
C++
101 lines
3 KiB
C++
#pragma once
|
|
|
|
#define GLFW_INCLUDE_VULKAN
|
|
#include <GLFW/glfw3.h>
|
|
|
|
#define GLM_FORCE_RADIANS
|
|
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
|
#include <glm/vec4.hpp>
|
|
#include <glm/mat4x4.hpp>
|
|
#include <vector>
|
|
|
|
#include <renderer/renderer.hpp>
|
|
#include <vulkan/vulkan_core.h>
|
|
|
|
namespace hibis::aethiopicus {
|
|
/** \class Aethiopicus
|
|
* Vulkan-based renderer for the Hibis game engine.
|
|
*
|
|
* @param title Application window title
|
|
* @param internalName Application internal name (used by Aethiopicus::mVulkanInstance)
|
|
* @param version A semantic version stored in an std::string
|
|
* @param size Size of the application window
|
|
* @param callback Logging callback
|
|
*/
|
|
class Aethiopicus : public Renderer {
|
|
public:
|
|
Aethiopicus(std::string title, std::string internalName, std::string version, IntVec2 size, LoggerCallback callback, bool useValidationLayers = true);
|
|
~Aethiopicus();
|
|
|
|
// Draw
|
|
void clearScreen(Color col = Color {0, 0, 0, 255}) override;
|
|
void renderCurrent() override;
|
|
|
|
void drawText(Resource* resource, std::string text, IntVec2 pos, Color color) override;
|
|
void drawTexture(Resource* resource, IntRect size) override;
|
|
|
|
void useShader(Shader* shader, Point2D points[3]) override;
|
|
void stopUsingShaders() override;
|
|
|
|
// Pre and Post draw
|
|
void preDraw() override;
|
|
void postDraw() override;
|
|
|
|
// Update
|
|
void update() override;
|
|
|
|
// Util
|
|
void compileShader(Shader* shader) override;
|
|
void toggleWireframe() override;
|
|
void setWindowTitle(std::string title) override;
|
|
void resize(unsigned int width, unsigned int height);
|
|
|
|
std::vector<const char*> mGLFWExtensionVector;
|
|
uint32_t mGLFWExtensionCount = 0;
|
|
const char** mGLFWExtensions;
|
|
|
|
std::vector<VkExtensionProperties> mVulkanExtensions;
|
|
private:
|
|
// Functions
|
|
bool checkValidationLayerSupport();
|
|
|
|
int rateDeviceSuitability(VkPhysicalDevice device, VkPhysicalDeviceProperties deviceProperties);
|
|
|
|
bool checkDeviceExtensionSupport(VkPhysicalDevice device);
|
|
|
|
VkResult createDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pDebugMessenger);
|
|
void destroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks* pAllocator);
|
|
// GLFW
|
|
GLFWwindow* mWindow;
|
|
|
|
// Vulkan
|
|
VkInstance mVulkanInstance;
|
|
VkPhysicalDevice mVulkanGraphicsDevice = VK_NULL_HANDLE;
|
|
VkDevice mVulkanLogicalDevice;
|
|
|
|
VkQueue mVulkanGraphicsQueue;
|
|
VkQueue mVulkanPresentQueue;
|
|
|
|
VkSurfaceKHR mVulkanSurface;
|
|
VkSwapchainKHR mVulkanSwapchain;
|
|
|
|
VkDebugUtilsMessengerEXT mDebugMessenger;
|
|
|
|
VkFormat mSwapChainImageFormat;
|
|
VkExtent2D mSwapChainExtent;
|
|
|
|
std::vector<VkImage> mSwapchainImages;
|
|
std::vector<VkImageView> mSwapChainImageViews;
|
|
|
|
bool mUseValidationLayers = false;
|
|
|
|
const std::vector<const char*> mValidationLayers = {
|
|
"VK_LAYER_KHRONOS_validation"
|
|
};
|
|
|
|
const std::vector<const char*> mRequiredDeviceExtensions = {
|
|
VK_KHR_SWAPCHAIN_EXTENSION_NAME
|
|
};
|
|
};
|
|
}
|