still working on code refactoring

This commit is contained in:
2024-04-23 22:59:33 +02:00
parent ace4c98945
commit 1d9a51e4f7
16 changed files with 560 additions and 518 deletions

View File

@@ -6,13 +6,14 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/18 17:14:45 by maldavid #+# #+# */
/* Updated: 2024/03/28 22:36:05 by maldavid ### ########.fr */
/* Updated: 2024/04/23 22:25:13 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __RENDERER__
#define __RENDERER__
#include <Renderer/Vertex.h>
#include <Renderer/Buffers/UniformBuffer.h>
#include <Renderer/Core/Surface.h>
#include <Renderer/Core/RenderCore.h>
@@ -28,47 +29,6 @@
namespace mlx
{
struct Vertex
{
glm::vec2 pos;
glm::vec4 color;
glm::vec2 uv;
Vertex(glm::vec2 _pos, glm::vec4 _color, glm::vec2 _uv) : pos(std::move(_pos)), color(std::move(_color)), uv(std::move(_uv)) {}
static VkVertexInputBindingDescription GetBindingDescription()
{
VkVertexInputBindingDescription binding_description{};
binding_description.binding = 0;
binding_description.stride = sizeof(Vertex);
binding_description.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
return binding_description;
}
static std::array<VkVertexInputAttributeDescription, 3> GetAttributeDescriptions()
{
std::array<VkVertexInputAttributeDescription, 3> attribute_descriptions;
attribute_descriptions[0].binding = 0;
attribute_descriptions[0].location = 0;
attribute_descriptions[0].format = VK_FORMAT_R32G32_SFLOAT;
attribute_descriptions[0].offset = offsetof(Vertex, pos);
attribute_descriptions[1].binding = 0;
attribute_descriptions[1].location = 1;
attribute_descriptions[1].format = VK_FORMAT_R32G32B32A32_SFLOAT;
attribute_descriptions[1].offset = offsetof(Vertex, color);
attribute_descriptions[2].binding = 0;
attribute_descriptions[2].location = 2;
attribute_descriptions[2].format = VK_FORMAT_R32G32_SFLOAT;
attribute_descriptions[2].offset = offsetof(Vertex, uv);
return attribute_descriptions;
}
};
class Renderer
{
public:
@@ -96,8 +56,6 @@ namespace mlx
inline FrameBuffer& GetFrameBuffer(int i) noexcept { return m_framebuffers[i]; }
inline DescriptorSet& GetVertDescriptorSet() noexcept { return m_vert_set; }
inline DescriptorSet& GetFragDescriptorSet() noexcept { return m_frag_set; }
inline DescriptorSetLayout& GetVertDescriptorSetLayout() noexcept { return m_vert_layout; }
inline DescriptorSetLayout& GetFragDescriptorSetLayout() noexcept { return m_frag_layout; }
inline std::uint32_t GetActiveImageIndex() noexcept { return m_current_frame_index; }
inline std::uint32_t GetImageIndex() noexcept { return m_image_index; }
@@ -117,9 +75,6 @@ namespace mlx
std::array<Semaphore, MAX_FRAMES_IN_FLIGHT> m_semaphores;
std::vector<FrameBuffer> m_framebuffers;
DescriptorSetLayout m_vert_layout;
DescriptorSetLayout m_frag_layout;
DescriptorSet m_vert_set;
DescriptorSet m_frag_set;