2
0
Эх сурвалжийг харах

Use a traditional color clear on OpenGL ES for better performance.

Lasse Öörni 13 жил өмнө
parent
commit
f0263df91d

+ 4 - 0
Engine/Graphics/OpenGL/OGLGraphics.cpp

@@ -423,6 +423,10 @@ void Graphics::Clear(unsigned flags, const Color& color, float depth, unsigned s
     if (impl_->fboDirty_)
     if (impl_->fboDirty_)
         CommitFramebuffer();
         CommitFramebuffer();
     
     
+    #ifdef GL_ES_VERSION_2_0
+    flags &= ~CLEAR_STENCIL;
+    #endif
+    
     bool oldColorWrite = colorWrite_;
     bool oldColorWrite = colorWrite_;
     bool oldDepthWrite = depthWrite_;
     bool oldDepthWrite = depthWrite_;
     
     

+ 7 - 0
Engine/Graphics/View.cpp

@@ -1182,7 +1182,11 @@ void View::RenderBatchesForward()
     graphics_->SetRenderTarget(0, renderTarget);
     graphics_->SetRenderTarget(0, renderTarget);
     graphics_->SetDepthStencil(depthStencil);
     graphics_->SetDepthStencil(depthStencil);
     graphics_->SetViewport(viewRect_);
     graphics_->SetViewport(viewRect_);
+    #ifndef GL_ES_VERSION_2_0
     graphics_->Clear(CLEAR_DEPTH | CLEAR_STENCIL);
     graphics_->Clear(CLEAR_DEPTH | CLEAR_STENCIL);
+    #else
+    graphics_->Clear(CLEAR_COLOR | CLEAR_DEPTH, farClipZone_->GetFogColor());
+    #endif
     
     
     // Render opaque object unlit base pass
     // Render opaque object unlit base pass
     if (!baseQueue_.IsEmpty())
     if (!baseQueue_.IsEmpty())
@@ -1214,7 +1218,9 @@ void View::RenderBatchesForward()
     graphics_->SetScissorTest(false);
     graphics_->SetScissorTest(false);
     graphics_->SetStencilTest(false);
     graphics_->SetStencilTest(false);
     
     
+    #ifndef GL_ES_VERSION_2_0
     // At this point clear the parts of viewport not occupied by opaque geometry with fog color
     // At this point clear the parts of viewport not occupied by opaque geometry with fog color
+    // On OpenGL ES an ordinary color clear has been performed beforehand instead
     graphics_->SetBlendMode(BLEND_REPLACE);
     graphics_->SetBlendMode(BLEND_REPLACE);
     graphics_->SetColorWrite(true);
     graphics_->SetColorWrite(true);
     graphics_->SetDepthTest(CMP_LESSEQUAL);
     graphics_->SetDepthTest(CMP_LESSEQUAL);
@@ -1225,6 +1231,7 @@ void View::RenderBatchesForward()
     graphics_->SetShaderParameter(PSP_MATDIFFCOLOR, farClipZone_->GetFogColor());
     graphics_->SetShaderParameter(PSP_MATDIFFCOLOR, farClipZone_->GetFogColor());
     graphics_->ClearParameterSource(SP_MATERIAL);
     graphics_->ClearParameterSource(SP_MATERIAL);
     DrawFullscreenQuad(camera_, false);
     DrawFullscreenQuad(camera_, false);
+    #endif
     
     
     // Render pre-alpha custom pass
     // Render pre-alpha custom pass
     if (!preAlphaQueue_.IsEmpty())
     if (!preAlphaQueue_.IsEmpty())