From 8821e7b162fca542922137c96458bc10ed896615 Mon Sep 17 00:00:00 2001 From: rogerman Date: Tue, 29 Nov 2016 17:09:25 -0800 Subject: [PATCH] Render3D: Make _textureList universal for all 3D renderers. --- desmume/src/OGLRender.cpp | 4 ++-- desmume/src/OGLRender.h | 1 - desmume/src/OGLRender_3_2.cpp | 2 +- desmume/src/rasterize.cpp | 2 +- desmume/src/rasterize.h | 1 - desmume/src/render3D.cpp | 5 +++++ desmume/src/render3D.h | 2 ++ 7 files changed, 11 insertions(+), 6 deletions(-) diff --git a/desmume/src/OGLRender.cpp b/desmume/src/OGLRender.cpp index 03bc4cb15..b16b386bf 100644 --- a/desmume/src/OGLRender.cpp +++ b/desmume/src/OGLRender.cpp @@ -3056,7 +3056,7 @@ Render3DError OpenGLRenderer_1_2::SetupPolygon(const POLY &thePoly) Render3DError OpenGLRenderer_1_2::SetupTexture(const POLY &thePoly, size_t polyRenderIndex) { - OpenGLTexture *theTexture = this->_textureList[polyRenderIndex]; + OpenGLTexture *theTexture = (OpenGLTexture *)this->_textureList[polyRenderIndex]; const NDSTextureFormat packFormat = theTexture->GetPackFormat(); const OGLRenderRef &OGLRef = *this->ref; @@ -4650,7 +4650,7 @@ Render3DError OpenGLRenderer_2_0::SetupPolygon(const POLY &thePoly) Render3DError OpenGLRenderer_2_0::SetupTexture(const POLY &thePoly, size_t polyRenderIndex) { - OpenGLTexture *theTexture = this->_textureList[polyRenderIndex]; + OpenGLTexture *theTexture = (OpenGLTexture *)this->_textureList[polyRenderIndex]; const NDSTextureFormat packFormat = theTexture->GetPackFormat(); const OGLRenderRef &OGLRef = *this->ref; diff --git a/desmume/src/OGLRender.h b/desmume/src/OGLRender.h index 00aed459f..89e35c88e 100644 --- a/desmume/src/OGLRender.h +++ b/desmume/src/OGLRender.h @@ -611,7 +611,6 @@ protected: bool _pixelReadNeedsFinish; size_t _currentPolyIndex; std::vector _shadowPolyID; - OpenGLTexture *_textureList[POLYLIST_SIZE]; Render3DError FlushFramebuffer(const FragmentColor *__restrict srcFramebuffer, FragmentColor *__restrict dstFramebuffer, u16 *__restrict dstRGBA5551); OpenGLTexture* GetLoadedTextureFromPolygon(const POLY &thePoly, bool enableTexturing); diff --git a/desmume/src/OGLRender_3_2.cpp b/desmume/src/OGLRender_3_2.cpp index c5fc83d7e..2b47f1041 100644 --- a/desmume/src/OGLRender_3_2.cpp +++ b/desmume/src/OGLRender_3_2.cpp @@ -1687,7 +1687,7 @@ Render3DError OpenGLRenderer_3_2::SetupPolygon(const POLY &thePoly) Render3DError OpenGLRenderer_3_2::SetupTexture(const POLY &thePoly, size_t polyRenderIndex) { - OpenGLTexture *theTexture = this->_textureList[polyRenderIndex]; + OpenGLTexture *theTexture = (OpenGLTexture *)this->_textureList[polyRenderIndex]; glBindTexture(GL_TEXTURE_2D, theTexture->GetID()); diff --git a/desmume/src/rasterize.cpp b/desmume/src/rasterize.cpp index 9b48956c2..2ec747747 100644 --- a/desmume/src/rasterize.cpp +++ b/desmume/src/rasterize.cpp @@ -345,7 +345,7 @@ public: Render3DError SetupTexture(const POLY &thePoly, size_t polyRenderIndex) { - SoftRasterizerTexture *theTexture = this->_softRender->_textureList[polyRenderIndex]; + SoftRasterizerTexture *theTexture = (SoftRasterizerTexture *)this->_softRender->GetTextureByPolygonRenderIndex(polyRenderIndex); this->currentTexture = theTexture; if (!theTexture->IsSamplingEnabled()) diff --git a/desmume/src/rasterize.h b/desmume/src/rasterize.h index c4f42d0a3..18e025b4e 100644 --- a/desmume/src/rasterize.h +++ b/desmume/src/rasterize.h @@ -122,7 +122,6 @@ public: FragmentColor toonColor32LUT[32]; GFX3D_Clipper::TClippedPoly *clippedPolys; FragmentAttributesBuffer *_framebufferAttributes; - SoftRasterizerTexture *_textureList[POLYLIST_SIZE]; bool polyVisible[POLYLIST_SIZE]; bool polyBackfacing[POLYLIST_SIZE]; GFX3D_State *currentRenderState; diff --git a/desmume/src/render3D.cpp b/desmume/src/render3D.cpp index 2abeef855..18a1ae376 100644 --- a/desmume/src/render3D.cpp +++ b/desmume/src/render3D.cpp @@ -453,6 +453,11 @@ void Render3D::SetTextureProcessingProperties(size_t scalingFactor, bool willDep } } +Render3DTexture* Render3D::GetTextureByPolygonRenderIndex(size_t polyRenderIndex) const +{ + return this->_textureList[polyRenderIndex]; +} + Render3DError Render3D::BeginRender(const GFX3D &engine) { return RENDER3DERROR_NOERR; diff --git a/desmume/src/render3D.h b/desmume/src/render3D.h index 0dd221a5a..b24a591c9 100644 --- a/desmume/src/render3D.h +++ b/desmume/src/render3D.h @@ -162,6 +162,7 @@ protected: SSurface _textureDeposterizeDstSurface; u32 *_textureUpscaleBuffer; + Render3DTexture *_textureList[POLYLIST_SIZE]; CACHE_ALIGN u16 clearImageColor16Buffer[GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT]; CACHE_ALIGN u32 clearImageDepthBuffer[GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT]; @@ -230,6 +231,7 @@ public: void SetRenderNeedsFinish(const bool renderNeedsFinish); void SetTextureProcessingProperties(size_t scalingFactor, bool willDeposterize, bool willSmooth); + Render3DTexture* GetTextureByPolygonRenderIndex(size_t polyRenderIndex) const; }; #ifdef ENABLE_SSE2