Chronos 0.0
A advanced 2D rendering and animation system
Loading...
Searching...
No Matches
buffers.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
23#pragma once
29#include "device.hpp"
30namespace Chronos {
31namespace Engine {
32
39 class Buffer {
40 public:
55 void create(Chronos::Engine::Device device, VkBufferUsageFlags flags,
56 VkMemoryPropertyFlags properties);
57
68 void copy(void* data, VkCommandPool commandPool);
69
73 void destroy();
74
78 VkBuffer buffer;
79
83 VkDeviceSize size;
84
88 VkDeviceMemory memory;
89
90 private:
95 };
96
104 class UniformBuffer : public Buffer {
105 public:
115
133 void update(VkExtent2D swapChainExtent, float x, float y,
134 float rotation, float x_size, float y_size);
135
136 private:
141 void* data;
142 };
143
149 class ColorBuffer : public Buffer {
150 public:
160
166 void update(glm::vec3 color);
167
168 private:
169 void* data;
170 };
171}; // namespace Engine
172}; // namespace Chronos
Used to store buffers in GPU.
Definition buffers.hpp:39
VkBuffer buffer
The buffer.
Definition buffers.hpp:78
VkDeviceSize size
The size of the buffer.
Definition buffers.hpp:83
void destroy()
Destroys the buffer and frees the memory.
Definition buffers.cpp:63
void copy(void *data, VkCommandPool commandPool)
Copies the data to the buffer.
Definition buffers.cpp:39
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
This is a buffer for storing and updating the color of the shape.
Definition buffers.hpp:149
void update(glm::vec3 color)
Updates the buffer with the new color.
Definition buffers.cpp:118
void create(Chronos::Engine::Device device)
Creates the buffer and maps the memory.
Definition buffers.cpp:105
This initializes, manages and destroys the logical and physical devices(GPU).
Definition device.hpp:47
This is a Uniform buffer for storing the uniform variables in the shaders.
Definition buffers.hpp:104
void * data
Temporary storage used to store the data before copying to the buffer.
Definition buffers.hpp:141
void update(VkExtent2D swapChainExtent, float x, float y, float rotation, float x_size, float y_size)
Updates the buffer with the given information.
Definition buffers.cpp:83
void create(Chronos::Engine::Device device)
Creates the buffer and maps the memory.
Definition buffers.cpp:73
Contains the Device class.