From 1213deb102ed79418c0228233e05c2172faf06e1 Mon Sep 17 00:00:00 2001 From: rogerman Date: Wed, 28 Dec 2016 14:07:06 -0800 Subject: [PATCH] OpenGL Renderer: Fix various bugs when running OpenGL 2.1 and earlier. Fixes regressions from commits 8fab805 and 7b13501. --- desmume/src/OGLRender.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/desmume/src/OGLRender.cpp b/desmume/src/OGLRender.cpp index 90a8a4cd0..55eff9960 100644 --- a/desmume/src/OGLRender.cpp +++ b/desmume/src/OGLRender.cpp @@ -361,16 +361,9 @@ static const char *fragmentShader_100 = {"\ discard;\n\ }\n\ }\n\ - else\n\ - {\n\ - if ( ((polyMode != 1) && (mainTexColor.a * vtxColor.a > 0.999)) || ((polyMode == 1) && (vtxColor.a > 0.999)) )\n\ - {\n\ - discard;\n\ - }\n\ - }\n\ }\n\ \n\ - vec4 newFragColor = mainTexColor * vtxColor;\n\ + newFragColor = mainTexColor * vtxColor;\n\ \n\ if(polyMode == 1)\n\ {\n\ @@ -1506,7 +1499,7 @@ Render3DError OpenGLRenderer_1_2::InitExtensions() if (this->isFBOSupported) { this->willFlipFramebufferOnGPU = true; - this->willConvertFramebufferOnGPU = (this->isShaderSupported && this->isVAOSupported && this->isPBOSupported && this->isFBOSupported); + this->willConvertFramebufferOnGPU = false; // Only support this on OpenGL v2.0 or later. error = this->CreateFBOs(); if (error != OGLERROR_NOERR) @@ -1519,9 +1512,8 @@ Render3DError OpenGLRenderer_1_2::InitExtensions() INFO("OpenGL: FBOs are unsupported. Some emulation features will be disabled.\n"); } - // Set these again after FBO creation just in case FBO creation fails. + // Set this again after FBO creation just in case FBO creation fails. this->willFlipFramebufferOnGPU = this->isFBOSupported; - this->willConvertFramebufferOnGPU = (this->isShaderSupported && this->isVAOSupported && this->isPBOSupported && this->isFBOSupported); // Don't use ARB versions since we're using the EXT versions for backwards compatibility. this->isMultisampledFBOSupported = this->isFBOSupported && @@ -1607,6 +1599,12 @@ void OpenGLRenderer_1_2::DestroyPBOs() return; } + if (this->_mappedFramebuffer != NULL) + { + glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB); + this->_mappedFramebuffer = NULL; + } + glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); glDeleteBuffersARB(1, &this->ref->pboRenderDataID); @@ -2602,6 +2600,7 @@ Render3DError OpenGLRenderer_1_2::BeginRender(const GFX3D &engine) glUniform1i(OGLRef.uniformStateEnableEdgeMarking, (engine.renderState.enableEdgeMarking) ? GL_TRUE : GL_FALSE); glUniform1i(OGLRef.uniformStateUseWDepth, (engine.renderState.wbuffer) ? GL_TRUE : GL_FALSE); glUniform1f(OGLRef.uniformStateAlphaTestRef, divide5bitBy31_LUT[engine.renderState.alphaTestRef]); + glUniform1i(OGLRef.uniformTexDrawOpaque, GL_FALSE); glUniform1i(OGLRef.uniformPolyDrawShadow, GL_FALSE); } else @@ -3835,6 +3834,7 @@ Render3DError OpenGLRenderer_1_5::BeginRender(const GFX3D &engine) glUniform1i(OGLRef.uniformStateEnableEdgeMarking, (engine.renderState.enableEdgeMarking) ? GL_TRUE : GL_FALSE); glUniform1i(OGLRef.uniformStateUseWDepth, (engine.renderState.wbuffer) ? GL_TRUE : GL_FALSE); glUniform1f(OGLRef.uniformStateAlphaTestRef, divide5bitBy31_LUT[engine.renderState.alphaTestRef]); + glUniform1i(OGLRef.uniformTexDrawOpaque, GL_FALSE); glUniform1i(OGLRef.uniformPolyDrawShadow, GL_FALSE); } else @@ -4510,6 +4510,7 @@ Render3DError OpenGLRenderer_2_0::BeginRender(const GFX3D &engine) glUniform1i(OGLRef.uniformStateEnableEdgeMarking, (engine.renderState.enableEdgeMarking) ? GL_TRUE : GL_FALSE); glUniform1i(OGLRef.uniformStateUseWDepth, (engine.renderState.wbuffer) ? GL_TRUE : GL_FALSE); glUniform1f(OGLRef.uniformStateAlphaTestRef, divide5bitBy31_LUT[engine.renderState.alphaTestRef]); + glUniform1i(OGLRef.uniformTexDrawOpaque, GL_FALSE); glUniform1i(OGLRef.uniformPolyDrawShadow, GL_FALSE); glBindBuffer(GL_ARRAY_BUFFER, OGLRef.vboGeometryVtxID);