Chronos 0.0
A advanced 2D rendering and animation system
Loading...
Searching...
No Matches
Chronos::Engine::ColorBuffer Class Reference

This is a buffer for storing and updating the color of the shape. More...

#include <buffers.hpp>

Inheritance diagram for Chronos::Engine::ColorBuffer:
Collaboration diagram for Chronos::Engine::ColorBuffer:

Public Member Functions

void create (Chronos::Engine::Device device)
 Creates the buffer and maps the memory.
 
void update (glm::vec3 color)
 Updates the buffer with the new color.
 
- Public Member Functions inherited from Chronos::Engine::Buffer
void create (Chronos::Engine::Device device, VkBufferUsageFlags flags, VkMemoryPropertyFlags properties)
 This is used to initialize the buffer.
 
void copy (void *data, VkCommandPool commandPool)
 Copies the data to the buffer.
 
void destroy ()
 Destroys the buffer and frees the memory.
 

Private Attributes

void * data
 

Additional Inherited Members

- Public Attributes inherited from Chronos::Engine::Buffer
VkBuffer buffer
 The buffer.
 
VkDeviceSize size
 The size of the buffer.
 
VkDeviceMemory memory
 The device memory of the buffer.
 

Detailed Description

This is a buffer for storing and updating the color of the shape.

It is used to store the color of the shape and update it on the fly.

Definition at line 149 of file buffers.hpp.

Member Function Documentation

◆ create()

void Chronos::Engine::ColorBuffer::create ( Chronos::Engine::Device  device)

Creates the buffer and maps the memory.

It uses the inherited function create to create the buffer

Parameters
deviceThe device on which the buffer should be stored.

Definition at line 105 of file buffers.cpp.

106{
107 size = sizeof(UniformColorBufferObject);
108 Buffer::create(device, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
109 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
110 | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); // want to be visible to
111 // host and device
112 vkMapMemory(device.device, memory, 0, size, 0, &data);
113 LOG(3,
114 "Color buffer object created for buffer ["
115 + std::to_string((uint64_t)buffer) + "]")
116}
VkBuffer buffer
The buffer.
Definition buffers.hpp:78
VkDeviceSize size
The size of the buffer.
Definition buffers.hpp:83
void create(Chronos::Engine::Device device, VkBufferUsageFlags flags, VkMemoryPropertyFlags properties)
This is used to initialize the buffer.
Definition buffers.cpp:27
VkDeviceMemory memory
The device memory of the buffer.
Definition buffers.hpp:88
Chronos::Engine::Device device
The device on which the buffer is stored.
Definition buffers.hpp:94
VkDevice device
This is the logical device that is used by Vulkan.
Definition device.hpp:52
#define LOG(LEVEL, MESSAGE)
Definition logging.hpp:60

References Chronos::Engine::Buffer::create(), Chronos::Engine::Device::device, and LOG.

Here is the call graph for this function:

◆ update()

void Chronos::Engine::ColorBuffer::update ( glm::vec3  color)

Updates the buffer with the new color.

Parameters
colorThe new color of the shape.

Definition at line 118 of file buffers.cpp.

119{
120 // copy the color to the buffer
121 UniformColorBufferObject ubo {};
122 ubo.color = color;
123 memcpy(data, &ubo, sizeof(ubo));
124 LOG(4,
125 "Color buffer object updated for buffer ["
126 + std::to_string((uint64_t)buffer) + "]")
127}

References Chronos::Engine::UniformColorBufferObject::color, and LOG.

Member Data Documentation

◆ data

void* Chronos::Engine::ColorBuffer::data
private

Definition at line 169 of file buffers.hpp.


The documentation for this class was generated from the following files: