Files
Cubed/include/Cubed/texture_manager.hpp
zhenyan121 5901ab7cd9 feat: grass (#11)
* feat: add grass texture and update grass_block texture

* feat: add block data

* feat: add blocks_tool

* feat: add sync info and change function in blocks_tools

* feat: add check and new function

* refactor: make block texture loading data-driven

* feat: add rendering for grass

* feat: passable grass

* feat: random grass place

* fix: memory leak in TextureManager::load_cross_plane_texture
2026-05-28 21:34:36 +08:00

48 lines
1.2 KiB
C++

#pragma once
#include "Cubed/gameplay/block.hpp"
#include <glad/glad.h>
namespace Cubed {
class TextureManager {
private:
bool m_need_reload = false;
GLuint m_block_status_array = 0;
GLuint m_texture_array = 0;
GLuint m_cross_plane_array = 0;
GLuint m_ui_array = 0;
GLfloat m_max_aniso = 0.0f;
int m_aniso = 1;
std::vector<GLuint> m_item_textures;
void load_block_status(unsigned status_id);
void load_block_texture(unsigned block_id);
void load_block_item_texture(unsigned id);
void load_cross_plane_texture(unsigned id);
void load_ui_texture(unsigned id);
void init_item();
void init_block();
void init_ui();
void init_block_status();
public:
TextureManager();
~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;
const std::vector<GLuint>& item_textures() const;
// Must call after MapTable::init_map() and glfwMakeContextCurrent(window);
void init_texture();
void hot_reload();
void need_reload();
void update();
int max_aniso() const;
};
} // namespace Cubed