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:
zhenyan121
2026-07-10 14:51:43 +08:00
committed by GitHub
parent b1341d7da4
commit 913809a5f0
33 changed files with 2263 additions and 1547 deletions

View File

@@ -650,14 +650,23 @@ void DevPanel::show_items_tab_item() {
if (ImGui::BeginTabItem("item")) {
ImGui::Text("Place Block ");
ImGui::SameLine();
ImGui::Image(static_cast<ImTextureID>(static_cast<intptr_t>(
textures[m_player->place_block()])),
ImVec2{48, 48});
auto& place_texture = textures[m_player->place_block()];
if (place_texture) {
ImGui::Image(static_cast<ImTextureID>(
static_cast<intptr_t>(place_texture->id())),
ImVec2{48, 48});
}
for (size_t i = 1; i < textures.size(); i++) {
if (ImGui::ImageButton(("##item" + std::to_string(i)).c_str(),
static_cast<ImTextureID>(
static_cast<intptr_t>(textures[i])),
ImVec2{48, 48})) {
auto& item_texture = textures[i];
if (!item_texture) {
continue;
}
if (ImGui::ImageButton(
("##item" + std::to_string(i)).c_str(),
static_cast<ImTextureID>(
static_cast<intptr_t>(item_texture->id())),
ImVec2{48, 48})) {
m_player->set_place_block(i);
}
if (ImGui::IsItemHovered()) {