mWidth( mSurface->GetPositionSize().width ),
mHeight( mSurface->GetPositionSize().height ),
mBackgroundColor( 0.f, 0.f, 0.f, 1.f ),
- mSizeChanged( false )
+ mSizeChanged( false ),
+ mIsSurfaceInvalid( false )
{
}
void SurfaceFrameBuffer::Destroy( Context& context )
{
+ if ( IsSurfaceValid() )
+ {
+ mSurface->DestroySurface();
+ mSurface = nullptr;
+ }
}
void SurfaceFrameBuffer::GlContextDestroyed()
{
mContext->GlContextDestroyed();
}
+
+ if ( IsSurfaceValid() )
+ {
+ mSurface->DestroySurface();
+ mSurface = nullptr;
+ }
}
void SurfaceFrameBuffer::Initialize(Context& context)
{
mContext = &context;
mContext->GlContextCreated();
- mSurface->InitializeGraphics();
+
+ if ( IsSurfaceValid() )
+ {
+ mSurface->InitializeGraphics();
+ }
}
void SurfaceFrameBuffer::Bind( Context& context )
{
- mSurface->PreRender( mSizeChanged );
+ if ( IsSurfaceValid() )
+ {
+ mSurface->PreRender( mSizeChanged );
- context.BindFramebuffer( GL_FRAMEBUFFER, 0u );
+ context.BindFramebuffer( GL_FRAMEBUFFER, 0u );
+ }
}
uint32_t SurfaceFrameBuffer::GetWidth() const
void SurfaceFrameBuffer::PostRender()
{
- mSurface->PostRender( false, false, mSizeChanged );
+ if ( IsSurfaceValid() )
+ {
+ mSurface->PostRender( false, false, mSizeChanged );
+ }
mSizeChanged = false;
}
return mContext;
}
-Integration::DepthBufferAvailable SurfaceFrameBuffer::GetDepthBufferRequired()
-{
- return mSurface->GetDepthBufferRequired();
-}
-
-Integration::StencilBufferAvailable SurfaceFrameBuffer::GetStencilBufferRequired()
+void SurfaceFrameBuffer::MakeContextCurrent()
{
- return mSurface->GetStencilBufferRequired();
+ if ( IsSurfaceValid() )
+ {
+ mSurface->MakeContextCurrent();
+ }
}
Vector4 SurfaceFrameBuffer::GetBackgroundColor()
mBackgroundColor = color;
}
+bool SurfaceFrameBuffer::IsSurfaceValid() const
+{
+ return mSurface && !mIsSurfaceInvalid;
+}
+
} //Render
} //Internal