OpenGL: Maintain one more flag to ensure that textures are always initialized. (Fixes #116.)

This commit is contained in:
rogerman 2017-11-21 11:17:52 -08:00
parent 4269925258
commit 5890540007
2 changed files with 11 additions and 6 deletions

View File

@ -702,6 +702,7 @@ OpenGLTexture::OpenGLTexture(TEXIMAGE_PARAM texAttributes, u32 palAttributes) :
_cacheSize = GetUnpackSizeUsingFormat(TexFormat_32bpp);
_invSizeS = 1.0f / (float)_sizeS;
_invSizeT = 1.0f / (float)_sizeT;
_isTexInited = false;
_upscaleBuffer = NULL;
@ -713,7 +714,7 @@ OpenGLTexture::~OpenGLTexture()
glDeleteTextures(1, &this->_texID);
}
void OpenGLTexture::Load(bool isNewTexture)
void OpenGLTexture::Load(bool forceTextureInit)
{
u32 *textureSrc = (u32 *)this->_deposterizeSrcSurface.Surface;
@ -733,8 +734,9 @@ void OpenGLTexture::Load(bool isNewTexture)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
if (isNewTexture)
if (forceTextureInit || !this->_isTexInited)
{
this->_isTexInited = true;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->_sizeS, this->_sizeT, 0, GL_RGBA, GL_TEXTURE_SRC_FORMAT, textureSrc);
}
else
@ -751,8 +753,9 @@ void OpenGLTexture::Load(bool isNewTexture)
this->_Upscale<2>(textureSrc, this->_upscaleBuffer);
if (isNewTexture)
if (forceTextureInit || !this->_isTexInited)
{
this->_isTexInited = true;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->_sizeS*2, this->_sizeT*2, 0, GL_RGBA, GL_TEXTURE_SRC_FORMAT, this->_upscaleBuffer);
glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, this->_sizeS*1, this->_sizeT*1, 0, GL_RGBA, GL_TEXTURE_SRC_FORMAT, textureSrc);
}
@ -771,8 +774,9 @@ void OpenGLTexture::Load(bool isNewTexture)
this->_Upscale<4>(textureSrc, this->_upscaleBuffer);
if (isNewTexture)
if (forceTextureInit || !this->_isTexInited)
{
this->_isTexInited = true;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->_sizeS*4, this->_sizeT*4, 0, GL_RGBA, GL_TEXTURE_SRC_FORMAT, this->_upscaleBuffer);
this->_Upscale<2>(textureSrc, this->_upscaleBuffer);

View File

@ -598,14 +598,15 @@ protected:
GLuint _texID;
GLfloat _invSizeS;
GLfloat _invSizeT;
bool _isTexInited;
u32 *_upscaleBuffer;
public:
OpenGLTexture(TEXIMAGE_PARAM texAttributes, u32 palAttributes);
virtual ~OpenGLTexture();
virtual void Load(bool isNewTexture);
virtual void Load(bool forceTextureInit);
GLuint GetID() const;
GLfloat GetInvWidth() const;