From 7ea1e8acee344559542b78fb165d056982d07c02 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 12 Dec 2018 20:07:46 +0100 Subject: [PATCH] - fixed layer creation. --- src/hwrenderer/textures/hw_material.cpp | 30 ++++++++++++++----------- src/textures/texturemanager.cpp | 7 +++--- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/hwrenderer/textures/hw_material.cpp b/src/hwrenderer/textures/hw_material.cpp index 13cd9298e..b33efc190 100644 --- a/src/hwrenderer/textures/hw_material.cpp +++ b/src/hwrenderer/textures/hw_material.cpp @@ -404,17 +404,21 @@ outl: IHardwareTexture *FMaterial::GetLayer(int i, int translation, FTexture **pLayer) { - FTexture *texture = i == 0 ? tex : mTextureLayers[i - 1]; - if (pLayer) *pLayer = tex; - - auto hwtex = tex->SystemTextures.GetHardwareTexture(translation, mExpanded); - if (hwtex == nullptr) + FTexture *layer = i == 0 ? tex : mTextureLayers[i - 1]; + if (pLayer) *pLayer = layer; + + if (layer && layer->UseType!=ETextureType::Null) { - hwtex = screen->CreateHardwareTexture(); - // Fixme: This needs to create the texture here and not implicitly in BindOrCreate! - tex->SystemTextures.AddHardwareTexture(translation, mExpanded, hwtex); + IHardwareTexture *hwtex = layer->SystemTextures.GetHardwareTexture(0, mExpanded); + if (hwtex == nullptr) + { + hwtex = screen->CreateHardwareTexture(); + layer->SystemTextures.AddHardwareTexture(0, mExpanded, hwtex); + hwtex = tex->SystemTextures.GetHardwareTexture(0, mExpanded); + } + return hwtex; } - return hwtex; + return nullptr; } //=========================================================================== @@ -473,8 +477,8 @@ again: { if (tex->bNoExpand) expand = false; - FMaterial *gltex = tex->Material[expand]; - if (gltex == NULL && create) + FMaterial *hwtex = tex->Material[expand]; + if (hwtex == NULL && create) { if (expand) { @@ -493,9 +497,9 @@ again: goto again; } } - gltex = new FMaterial(tex, expand); + hwtex = new FMaterial(tex, expand); } - return gltex; + return hwtex; } return NULL; } diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index bb2fe50f2..799edb4aa 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -54,6 +54,7 @@ #include "vm.h" #include "image.h" #include "formats/multipatchtexture.h" +#include "swrenderer/textures/r_swtexture.h" FTextureManager TexMan; @@ -159,11 +160,11 @@ void FTextureManager::FlushAll() { for (int j = 0; j < 2; j++) { - TexMan.ByIndex(i)->SystemTextures.Clean(true, true); - delete TexMan.ByIndex(i)->SoftwareTexture; + Textures[i].Texture->SystemTextures.Clean(true, true); + delete Textures[i].Texture->SoftwareTexture; + Textures[i].Texture->SoftwareTexture = nullptr; } } - // This must also delete the software renderer's canvas. } //==========================================================================