- minor cleanup and allow FHardwareTexture to restore the old bindings after creating a texture.

This commit is contained in:
Christoph Oelckers 2018-12-11 19:56:23 +01:00
parent 5666e4c805
commit 86d851bc5c
4 changed files with 11 additions and 5 deletions

View File

@ -99,10 +99,14 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
TranslatedTexture * glTex=GetTexID(translation);
bool firstCall = glTex->glTexID == 0;
if (firstCall) glGenTextures(1,&glTex->glTexID);
if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit);
unsigned textureBinding = UINT_MAX;
if (texunit == -1) glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding);
if (texunit > 0) glActiveTexture(GL_TEXTURE0+texunit);
if (texunit >= 0) lastbound[texunit] = glTex->glTexID;
glBindTexture(GL_TEXTURE_2D, glTex->glTexID);
FGLDebug::LabelObject(GL_TEXTURE, glTex->glTexID, name);
lastbound[texunit] = glTex->glTexID;
rw = GetTexDimension(w);
rh = GetTexDimension(h);
@ -168,7 +172,8 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
glTex->mipmapped = true;
}
if (texunit != 0) glActiveTexture(GL_TEXTURE0);
if (texunit > 0) glActiveTexture(GL_TEXTURE0);
else if (texunit == -1) glBindTexture(GL_TEXTURE_2D, textureBinding);
return glTex->glTexID;
}

View File

@ -140,7 +140,7 @@ IHardwareTexture * FMaterial::ValidateSysTexture(FTexture * tex, bool expand)
IHardwareTexture *gltex = tex->SystemTexture[expand];
if (gltex == nullptr)
{
gltex = tex->SystemTexture[expand] = screen->CreateHardwareTexture(tex);
gltex = tex->SystemTexture[expand] = screen->CreateHardwareTexture();
}
return gltex;
}

View File

@ -774,7 +774,7 @@ FWrapperTexture::FWrapperTexture(int w, int h, int bits)
Format = bits;
UseType = ETextureType::SWCanvas;
bNoCompress = true;
SystemTexture[0] = screen->CreateHardwareTexture(this);
SystemTexture[0] = screen->CreateHardwareTexture();
}
//===========================================================================

View File

@ -42,6 +42,7 @@
#include "colormatcher.h"
#include "r_data/renderstyle.h"
#include "r_data/r_translate.h"
#include "hwrenderer/textures/hw_texmanager.h"
#include <vector>
// 15 because 0th texture is our texture