OpenGL Renderer: Fix bug where certain polygons would occasionally render their textures blank.

(Regression from commit 1368b2d).
This commit is contained in:
rogerman 2016-12-05 15:13:17 -08:00
parent 1d8bdd5b54
commit d2f054b5fb
2 changed files with 4 additions and 6 deletions

View File

@ -3066,8 +3066,6 @@ Render3DError OpenGLRenderer_1_2::SetupTexture(const POLY &thePoly, size_t polyR
const NDSTextureFormat packFormat = theTexture->GetPackFormat();
const OGLRenderRef &OGLRef = *this->ref;
glBindTexture(GL_TEXTURE_2D, theTexture->GetID());
// Check if we need to use textures
if (!theTexture->IsSamplingEnabled())
{
@ -3102,6 +3100,7 @@ Render3DError OpenGLRenderer_1_2::SetupTexture(const POLY &thePoly, size_t polyR
glScalef(theTexture->GetInvWidth(), theTexture->GetInvHeight(), 1.0f);
}
glBindTexture(GL_TEXTURE_2D, theTexture->GetID());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (texParams.enableRepeatS ? (texParams.enableMirroredRepeatS ? OGLRef.stateTexMirroredRepeat : GL_REPEAT) : GL_CLAMP_TO_EDGE));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (texParams.enableRepeatT ? (texParams.enableMirroredRepeatT ? OGLRef.stateTexMirroredRepeat : GL_REPEAT) : GL_CLAMP_TO_EDGE));
@ -4660,7 +4659,6 @@ Render3DError OpenGLRenderer_2_0::SetupTexture(const POLY &thePoly, size_t polyR
const NDSTextureFormat packFormat = theTexture->GetPackFormat();
const OGLRenderRef &OGLRef = *this->ref;
glBindTexture(GL_TEXTURE_2D, theTexture->GetID());
glUniform2f(OGLRef.uniformPolyTexScale, theTexture->GetInvWidth(), theTexture->GetInvHeight());
// Check if we need to use textures
@ -4676,6 +4674,7 @@ Render3DError OpenGLRenderer_2_0::SetupTexture(const POLY &thePoly, size_t polyR
glUniform1i(OGLRef.uniformPolyEnableTexture, GL_TRUE);
glUniform1i(OGLRef.uniformTexSingleBitAlpha, (packFormat != TEXMODE_A3I5 && packFormat != TEXMODE_A5I3) ? GL_TRUE : GL_FALSE);
glBindTexture(GL_TEXTURE_2D, theTexture->GetID());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (texParams.enableRepeatS ? (texParams.enableMirroredRepeatS ? GL_MIRRORED_REPEAT : GL_REPEAT) : GL_CLAMP_TO_EDGE));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (texParams.enableRepeatT ? (texParams.enableMirroredRepeatT ? GL_MIRRORED_REPEAT : GL_REPEAT) : GL_CLAMP_TO_EDGE));

View File

@ -1688,9 +1688,7 @@ Render3DError OpenGLRenderer_3_2::SetupPolygon(const POLY &thePoly)
Render3DError OpenGLRenderer_3_2::SetupTexture(const POLY &thePoly, size_t polyRenderIndex)
{
OpenGLTexture *theTexture = (OpenGLTexture *)this->_textureList[polyRenderIndex];
glBindTexture(GL_TEXTURE_2D, theTexture->GetID());
// Check if we need to use textures
if (!theTexture->IsSamplingEnabled())
{
@ -1699,6 +1697,7 @@ Render3DError OpenGLRenderer_3_2::SetupTexture(const POLY &thePoly, size_t polyR
PolygonTexParams texParams = thePoly.getTexParams();
glBindTexture(GL_TEXTURE_2D, theTexture->GetID());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (texParams.enableRepeatS ? (texParams.enableMirroredRepeatS ? GL_MIRRORED_REPEAT : GL_REPEAT) : GL_CLAMP_TO_EDGE));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (texParams.enableRepeatT ? (texParams.enableMirroredRepeatT ? GL_MIRRORED_REPEAT : GL_REPEAT) : GL_CLAMP_TO_EDGE));