diff --git a/Src/Graphics/New3D/New3D.cpp b/Src/Graphics/New3D/New3D.cpp index f5ca665..18b598b 100644 --- a/Src/Graphics/New3D/New3D.cpp +++ b/Src/Graphics/New3D/New3D.cpp @@ -92,6 +92,8 @@ void CNew3D::RenderScene(int priority, bool alpha) continue; } + std::shared_ptr tex1; + glViewport (n.viewport.x, n.viewport.y, n.viewport.width, n.viewport.height); glMatrixMode (GL_PROJECTION); glLoadMatrixf (n.viewport.projectionMatrix); @@ -132,10 +134,15 @@ void CNew3D::RenderScene(int priority, bool alpha) int x, y; CalcTexOffset(m.textureOffsetX, m.textureOffsetY, m.page, mesh.x, mesh.y, x, y); - auto tex1 = m_texSheet.BindTexture(m_textureRAM, mesh.format, mesh.mirrorU, mesh.mirrorV, x, y, mesh.width, mesh.height); - if (tex1) { - tex1->BindTexture(); - tex1->SetWrapMode(mesh.mirrorU, mesh.mirrorV); + if (tex1 && tex1->Compare(x, y, mesh.width, mesh.height, mesh.format)) { + tex1->SetWrapMode(mesh.mirrorU, mesh.mirrorV); + } + else { + tex1 = m_texSheet.BindTexture(m_textureRAM, mesh.format, mesh.mirrorU, mesh.mirrorV, x, y, mesh.width, mesh.height); + if (tex1) { + tex1->BindTexture(); + tex1->SetWrapMode(mesh.mirrorU, mesh.mirrorV); + } } if (mesh.microTexture) { diff --git a/Src/Graphics/New3D/Texture.cpp b/Src/Graphics/New3D/Texture.cpp index 632d980..a1fe956 100644 --- a/Src/Graphics/New3D/Texture.cpp +++ b/Src/Graphics/New3D/Texture.cpp @@ -325,4 +325,13 @@ void Texture::GetDetails(int& x, int&y, int& width, int& height, int& format) format = m_format; } +bool Texture::Compare(int x, int y, int width, int height, int format) +{ + if (m_x == x && m_y == y && m_width == width && m_height == height && m_format == format) { + return true; + } + + return false; +} + } // New3D diff --git a/Src/Graphics/New3D/Texture.h b/Src/Graphics/New3D/Texture.h index c429cc1..7ba41cc 100644 --- a/Src/Graphics/New3D/Texture.h +++ b/Src/Graphics/New3D/Texture.h @@ -19,6 +19,7 @@ public: void GetCoordinates (UINT16 uIn, UINT16 vIn, float uvScale, float& uOut, float& vOut); void GetDetails (int& x, int&y, int& width, int& height, int& format); void SetWrapMode (bool mirrorU, bool mirrorV); + bool Compare (int x, int y, int width, int height, int format); static void GetCoordinates(int width, int height, UINT16 uIn, UINT16 vIn, float uvScale, float& uOut, float& vOut);