From b23cf06f1c96cb7f18ec46a25da5651bda8e587d Mon Sep 17 00:00:00 2001 From: Kelsi Date: Mon, 9 Mar 2026 16:07:08 -0700 Subject: [PATCH] Remove dead legacy GL Texture class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit texture.hpp / texture.cpp implemented an unfinished OpenGL texture loader (loadFromFile was a TODO stub) that had no callers — the project's texture loading is entirely handled by VkTexture (vk_texture.hpp/cpp) after the Vulkan migration. Remove both files and their CMakeLists entries. --- CMakeLists.txt | 2 - include/rendering/texture.hpp | 38 ------------------- src/rendering/texture.cpp | 69 ----------------------------------- 3 files changed, 109 deletions(-) delete mode 100644 include/rendering/texture.hpp delete mode 100644 src/rendering/texture.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ffdbd5e..54f39283 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -506,7 +506,6 @@ set(WOWEE_SOURCES src/rendering/renderer.cpp src/rendering/amd_fsr3_runtime.cpp src/rendering/shader.cpp - src/rendering/texture.cpp src/rendering/mesh.cpp src/rendering/camera.cpp src/rendering/camera_controller.cpp @@ -620,7 +619,6 @@ set(WOWEE_HEADERS include/rendering/vk_render_target.hpp include/rendering/renderer.hpp include/rendering/shader.hpp - include/rendering/texture.hpp include/rendering/mesh.hpp include/rendering/camera.hpp include/rendering/camera_controller.hpp diff --git a/include/rendering/texture.hpp b/include/rendering/texture.hpp deleted file mode 100644 index 5baf32a4..00000000 --- a/include/rendering/texture.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include -#include - -namespace wowee { -namespace rendering { - -class Texture { -public: - Texture() = default; - ~Texture(); - - bool loadFromFile(const std::string& path); - bool loadFromMemory(const unsigned char* data, int width, int height, int channels); - - void bind(GLuint unit = 0) const; - void unbind() const; - - GLuint getID() const { return textureID; } - int getWidth() const { return width; } - int getHeight() const { return height; } - -private: - GLuint textureID = 0; - int width = 0; - int height = 0; -}; - -/** - * Apply anisotropic filtering to the currently bound GL_TEXTURE_2D. - * Queries the driver maximum once and caches it. No-op if the extension - * is not available. - */ -void applyAnisotropicFiltering(); - -} // namespace rendering -} // namespace wowee diff --git a/src/rendering/texture.cpp b/src/rendering/texture.cpp deleted file mode 100644 index 769ba36e..00000000 --- a/src/rendering/texture.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "rendering/texture.hpp" -#include "core/logger.hpp" - -// Stub implementation - would use stb_image or similar -namespace wowee { -namespace rendering { - -Texture::~Texture() { - if (textureID) { - glDeleteTextures(1, &textureID); - } -} - -bool Texture::loadFromFile(const std::string& path) { - // TODO: Implement with stb_image or BLP loader - LOG_WARNING("Texture loading not yet implemented: ", path); - return false; -} - -bool Texture::loadFromMemory(const unsigned char* data, int w, int h, int channels) { - width = w; - height = h; - - glGenTextures(1, &textureID); - glBindTexture(GL_TEXTURE_2D, textureID); - - GLenum format = (channels == 4) ? GL_RGBA : GL_RGB; - glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - glGenerateMipmap(GL_TEXTURE_2D); - applyAnisotropicFiltering(); - glBindTexture(GL_TEXTURE_2D, 0); - - return true; -} - -void Texture::bind(GLuint unit) const { - glActiveTexture(GL_TEXTURE0 + unit); - glBindTexture(GL_TEXTURE_2D, textureID); -} - -void Texture::unbind() const { - glBindTexture(GL_TEXTURE_2D, 0); -} - -void applyAnisotropicFiltering() { - static float maxAniso = -1.0f; - if (maxAniso < 0.0f) { - if (GLEW_EXT_texture_filter_anisotropic) { - glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAniso); - if (maxAniso < 1.0f) maxAniso = 1.0f; - } else { - maxAniso = 0.0f; // Extension not available - } - } - if (maxAniso > 0.0f) { - float desired = 16.0f; - float clamped = (desired < maxAniso) ? desired : maxAniso; - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, clamped); - } -} - -} // namespace rendering -} // namespace wowee