Chronos 0.0
A advanced 2D rendering and animation system
|
Abstract class for creating and managing generic graphical objects. More...
#include <object.hpp>
Public Member Functions | |
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. | |
virtual void | update (uint32_t currentFrame)=0 |
Updates the object for the current frame. | |
virtual void | render (uint32_t currentFrame, uint32_t imageIndex, float bgColor[3], VkViewport &viewport, VkRect2D &scissor, std::vector< VkCommandBuffer > &commandBuffers)=0 |
virtual void | destroy ()=0 |
Destroys the object and releases associated resources. | |
void | recreateGraphicsPipeline () |
Recreates the graphics pipeline for the object. | |
Public Attributes | |
VkPipeline | graphicsPipeline |
VkPipelineLayout | pipelineLayout |
std::vector< VkDescriptorSet > | descriptorSets |
Chronos::Engine::ObjectType | objectType |
Protected Member Functions | |
void | createGraphicsPipeline () |
Creates the graphics pipeline for the object. | |
void | createDescriptorPool () |
Creates the Vulkan descriptor pool for the object. | |
void | createDescriptorSetLayout () |
Creates the Vulkan descriptor set layout for the object. | |
virtual void | createDescriptorSets ()=0 |
virtual std::vector< VkDescriptorType > | getDescriptorTypes ()=0 |
virtual std::vector< VkShaderStageFlagBits > | getDescriptorStages ()=0 |
virtual PipelineAttributes | getPipelineAttributes ()=0 |
Protected Attributes | |
Chronos::Engine::Device * | device |
Chronos::Engine::SwapChain * | swapChain |
VkCommandPool | commandPool |
VkSampler | textureSampler |
VkRenderPass * | renderPass |
VkDescriptorSetLayout | descriptorSetLayout |
VkDescriptorPool | descriptorPool |
std::vector< Chronos::Engine::UniformBuffer > | uniformBuffers |
Private Attributes | |
unsigned char * | vertShaderCode |
int | vertShaderCodeSize |
unsigned char * | fragShaderCode |
int | fragShaderCodeSize |
Abstract class for creating and managing generic graphical objects.
The Object class provides an interface for creating and managing generic graphical objects. Derived classes are expected to implement specific functionality for initialization, updates, and destruction of the object depending on specific use case.
Definition at line 66 of file object.hpp.
|
protected |
Creates the Vulkan descriptor pool for the object.
This method sets up and creates the Vulkan descriptor pool based on the descriptor types used by the object.
Definition at line 246 of file object.cpp.
References MAX_FRAMES_IN_FLIGHT.
|
protected |
Creates the Vulkan descriptor set layout for the object.
This method sets up and creates the Vulkan descriptor set layout based on the descriptor types and stages used by the object.
Definition at line 269 of file object.cpp.
|
protectedpure virtual |
Implemented in Chronos::Engine::ColoredRectangle, Chronos::Engine::TexturedRectangle, and Chronos::Engine::Text.
|
protected |
Creates the graphics pipeline for the object.
This method is responsible for configuring and creating the Vulkan graphics pipeline used by the object, including shader modules, vertex input, input assembly, viewport, rasterization, multisampling, color blending, and dynamic states.
Definition at line 80 of file object.cpp.
References Chronos::Engine::PipelineAttributes::attributeDescriptions, Chronos::Engine::PipelineAttributes::bindingDescriptions, Chronos::Engine::PipelineAttributes::colorBlendAttachment, createShaderModule(), Chronos::Engine::PipelineAttributes::frontFace, and Chronos::Engine::PipelineAttributes::topology.
|
pure virtual |
Destroys the object and releases associated resources.
This method is responsible for cleaning up the object's resources, including uniform buffers, descriptor pool, descriptor set layout, graphics pipeline, and pipeline layout.
Implemented in Chronos::Engine::ColoredRectangle, Chronos::Engine::TexturedRectangle, and Chronos::Engine::Text.
Definition at line 235 of file object.cpp.
References MAX_FRAMES_IN_FLIGHT.
|
protectedpure virtual |
Implemented in Chronos::Engine::ColoredRectangle, Chronos::Engine::TexturedRectangle, and Chronos::Engine::Text.
|
protectedpure virtual |
Implemented in Chronos::Engine::ColoredRectangle, Chronos::Engine::TexturedRectangle, and Chronos::Engine::Text.
|
protectedpure virtual |
Implemented in Chronos::Engine::ColoredRectangle, Chronos::Engine::TexturedRectangle, and Chronos::Engine::Text.
void Chronos::Engine::Object::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.
This method initializes the Object with necessary Vulkan-related parameters, such as the device, command pool, swap chain, texture sampler, and render pass. It also allocates uniform buffers and creates descriptor sets, descriptor pool, descriptor set layout, and the graphics pipeline for rendering the object.
device | The device used by the object. |
commandPool | Vulkan command pool for the object. |
swapChain | Swap chain used by the object. |
textureSampler | Vulkan texture sampler used by the object. |
renderPass | Vulkan render pass that is used for rendering |
objectType | Type of the object. |
vertShaderCode | Vertex shader code in binary format. |
vertShaderCodeSize | Size of the vertex shader code. |
fragShaderCode | Fragment shader code in binary format. |
fragShaderCodeSize | Size of the fragment shader code. object in question. |
Definition at line 53 of file object.cpp.
References commandPool, Chronos::Engine::SwapChain::create(), createDescriptorPool(), createDescriptorSetLayout(), createDescriptorSets(), createGraphicsPipeline(), device, fragShaderCode, fragShaderCodeSize, MAX_FRAMES_IN_FLIGHT, objectType, renderPass, swapChain, textureSampler, uniformBuffers, vertShaderCode, and vertShaderCodeSize.
void Chronos::Engine::Object::recreateGraphicsPipeline | ( | ) |
Recreates the graphics pipeline for the object.
This method is used to recreate the graphics pipeline when needed, typically after changes in the rendering configuration such as MSAA changes. It destroys the existing graphics pipeline and pipeline layout before creating a new one.
Definition at line 302 of file object.cpp.
|
pure virtual |
Implemented in Chronos::Engine::ColoredRectangle, Chronos::Engine::TexturedRectangle, and Chronos::Engine::Text.
|
pure virtual |
Updates the object for the current frame.
This pure virtual method must be implemented by derived classes to perform any updates required for the object during each frame. The currentFrame
parameter represents the index of the current frame in the application.
currentFrame | Index of the current frame. |
Implemented in Chronos::Engine::ColoredRectangle, Chronos::Engine::TexturedRectangle, and Chronos::Engine::Text.
|
protected |
Vulkan command pool associated with the object.
Definition at line 143 of file object.hpp.
|
protected |
Vulkan descriptor pool used by the object.
Definition at line 152 of file object.hpp.
|
protected |
Vulkan descriptor set layout used by the object.
Definition at line 149 of file object.hpp.
std::vector<VkDescriptorSet> Chronos::Engine::Object::descriptorSets |
Vulkan descriptor sets associated with the object.
Definition at line 135 of file object.hpp.
|
protected |
Device to render to.
Definition at line 140 of file object.hpp.
|
private |
Fragment shader code.
Definition at line 187 of file object.hpp.
|
private |
Size of the fragment shader code.
Definition at line 188 of file object.hpp.
VkPipeline Chronos::Engine::Object::graphicsPipeline |
Vulkan graphics pipeline used by the object.
Definition at line 130 of file object.hpp.
Chronos::Engine::ObjectType Chronos::Engine::Object::objectType |
Type of the object.
Definition at line 137 of file object.hpp.
VkPipelineLayout Chronos::Engine::Object::pipelineLayout |
Vulkan pipeline layout used by the object.
Definition at line 133 of file object.hpp.
|
protected |
Renderpass that the object will render to.
Definition at line 147 of file object.hpp.
|
protected |
Swapchain to present to.
Definition at line 141 of file object.hpp.
|
protected |
Vulkan texture sampler used by the object.
Definition at line 145 of file object.hpp.
|
protected |
uniform buffers associated with the object.
Definition at line 183 of file object.hpp.
|
private |
Vertex shader code.
Definition at line 185 of file object.hpp.
|
private |
Size of the vertex shader code.
Definition at line 186 of file object.hpp.