mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
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.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "Cubed/constants.hpp"
|
||||
#include "Cubed/primitive_data.hpp"
|
||||
#include "Cubed/render/player_renderer.hpp"
|
||||
#include "Cubed/render/texture.hpp"
|
||||
#include "Cubed/render/vertex_array.hpp"
|
||||
#include "Cubed/render/vertex_buffer.hpp"
|
||||
#include "Cubed/shader.hpp"
|
||||
@@ -137,16 +138,16 @@ private:
|
||||
std::unique_ptr<VertexBuffer> m_quad_vbo = 0;
|
||||
|
||||
GLuint m_fbo = 0;
|
||||
GLuint m_screen_texture = 0;
|
||||
GLuint m_screen_depth_texture = 0;
|
||||
std::unique_ptr<Texture> m_screen_texture;
|
||||
std::unique_ptr<Texture> m_screen_depth_texture;
|
||||
|
||||
GLuint m_oit_fbo = 0;
|
||||
GLuint m_accum_texture = 0;
|
||||
GLuint m_reveal_texture = 0;
|
||||
GLuint m_oit_depth_texture = 0;
|
||||
std::unique_ptr<Texture> m_accum_texture;
|
||||
std::unique_ptr<Texture> m_reveal_texture;
|
||||
std::unique_ptr<Texture> m_oit_depth_texture;
|
||||
|
||||
GLuint m_depth_map_fbo = 0;
|
||||
GLuint m_depth_map_texture = 0;
|
||||
std::unique_ptr<Texture> m_depth_map_texture;
|
||||
|
||||
glm::mat4 m_ui_proj;
|
||||
glm::mat4 m_ui_m_matrix;
|
||||
|
||||
@@ -32,8 +32,10 @@ enum TextureFormat : GLenum {
|
||||
DEPTH_COMPONENT32F = GL_DEPTH_COMPONENT32F,
|
||||
DEPTH_COMPONENT = GL_DEPTH_COMPONENT,
|
||||
R16F = GL_R16F,
|
||||
RGBA16F = GL_RGBA16F,
|
||||
RED = GL_RED,
|
||||
RGBA = GL_RGBA,
|
||||
RGB = GL_RGB,
|
||||
RGBA8 = GL_RGBA8,
|
||||
|
||||
};
|
||||
|
||||
@@ -40,13 +40,13 @@ public:
|
||||
~TextureManager();
|
||||
|
||||
void delet_texture();
|
||||
GLuint get_block_status_array() const;
|
||||
GLuint get_texture_array() const;
|
||||
GLuint get_cross_plane_array() const;
|
||||
GLuint get_ui_array() const;
|
||||
GLuint get_pbr_texture() const;
|
||||
const Texture* get_block_status_array() const;
|
||||
const Texture* get_texture_array() const;
|
||||
const Texture* get_cross_plane_array() const;
|
||||
const Texture* get_ui_array() const;
|
||||
const Texture* get_pbr_texture() const;
|
||||
const std::vector<std::unique_ptr<Texture>>& item_textures() const;
|
||||
GLuint get_skin() const;
|
||||
const Texture* get_skin() const;
|
||||
// Must call after MapTable::init_map() and glfwMakeContextCurrent(window);
|
||||
void init_texture();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user