mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
refactor: renderer (#29)
* refactor(render): move render files to subdirectory, add RAII vertex buffer/array classes * refactor(render): encapsulate OpenGL textures into Texture class * refactor(texture): encapsulate textures with unique_ptr and bind methods Replace raw GLuint framebuffer textures with std::unique_ptr<Texture>. Update TextureManager to return const Texture* instead of GLuint. Use Texture::bind() for active texture binding. Add RGBA16F and RGB formats. Add texture parameter methods. Update destructors accordingly. * refactor(render): use Texture, VertexBuffer, VertexArray classes * feat(render): add FrameBuffer class to encapsulate framebuffer operations * refactor(render): extract world rendering into WorldRenderer class * refactor(render): rename projection and model matrix members for clarity * chore(render): remove unused matrix members * fix(texture-manager): correct delet_texture typo and add null checks for textures
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "Cubed/primitive_data.hpp"
|
||||
#include "Cubed/render/vertex_array.hpp"
|
||||
#include "Cubed/render/vertex_buffer.hpp"
|
||||
#include "Cubed/ui/color.hpp"
|
||||
|
||||
#include <glad/glad.h>
|
||||
@@ -27,8 +29,7 @@ public:
|
||||
Text& text(std::string_view str);
|
||||
|
||||
std::size_t uuid() const;
|
||||
static void set_loc(const Shader& shader);
|
||||
void render();
|
||||
void render(const Shader& shader);
|
||||
|
||||
bool operator==(const Text& other) const;
|
||||
|
||||
@@ -38,14 +39,14 @@ private:
|
||||
|
||||
const std::string NAME;
|
||||
const std::size_t UUID;
|
||||
|
||||
std::string m_text;
|
||||
glm::vec4 m_color{1.0f, 1.0f, 1.0f, 1.0f};
|
||||
glm::mat4 m_model_matrix;
|
||||
|
||||
std::vector<Vertex2D> m_vertices;
|
||||
GLuint m_vbo = 0;
|
||||
static inline GLuint m_color_loc = 0;
|
||||
static inline GLuint m_mv_loc = 0;
|
||||
std::unique_ptr<VertexBuffer> m_vbo;
|
||||
std::unique_ptr<VertexArray> m_vao;
|
||||
|
||||
void update_vertices();
|
||||
void upload_to_gpu();
|
||||
|
||||
Reference in New Issue
Block a user