- fixed layer creation.

This commit is contained in:
Christoph Oelckers 2018-12-12 20:07:46 +01:00
parent 173b8beb33
commit 7ea1e8acee
2 changed files with 21 additions and 16 deletions

View file

@ -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;
FTexture *layer = i == 0 ? tex : mTextureLayers[i - 1];
if (pLayer) *pLayer = layer;
auto hwtex = tex->SystemTextures.GetHardwareTexture(translation, mExpanded);
if (layer && layer->UseType!=ETextureType::Null)
{
IHardwareTexture *hwtex = layer->SystemTextures.GetHardwareTexture(0, mExpanded);
if (hwtex == nullptr)
{
hwtex = screen->CreateHardwareTexture();
// Fixme: This needs to create the texture here and not implicitly in BindOrCreate!
tex->SystemTextures.AddHardwareTexture(translation, mExpanded, hwtex);
layer->SystemTextures.AddHardwareTexture(0, mExpanded, hwtex);
hwtex = tex->SystemTextures.GetHardwareTexture(0, mExpanded);
}
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;
}

View file

@ -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.
}
//==========================================================================