mContext( nullptr ),
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();
-}
-
-Vector4 SurfaceFrameBuffer::GetBackgroundColor()
-{
- return mBackgroundColor;
+ if ( IsSurfaceValid() )
+ {
+ mSurface->MakeContextCurrent();
+ }
}
void SurfaceFrameBuffer::SetSize( uint32_t width, uint32_t height )
mSizeChanged = true;
}
-void SurfaceFrameBuffer::SetBackgroundColor( const Vector4& color )
+bool SurfaceFrameBuffer::IsSurfaceValid() const
{
- mBackgroundColor = color;
+ return mSurface && !mIsSurfaceInvalid;
}
} //Render