- if ( surfaceFrameBuffer )
- {
- mImpl->currentContext->Viewport( surfaceRect.x,
- surfaceRect.y,
- surfaceRect.width,
- surfaceRect.height );
-
-
- mImpl->currentContext->ClearColor( backgroundColor.r,
- backgroundColor.g,
- backgroundColor.b,
- backgroundColor.a );
- }
-
- // Clear the entire color, depth and stencil buffers for the default framebuffer, if required.
- // It is important to clear all 3 buffers when they are being used, for performance on deferred renderers
- // e.g. previously when the depth & stencil buffers were NOT cleared, it caused the DDK to exceed a "vertex count limit",
- // and then stall. That problem is only noticeable when rendering a large number of vertices per frame.
- if( isPartialUpdate )
- {
- mImpl->currentContext->SetScissorTest( true );
- mImpl->currentContext->Scissor( scissorBox.x, scissorBox.y, scissorBox.width, scissorBox.height );
- }
- else
- {
- mImpl->currentContext->SetScissorTest( false );
- }
-
- GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
-
- mImpl->currentContext->ColorMask( true );
-
- if( depthBufferAvailable == Integration::DepthBufferAvailable::TRUE )
- {
- mImpl->currentContext->DepthMask( true );
- clearMask |= GL_DEPTH_BUFFER_BIT;
- }
-
- if( stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE)
- {
- mImpl->currentContext->ClearStencil( 0 );
- mImpl->currentContext->StencilMask( 0xFF ); // 8 bit stencil mask, all 1's
- clearMask |= GL_STENCIL_BUFFER_BIT;
- }
-
- mImpl->currentContext->Clear( clearMask, Context::FORCE_CLEAR );
-
- if( isPartialUpdate )
- {
- mImpl->currentContext->SetScissorTest( false );
- }
-
-
- if( !instruction.mIgnoreRenderToFbo && ( instruction.mFrameBuffer != 0 ) )
- {
- if ( instruction.mFrameBuffer->IsSurfaceBacked() ) // Surface rendering