feat: add texture hot-reload

This commit is contained in:
2026-04-16 15:33:58 +08:00
parent cf9aaa62a7
commit 7d5b9c34b3
8 changed files with 59 additions and 9 deletions

View File

@@ -29,9 +29,6 @@ private:
Window m_window{m_renderer};
GLuint m_texture_array = 0;
inline static double last_time = glfwGetTime();
inline static double current_time = glfwGetTime();
inline static double delta_time = 0.0f;

View File

@@ -16,9 +16,14 @@ struct MouseState {
bool right = false;
};
struct KeyState {
bool r = false;
};
struct InputState {
MoveState move_state;
MouseState mouse_state;
KeyState key_state;
};
namespace Input {

View File

@@ -6,20 +6,26 @@
class TextureManager {
private:
bool m_need_reload = false;
GLuint m_block_status_array;
GLuint m_texture_array;
GLuint m_ui_array;
void load_block_status(unsigned status_id);
void load_block_texture(unsigned block_id);
void load_ui_texture(unsigned id);
public:
TextureManager();
~TextureManager();
void delet_texture();
GLuint get_block_status_array() const;
GLuint get_texture_array() const;
GLuint get_ui_array() const;
// Must call after MapTable::init_map() and glfwMakeContextCurrent(window);
void init_texture();
void hot_reload();
void need_reload();
void update();
};

View File

@@ -6,12 +6,16 @@ public:
Window(Renderer& renderer);
~Window();
bool is_mouse_enable() const;
const GLFWwindow* get_glfw_window() const;
GLFWwindow* get_glfw_window();
void init();
void update_viewport();
void toggle_fullscreen();
void toggle_mouse_able();
private:
bool m_mouse_enable = false;
float m_aspect;
GLFWwindow* m_window;
int m_width;