Chronos 0.0
A advanced 2D rendering and animation system
Loading...
Searching...
No Matches
object.hpp
Go to the documentation of this file.
1/*
2Copyright (c) 2024 Rahul Satish Vadhyar
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in all
12copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20SOFTWARE.
21*/
22
27#pragma once
28#include "swapchain.hpp"
29#include "objectTypes.hpp"
30#include "buffers.hpp"
31namespace Chronos {
32namespace Engine {
33
44 std::vector<VkVertexInputBindingDescription>
46 std::vector<VkVertexInputAttributeDescription>
48 VkPrimitiveTopology
50 VkFrontFace
52 VkPipelineColorBlendAttachmentState
54 };
55
66 class Object {
67
68 public:
91 VkCommandPool commandPool, SwapChain* swapChain, VkSampler textureSampler,
92 VkRenderPass* renderPass, ObjectType objectType, unsigned char* vertShaderCode,
94
105 virtual void update(uint32_t currentFrame) = 0;
106
107 virtual void render(uint32_t currentFrame, uint32_t imageIndex,
108 float bgColor[3], VkViewport& viewport, VkRect2D& scissor,
109 std::vector<VkCommandBuffer>& commandBuffers)
110 = 0;
111
119 virtual void destroy() = 0;
120
130 VkPipeline graphicsPipeline;
132 VkPipelineLayout
134 std::vector<VkDescriptorSet>
139 protected:
142 VkCommandPool
144 VkSampler
146 VkRenderPass*
148 VkDescriptorSetLayout
151 VkDescriptorPool
162
170
178 virtual void createDescriptorSets() = 0;
179 virtual std::vector<VkDescriptorType> getDescriptorTypes() = 0;
180 virtual std::vector<VkShaderStageFlagBits> getDescriptorStages() = 0;
182 std::vector<Chronos::Engine::UniformBuffer>
184 private:
185 unsigned char* vertShaderCode;
187 unsigned char* fragShaderCode;
189 };
190};
191};
Contains the Buffer and UniformBuffer class.
This initializes, manages and destroys the logical and physical devices(GPU).
Definition device.hpp:47
Abstract class for creating and managing generic graphical objects.
Definition object.hpp:66
VkDescriptorSetLayout descriptorSetLayout
Definition object.hpp:149
void createDescriptorPool()
Creates the Vulkan descriptor pool for the object.
Definition object.cpp:246
virtual void render(uint32_t currentFrame, uint32_t imageIndex, float bgColor[3], VkViewport &viewport, VkRect2D &scissor, std::vector< VkCommandBuffer > &commandBuffers)=0
virtual std::vector< VkDescriptorType > getDescriptorTypes()=0
virtual void destroy()=0
Destroys the object and releases associated resources.
Definition object.cpp:235
VkCommandPool commandPool
Definition object.hpp:143
virtual PipelineAttributes getPipelineAttributes()=0
std::vector< VkDescriptorSet > descriptorSets
Definition object.hpp:135
Chronos::Engine::SwapChain * swapChain
Definition object.hpp:141
VkDescriptorPool descriptorPool
Definition object.hpp:152
void recreateGraphicsPipeline()
Recreates the graphics pipeline for the object.
Definition object.cpp:302
unsigned char * vertShaderCode
Definition object.hpp:185
virtual std::vector< VkShaderStageFlagBits > getDescriptorStages()=0
Chronos::Engine::Device * device
Definition object.hpp:140
std::vector< Chronos::Engine::UniformBuffer > uniformBuffers
Definition object.hpp:183
virtual void update(uint32_t currentFrame)=0
Updates the object for the current frame.
Chronos::Engine::ObjectType objectType
Definition object.hpp:137
void createDescriptorSetLayout()
Creates the Vulkan descriptor set layout for the object.
Definition object.cpp:269
void createGraphicsPipeline()
Creates the graphics pipeline for the object.
Definition object.cpp:80
VkPipeline graphicsPipeline
Definition object.hpp:130
void init(Chronos::Engine::Device *device, VkCommandPool commandPool, SwapChain *swapChain, VkSampler textureSampler, VkRenderPass *renderPass, ObjectType objectType, unsigned char *vertShaderCode, int vertShaderCodeSize, unsigned char *fragShaderCode, int fragShaderCodeSize)
Initializes the object.
Definition object.cpp:53
virtual void createDescriptorSets()=0
VkPipelineLayout pipelineLayout
Definition object.hpp:133
VkRenderPass * renderPass
Definition object.hpp:147
unsigned char * fragShaderCode
Definition object.hpp:187
Structure defining attributes required for creating a graphics pipeline.
Definition object.hpp:43
VkPrimitiveTopology topology
Definition object.hpp:49
VkPipelineColorBlendAttachmentState colorBlendAttachment
Definition object.hpp:53
std::vector< VkVertexInputBindingDescription > bindingDescriptions
Definition object.hpp:45
std::vector< VkVertexInputAttributeDescription > attributeDescriptions
Definition object.hpp:47
Contains the swapChain class along with all the swapChain related functions.