mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-13 16:07:55 +00:00
- minor cleanup and allow FHardwareTexture to restore the old bindings after creating a texture.
This commit is contained in:
parent
5666e4c805
commit
86d851bc5c
4 changed files with 11 additions and 5 deletions
|
@ -99,10 +99,14 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
|
||||||
TranslatedTexture * glTex=GetTexID(translation);
|
TranslatedTexture * glTex=GetTexID(translation);
|
||||||
bool firstCall = glTex->glTexID == 0;
|
bool firstCall = glTex->glTexID == 0;
|
||||||
if (firstCall) glGenTextures(1,&glTex->glTexID);
|
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);
|
glBindTexture(GL_TEXTURE_2D, glTex->glTexID);
|
||||||
|
|
||||||
FGLDebug::LabelObject(GL_TEXTURE, glTex->glTexID, name);
|
FGLDebug::LabelObject(GL_TEXTURE, glTex->glTexID, name);
|
||||||
lastbound[texunit] = glTex->glTexID;
|
|
||||||
|
|
||||||
rw = GetTexDimension(w);
|
rw = GetTexDimension(w);
|
||||||
rh = GetTexDimension(h);
|
rh = GetTexDimension(h);
|
||||||
|
@ -168,7 +172,8 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
|
||||||
glTex->mipmapped = true;
|
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;
|
return glTex->glTexID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ IHardwareTexture * FMaterial::ValidateSysTexture(FTexture * tex, bool expand)
|
||||||
IHardwareTexture *gltex = tex->SystemTexture[expand];
|
IHardwareTexture *gltex = tex->SystemTexture[expand];
|
||||||
if (gltex == nullptr)
|
if (gltex == nullptr)
|
||||||
{
|
{
|
||||||
gltex = tex->SystemTexture[expand] = screen->CreateHardwareTexture(tex);
|
gltex = tex->SystemTexture[expand] = screen->CreateHardwareTexture();
|
||||||
}
|
}
|
||||||
return gltex;
|
return gltex;
|
||||||
}
|
}
|
||||||
|
|
|
@ -774,7 +774,7 @@ FWrapperTexture::FWrapperTexture(int w, int h, int bits)
|
||||||
Format = bits;
|
Format = bits;
|
||||||
UseType = ETextureType::SWCanvas;
|
UseType = ETextureType::SWCanvas;
|
||||||
bNoCompress = true;
|
bNoCompress = true;
|
||||||
SystemTexture[0] = screen->CreateHardwareTexture(this);
|
SystemTexture[0] = screen->CreateHardwareTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include "colormatcher.h"
|
#include "colormatcher.h"
|
||||||
#include "r_data/renderstyle.h"
|
#include "r_data/renderstyle.h"
|
||||||
#include "r_data/r_translate.h"
|
#include "r_data/r_translate.h"
|
||||||
|
#include "hwrenderer/textures/hw_texmanager.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// 15 because 0th texture is our texture
|
// 15 because 0th texture is our texture
|
||||||
|
|
Loading…
Reference in a new issue