From 600ae21668293eb7e001e70ea86c1af37e56179c Mon Sep 17 00:00:00 2001 From: rogerman Date: Tue, 1 Aug 2017 13:02:50 -0700 Subject: [PATCH] OpenGL Renderer: Do some minor code cleanup. --- desmume/src/OGLRender.cpp | 68 ++-------------------------------- desmume/src/OGLRender_3_2.cpp | 69 +++-------------------------------- 2 files changed, 9 insertions(+), 128 deletions(-) diff --git a/desmume/src/OGLRender.cpp b/desmume/src/OGLRender.cpp index 27f69b49d..3cae65bc3 100755 --- a/desmume/src/OGLRender.cpp +++ b/desmume/src/OGLRender.cpp @@ -2127,26 +2127,8 @@ Render3DError OpenGLRenderer_1_2::CreateFBOs() if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) { INFO("OpenGL: Failed to create FBOs!\n"); + this->DestroyFBOs(); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - glDeleteFramebuffersEXT(1, &OGLRef.fboClearImageID); - glDeleteFramebuffersEXT(1, &OGLRef.fboRenderID); - glDeleteFramebuffersEXT(1, &OGLRef.fboPostprocessID); - glDeleteTextures(1, &OGLRef.texCIColorID); - glDeleteTextures(1, &OGLRef.texCIFogAttrID); - glDeleteTextures(1, &OGLRef.texCIPolyID); - glDeleteTextures(1, &OGLRef.texCIDepthStencilID); - glDeleteTextures(1, &OGLRef.texGColorID); - glDeleteTextures(1, &OGLRef.texGPolyID); - glDeleteTextures(1, &OGLRef.texGFogAttrID); - glDeleteTextures(1, &OGLRef.texGDepthStencilID); - glDeleteTextures(1, &OGLRef.texZeroAlphaPixelMaskID); - - OGLRef.fboClearImageID = 0; - OGLRef.fboRenderID = 0; - OGLRef.fboPostprocessID = 0; - - this->isFBOSupported = false; return OGLERROR_FBO_CREATE_ERROR; } @@ -2171,26 +2153,8 @@ Render3DError OpenGLRenderer_1_2::CreateFBOs() if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) { INFO("OpenGL: Failed to create FBOs!\n"); + this->DestroyFBOs(); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - glDeleteFramebuffersEXT(1, &OGLRef.fboClearImageID); - glDeleteFramebuffersEXT(1, &OGLRef.fboRenderID); - glDeleteFramebuffersEXT(1, &OGLRef.fboPostprocessID); - glDeleteTextures(1, &OGLRef.texCIColorID); - glDeleteTextures(1, &OGLRef.texCIFogAttrID); - glDeleteTextures(1, &OGLRef.texCIPolyID); - glDeleteTextures(1, &OGLRef.texCIDepthStencilID); - glDeleteTextures(1, &OGLRef.texGColorID); - glDeleteTextures(1, &OGLRef.texGPolyID); - glDeleteTextures(1, &OGLRef.texGFogAttrID); - glDeleteTextures(1, &OGLRef.texGDepthStencilID); - glDeleteTextures(1, &OGLRef.texZeroAlphaPixelMaskID); - - OGLRef.fboClearImageID = 0; - OGLRef.fboRenderID = 0; - OGLRef.fboPostprocessID = 0; - - this->isFBOSupported = false; return OGLERROR_FBO_CREATE_ERROR; } @@ -2213,26 +2177,8 @@ Render3DError OpenGLRenderer_1_2::CreateFBOs() if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) { INFO("OpenGL: Failed to created FBOs!\n"); + this->DestroyFBOs(); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - glDeleteFramebuffersEXT(1, &OGLRef.fboClearImageID); - glDeleteFramebuffersEXT(1, &OGLRef.fboRenderID); - glDeleteFramebuffersEXT(1, &OGLRef.fboPostprocessID); - glDeleteTextures(1, &OGLRef.texCIColorID); - glDeleteTextures(1, &OGLRef.texCIFogAttrID); - glDeleteTextures(1, &OGLRef.texCIPolyID); - glDeleteTextures(1, &OGLRef.texCIDepthStencilID); - glDeleteTextures(1, &OGLRef.texGColorID); - glDeleteTextures(1, &OGLRef.texGPolyID); - glDeleteTextures(1, &OGLRef.texGFogAttrID); - glDeleteTextures(1, &OGLRef.texGDepthStencilID); - glDeleteTextures(1, &OGLRef.texZeroAlphaPixelMaskID); - - OGLRef.fboClearImageID = 0; - OGLRef.fboRenderID = 0; - OGLRef.fboPostprocessID = 0; - - this->isFBOSupported = false; return OGLERROR_FBO_CREATE_ERROR; } @@ -2314,13 +2260,7 @@ Render3DError OpenGLRenderer_1_2::CreateMultisampledFBO() if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) { INFO("OpenGL: Failed to create multisampled FBO!\n"); - - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - glDeleteFramebuffersEXT(1, &OGLRef.fboMSIntermediateRenderID); - glDeleteRenderbuffersEXT(1, &OGLRef.rboMSGColorID); - glDeleteRenderbuffersEXT(1, &OGLRef.rboMSGPolyID); - glDeleteRenderbuffersEXT(1, &OGLRef.rboMSGFogAttrID); - glDeleteRenderbuffersEXT(1, &OGLRef.rboMSGDepthStencilID); + this->DestroyMultisampledFBO(); return OGLERROR_FBO_CREATE_ERROR; } diff --git a/desmume/src/OGLRender_3_2.cpp b/desmume/src/OGLRender_3_2.cpp index 45c5a0f35..11687a2aa 100644 --- a/desmume/src/OGLRender_3_2.cpp +++ b/desmume/src/OGLRender_3_2.cpp @@ -906,24 +906,7 @@ Render3DError OpenGLRenderer_3_2::CreateFBOs() if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { INFO("OpenGL: Failed to create FBOs!\n"); - - glBindFramebuffer(GL_FRAMEBUFFER, 0); - glDeleteFramebuffers(1, &OGLRef.fboClearImageID); - glDeleteFramebuffers(1, &OGLRef.fboRenderID); - glDeleteFramebuffers(1, &OGLRef.fboPostprocessID); - glDeleteTextures(1, &OGLRef.texCIColorID); - glDeleteTextures(1, &OGLRef.texCIFogAttrID); - glDeleteTextures(1, &OGLRef.texCIPolyID); - glDeleteTextures(1, &OGLRef.texCIDepthStencilID); - glDeleteTextures(1, &OGLRef.texGColorID); - glDeleteTextures(1, &OGLRef.texGPolyID); - glDeleteTextures(1, &OGLRef.texGFogAttrID); - glDeleteTextures(1, &OGLRef.texGDepthStencilID); - glDeleteTextures(1, &OGLRef.texZeroAlphaPixelMaskID); - - OGLRef.fboClearImageID = 0; - OGLRef.fboRenderID = 0; - OGLRef.fboPostprocessID = 0; + this->DestroyFBOs(); return OGLERROR_FBO_CREATE_ERROR; } @@ -940,24 +923,7 @@ Render3DError OpenGLRenderer_3_2::CreateFBOs() if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { INFO("OpenGL: Failed to create FBOs!\n"); - - glBindFramebuffer(GL_FRAMEBUFFER, 0); - glDeleteFramebuffers(1, &OGLRef.fboClearImageID); - glDeleteFramebuffers(1, &OGLRef.fboRenderID); - glDeleteFramebuffers(1, &OGLRef.fboPostprocessID); - glDeleteTextures(1, &OGLRef.texCIColorID); - glDeleteTextures(1, &OGLRef.texCIFogAttrID); - glDeleteTextures(1, &OGLRef.texCIPolyID); - glDeleteTextures(1, &OGLRef.texCIDepthStencilID); - glDeleteTextures(1, &OGLRef.texGColorID); - glDeleteTextures(1, &OGLRef.texGPolyID); - glDeleteTextures(1, &OGLRef.texGFogAttrID); - glDeleteTextures(1, &OGLRef.texGDepthStencilID); - glDeleteTextures(1, &OGLRef.texZeroAlphaPixelMaskID); - - OGLRef.fboClearImageID = 0; - OGLRef.fboRenderID = 0; - OGLRef.fboPostprocessID = 0; + this->DestroyFBOs(); return OGLERROR_FBO_CREATE_ERROR; } @@ -973,24 +939,7 @@ Render3DError OpenGLRenderer_3_2::CreateFBOs() if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { INFO("OpenGL: Failed to create FBOs!\n"); - - glBindFramebuffer(GL_FRAMEBUFFER, 0); - glDeleteFramebuffers(1, &OGLRef.fboClearImageID); - glDeleteFramebuffers(1, &OGLRef.fboRenderID); - glDeleteFramebuffers(1, &OGLRef.fboPostprocessID); - glDeleteTextures(1, &OGLRef.texCIColorID); - glDeleteTextures(1, &OGLRef.texCIFogAttrID); - glDeleteTextures(1, &OGLRef.texCIPolyID); - glDeleteTextures(1, &OGLRef.texCIDepthStencilID); - glDeleteTextures(1, &OGLRef.texGColorID); - glDeleteTextures(1, &OGLRef.texGPolyID); - glDeleteTextures(1, &OGLRef.texGFogAttrID); - glDeleteTextures(1, &OGLRef.texGDepthStencilID); - glDeleteTextures(1, &OGLRef.texZeroAlphaPixelMaskID); - - OGLRef.fboClearImageID = 0; - OGLRef.fboRenderID = 0; - OGLRef.fboPostprocessID = 0; + this->DestroyFBOs(); return OGLERROR_FBO_CREATE_ERROR; } @@ -1081,15 +1030,7 @@ Render3DError OpenGLRenderer_3_2::CreateMultisampledFBO() if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { INFO("OpenGL: Failed to create multisampled FBO. Multisample antialiasing will be disabled.\n"); - - glBindFramebuffer(GL_FRAMEBUFFER, 0); - glDeleteFramebuffers(1, &OGLRef.fboMSIntermediateRenderID); - glDeleteRenderbuffers(1, &OGLRef.rboMSGColorID); - glDeleteRenderbuffers(1, &OGLRef.rboMSGPolyID); - glDeleteRenderbuffers(1, &OGLRef.rboMSGFogAttrID); - glDeleteRenderbuffers(1, &OGLRef.rboMSGDepthStencilID); - - OGLRef.fboMSIntermediateRenderID = 0; + this->DestroyMultisampledFBO(); return OGLERROR_FBO_CREATE_ERROR; } @@ -1647,7 +1588,7 @@ Render3DError OpenGLRenderer_3_2::ClearUsingImage(const u16 *__restrict colorBuf glBindFramebuffer(GL_FRAMEBUFFER, OGLRef.fboRenderID); glDrawBuffers(3, RenderDrawList); - OGLRef.selectedRenderingFBO = (CommonSettings.GFX3D_Renderer_Multisample) ? OGLRef.fboMSIntermediateRenderID : OGLRef.fboRenderID; + OGLRef.selectedRenderingFBO = (CommonSettings.GFX3D_Renderer_Multisample && this->isMultisampledFBOSupported) ? OGLRef.fboMSIntermediateRenderID : OGLRef.fboRenderID; if (OGLRef.selectedRenderingFBO == OGLRef.fboMSIntermediateRenderID) { glBindFramebuffer(GL_READ_FRAMEBUFFER, OGLRef.fboRenderID);