|
CheeseEngine
A 2D Game Engine
|
Class that implements graphic system. More...
#include <graphicCore.hpp>
Classes | |
| struct | Camera |
| struct | FigureDesc |
| struct | PushConstant |
| struct | QueueFamilyIndicies |
| struct | SwapChainSupportDetails |
| struct | TextureArray |
| struct | UniformBufferObject |
| struct | Vertex |
Public Member Functions | |
| GraphicCore (GLFWwindow *window) | |
| Object constructor. | |
| uint32_t | addRectangle (glm::vec2 position, float width, float height, glm::vec3 color) |
| Add Rectangle method. | |
| uint32_t | addTriangle (std::array< glm::vec2, 3 > positions, glm::vec3 color) |
| Add Triangle method. | |
| void | removeFigure (uint32_t index) |
| Remove Figure method. | |
| void | setTransform (uint32_t index, const glm::mat4 &transform) |
| Set transform matrix for figure. | |
| void | setCamera (glm::vec2 position, float zoom) |
| Set camera method. | |
| TextureDescriptor | addTexture (const std::string &path) |
| Loading texture method. | |
| void | setTexture (uint32_t figureIndex, TextureDescriptor textureDescriptor, const std::vector< glm::vec2 > &texCoords) |
| Set Texture method. | |
| void | startGraphicThread () |
| Starting graphics thread method. | |
| void | stopGraphicThread () |
| Stopping graphics thread method. | |
Private Member Functions | |
| void | run () |
| void | initWindow () |
| void | initVulkan () |
| void | createSurface () |
| void | mainLoop () |
| void | _addRectangle (glm::vec2 position, float width, float height, glm::vec3 color, uint32_t index) |
| void | _addTriangle (std::array< glm::vec2, 3 > positions, glm::vec3 color, uint32_t index) |
| void | _removeFigure (uint32_t index) |
| void | _setTranform (uint32_t index, glm::mat4 transform) |
| void | _setCamera (glm::vec2 position, float zoom) |
| void | _setTexture (uint32_t figureIndex, TextureDescriptor textureDescriptor, std::vector< glm::vec2 > texCoords) |
| void | addDefaultTexture () |
| void | pollRenderQueue () |
| void | drawFrame () |
| void | cleanup () |
| bool | checkExtensionsSupport (const uint32_t extCount, const char **extToCheck) |
| void | createLogicalDevice () |
| void | createSwapChain () |
| void | cleanupSwapChain () |
| void | recreateSwapChain () |
| void | createImageViews () |
| void | createRenderPass () |
| void | createDescriptorSetLayout () |
| void | createGraphicsPipeline () |
| void | createFrameBuffers () |
| void | createCommandPool () |
| void | createImage (uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties, VkImage &image, VkDeviceMemory &imageMemory, uint32_t arrayLayers) |
| VkCommandBuffer | beginSingleTimeCommands () |
| void | endSingleTimeCommands (VkCommandBuffer commandBuffer) |
| void | createTextureImage () |
| void | createTextureImageView () |
| VkImageView | createImageView (VkImage image, VkFormat format, uint32_t layerCount, VkImageViewType viewType) |
| void | createTextureSampler () |
| void | transitionImageLayout (VkImage image, VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout, uint32_t layerCount) |
| void | copyBufferToImage (VkBuffer buffer, VkImage image, uint32_t width, uint32_t height, uint32_t layerCount) |
| void | createBuffer (VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer &buffer, VkDeviceMemory &bufferMemory) |
| void | createVertexBuffer () |
| void | createIndexBuffer () |
| void | createUniformBuffers () |
| void | updateUniformBuffer (uint32_t currentImage) |
| void | updateVertexBuffer () |
| void | createDescriptorPool () |
| void | createDescriptorSets () |
| void | copyBuffer (VkBuffer srcBuffer, VkBuffer dstBuffer, VkDeviceSize bufferSize) |
| uint32_t | findMemoryType (uint32_t typeFilter, VkMemoryPropertyFlags properties) |
| void | recordCommandBuffer (VkCommandBuffer commandBuffer, uint32_t imageIndex) |
| void | createCommandBuffers () |
| void | createSyncObjects () |
| VkShaderModule | createShaderModule (const std::vector< char > &code) |
| bool | checkDeviceExtensionSupport (VkPhysicalDevice device) |
| bool | isDeviceSuitable (VkPhysicalDevice device) |
| void | pickPhysicalDevice () |
| QueueFamilyIndicies | findQueueFamilies (VkPhysicalDevice device) |
| SwapChainSupportDetails | querySwapChainSupport (VkPhysicalDevice device) |
| VkSurfaceFormatKHR | chooseSwapSurfaceFormat (const std::vector< VkSurfaceFormatKHR > &availableFormats) |
| VkPresentModeKHR | chooseSwapPresentMode (const std::vector< VkPresentModeKHR > &availablePresentModes) |
| VkExtent2D | chooseSwapExtent (const VkSurfaceCapabilitiesKHR &capabilities) |
| std::vector< const char * > | getRequiredExtensions () |
| void | createInstance () |
| bool | checkValidationLayerSupport () |
| void | populateDebugMessengerCreateInfo (VkDebugUtilsMessengerCreateInfoEXT &createInfo) |
| void | setupDebugMessenger () |
Static Private Member Functions | |
| static VkResult | CreateDebugUtilsMessengerEXT (VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugUtilsMessengerEXT *pDebugMessenger) |
| static void | DestroyDebugUtilsMessengerEXT (VkInstance instance, VkDebugUtilsMessengerEXT debugMessenger, const VkAllocationCallbacks *pAllocator) |
| static std::vector< char > | readFile (const std::string &filename) |
| static void | framebufferSizeCallback (GLFWwindow *window, int width, int height) |
| static VKAPI_ATTR VkBool32 VKAPI_CALL | debugCallback (VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData, void *pUserData) |
Private Attributes | |
| std::mutex | verticesMutex |
| std::mutex | stopMutex |
| std::thread | graphicThread |
| GLFWwindow * | window |
| VkInstance | instance |
| std::vector< VkExtensionProperties > | instanceExtensions |
| VkDebugUtilsMessengerEXT | debugMessenger |
| VkSurfaceKHR | surface |
| VkPhysicalDevice | physicalDevice = VK_NULL_HANDLE |
| VkDevice | device |
| VkQueue | graphicsQueue |
| VkQueue | presentQueue |
| VkSwapchainKHR | swapChain = VK_NULL_HANDLE |
| std::vector< VkImage > | swapChainImages |
| VkFormat | swapChainImageFormat |
| VkExtent2D | swapChainExtent |
| std::vector< VkImageView > | swapChainImageViews |
| VkRenderPass | renderPass |
| VkDescriptorSetLayout | descriptorSetLayout |
| 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 |
| size_t | currentFrame = 0 |
| bool | framebufferResized = false |
| VkBuffer | vertexBuffer |
| VkDeviceMemory | vertexBufferMemory |
| bool | verticesChanged = false |
| VkBuffer | stagingVertexBuffer |
| VkDeviceMemory | stagingVertexBufferMemory |
| VkBuffer | indexBuffer |
| VkDeviceMemory | indexBufferMemory |
| VkBuffer | stagingIndexBuffer |
| VkDeviceMemory | stagingIndexBufferMemory |
| std::vector< VkBuffer > | uniformBuffers |
| std::vector< VkDeviceMemory > | uniformBuffersMemory |
| std::vector< void * > | uniformBuffersMapped |
| VkDescriptorPool | descriptorPool |
| std::vector< VkDescriptorSet > | descriptorSets |
| std::vector< Vertex > | vertices |
| std::vector< uint16_t > | indices |
| std::unordered_map< int, FigureDesc > | figures |
| bool | isStopped = false |
| uint32_t | indicesToDraw = 0 |
| uint32_t | verticesCount = 0 |
| uint32_t | nextFigureHex = 0x0 |
| RenderQueue | renderQueue |
| Camera | camera |
| std::vector< std::string > | texturePaths |
| std::vector< TextureArray > | textureArrays |
Class that implements graphic system.
| GraphicCore::GraphicCore | ( | GLFWwindow * | window | ) |
Object constructor.
| window | : GLFW window pointer for drawing in |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
| uint32_t GraphicCore::addRectangle | ( | glm::vec2 | position, |
| float | width, | ||
| float | height, | ||
| glm::vec3 | color | ||
| ) |
Add Rectangle method.
| position | : glm::vec2, position of upper left vertex |
| width | : float, the rectangle width |
| height | : float, the rectangle height |
| color | : glm::vec3, RGB vector of color, each color from 0.f to 1.f |
| uint32_t | index of added figure |
| TextureDescriptor GraphicCore::addTexture | ( | const std::string & | path | ) |
Loading texture method.
| path | : std::string, absolute path to texture file |
| texture | descriptor that required to set this texture to some figure |
| uint32_t GraphicCore::addTriangle | ( | std::array< glm::vec2, 3 > | positions, |
| glm::vec3 | color | ||
| ) |
Add Triangle method.
| positions | : std::array of size 3 with glm::vec2 positions of vertices that in clockwise(!) order |
| color | : glm::vec3, RGB vector of color, each color from 0.f to 1.f |
| uint32_t index of added figure |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
|
private |
|
private |
| void GraphicCore::removeFigure | ( | uint32_t | index | ) |
Remove Figure method.
| index | : uint32 index of figure to remove |
| None |
|
private |
| void GraphicCore::setCamera | ( | glm::vec2 | position, |
| float | zoom | ||
| ) |
Set camera method.
| position | : glm::vec2, new position of camera |
| zoom | : float, just camera zoom, default is 1.0f |
| None |
| void GraphicCore::setTexture | ( | uint32_t | figureIndex, |
| TextureDescriptor | textureDescriptor, | ||
| const std::vector< glm::vec2 > & | texCoords | ||
| ) |
Set Texture method.
| figureIndex | : uint32_t, index of a figure that gets texture |
| textureDescriptor | : TextureDescriptor of texture to be setted |
| texCoords | : std::vector of glm::vec2 texture coords for every vertex of figure |
| None |
| void GraphicCore::setTransform | ( | uint32_t | index, |
| const glm::mat4 & | transform | ||
| ) |
Set transform matrix for figure.
| index | : uint32 index of figure |
| transform | : glm::mat4, model matrix of object |
| None |
|
private |
| void GraphicCore::startGraphicThread | ( | ) |
Starting graphics thread method.
| None |
| None |
| void GraphicCore::stopGraphicThread | ( | ) |
Stopping graphics thread method.
| None |
| None |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |