diff --git a/include/Engine/Core/ResourceManager.h b/include/Engine/Core/ResourceManager.h index b994b5cf..cf569260 100644 --- a/include/Engine/Core/ResourceManager.h +++ b/include/Engine/Core/ResourceManager.h @@ -19,6 +19,7 @@ class Resource protected: Resource() { } + virtual ~Resource() = default; public: //Should be thrown in a Resource's constructor if it cannot complete because another resource is still loading. diff --git a/include/Engine/Rendering/CubeMapPass.h b/include/Engine/Rendering/CubeMapPass.h index 02e8e7ba..54bea377 100644 --- a/include/Engine/Rendering/CubeMapPass.h +++ b/include/Engine/Rendering/CubeMapPass.h @@ -3,6 +3,7 @@ #include "IRenderer.h" #include "ShaderProgram.h" +#include "PNG.h" class CubeMapPass { @@ -21,7 +22,7 @@ private: IRenderer* m_Renderer; std::string m_PreviusCubeMapTexture; - std::vector m_CubeMapTextures; + std::vector m_CubeMapTextures; }; #endif \ No newline at end of file diff --git a/include/Engine/Rendering/Image.h b/include/Engine/Rendering/Image.h index 19ef43c1..102521ed 100644 --- a/include/Engine/Rendering/Image.h +++ b/include/Engine/Rendering/Image.h @@ -3,6 +3,8 @@ struct Image { + virtual ~Image() = default; + enum class ImageFormat { Unknown, diff --git a/include/Engine/Rendering/TextureSprite.h b/include/Engine/Rendering/TextureSprite.h index f8527664..84998a7b 100644 --- a/include/Engine/Rendering/TextureSprite.h +++ b/include/Engine/Rendering/TextureSprite.h @@ -14,8 +14,6 @@ protected: TextureSprite(std::string path); public: - ~TextureSprite(); - void Bind(GLenum textureUnit = GL_TEXTURE0); GLuint m_Texture = 0; diff --git a/src/Engine/Rendering/CubeMapPass.cpp b/src/Engine/Rendering/CubeMapPass.cpp index e2a55b74..8d133579 100644 --- a/src/Engine/Rendering/CubeMapPass.cpp +++ b/src/Engine/Rendering/CubeMapPass.cpp @@ -6,18 +6,16 @@ CubeMapPass::CubeMapPass(IRenderer* renderer) LoadTextures("Nevada"); } -void CubeMapPass::LoadTextures(std::string input) +void CubeMapPass::LoadTextures(std::string cubemapName) { - if (m_PreviusCubeMapTexture != input) { + if (m_PreviusCubeMapTexture != cubemapName) { m_CubeMapTextures.clear(); for (int i = 0; i < 6; i++) { - std::string str; - str = "Textures/Test/CubeMap/" + input + "/CubeMapTest0" + std::to_string(i) + ".png"; - Texture* img = ResourceManager::Load(str); - m_CubeMapTextures.push_back(img); + std::string path = "Textures/Test/CubeMap/" + cubemapName + "/CubeMapTest0" + std::to_string(i) + ".png"; + m_CubeMapTextures.push_back(path); } GenerateCubeMapTexture(); - m_PreviusCubeMapTexture = input; + m_PreviusCubeMapTexture = cubemapName; } } @@ -29,7 +27,9 @@ void CubeMapPass::GenerateCubeMapTexture() glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapTexture); for (int i = 0; i < 6; i++) { - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, m_CubeMapTextures[0]->Width, m_CubeMapTextures[0]->Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_CubeMapTextures[i]->Data); + PNG* img = ResourceManager::Load(m_CubeMapTextures[i]); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, img->Width, img->Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, img->Data); + ResourceManager::Release("PNG", m_CubeMapTextures[i]); } glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); diff --git a/src/Engine/Rendering/Texture.cpp b/src/Engine/Rendering/Texture.cpp index fdf387c2..5ad1cf39 100644 --- a/src/Engine/Rendering/Texture.cpp +++ b/src/Engine/Rendering/Texture.cpp @@ -19,7 +19,6 @@ Texture::Texture(std::string path) } // Construct the OpenGL texture - glGenTextures(1, &m_Texture); glBindTexture(GL_TEXTURE_2D, m_Texture); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -30,6 +29,8 @@ Texture::Texture(std::string path) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); GLERROR("Texture load"); + + ResourceManager::Release("PNG", path); } Texture::~Texture() diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 7b80727e..3d49fad9 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -53,7 +53,7 @@ Game::Game(int argc, char* argv[]) ResourceManager::RegisterType("RawModel"); ResourceManager::RegisterType("Texture"); ResourceManager::RegisterType("TextureSprite"); - ResourceManager::RegisterType("Png"); + ResourceManager::RegisterType("PNG"); ResourceManager::RegisterType("ShaderProgram"); ResourceManager::RegisterType("EntityFile"); ResourceManager::RegisterType("EntityXMLFile");