Fixed texture freeing. Destructor was never called because base destructors weren't virtual.

This commit is contained in:
2016-03-12 17:45:43 +01:00
parent 068e151741
commit ce0d3b9fbe
7 changed files with 16 additions and 13 deletions
+8 -8
View File
@@ -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<Texture>(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<PNG>(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);
+2 -1
View File
@@ -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()