perf: optmize world rendering performance

This commit is contained in:
2026-03-08 11:27:37 +08:00
parent 668fa9a57d
commit f3ff209823
7 changed files with 149 additions and 113 deletions

View File

@@ -1,24 +1,21 @@
#pragma once
#include <glad/glad.h>
#include <string>
#include <vector>
#include <Cubed/gameplay/block.hpp>
#include <Cubed/tools/shader_tools.hpp>
class TextureManager {
private:
std::vector<BlockTexture> m_block_textures;
GLuint m_texture_array;
void load_block_texture(unsigned block_id);
public:
TextureManager();
~TextureManager();
const BlockTexture& get_block_texture(const std::string& block_name);
const BlockTexture& get_block_texture(unsigned block_id);
void delet_texture();
void load_block_texture(const std::string& block_name);
void load_block_texture(unsigned block_id);
void delet_texture();
GLuint get_texture_array();
// Must call after MapTable::init_map() and glfwMakeContextCurrent(window);
void init_texture();
};

View File

@@ -9,6 +9,7 @@ namespace Shader {
void print_program_info(int prog);
bool check_opengl_error();
std::string read_shader_source(const char* file_path);
GLuint load_texture(const std::string& tex_image_path);
GLuint load_texture(const char* tex_image_path);
void delete_image_data(unsigned char* data);
unsigned char* load_image_data(const std::string& tex_image_path);
}