dsrc isn't necessary for this repo
[client-tools.git] / src / external / 3rd / application / UiBuilder / UIDirectDrawOffscreenCanvas.cpp
blob4055e71b285f824d335cb6f58fa9d082426edbef
1 #include "FirstUiBuilder.h"
2 #include "UIDirectDrawOffscreenCanvas.h"
4 UIDirectDrawOffscreenCanvas::UIDirectDrawOffscreenCanvas( const UISize &Size ) : UIDirectDrawCanvas( Size )
8 UIDirectDrawOffscreenCanvas::~UIDirectDrawOffscreenCanvas()
12 bool UIDirectDrawOffscreenCanvas::IsA( const UITypeID Type ) const
14 return (Type == TUIDirectDrawOffscreenCanvas) || UIDirectDrawCanvas::IsA( Type );
17 bool UIDirectDrawOffscreenCanvas::Generate( void ) const
19 if( !mSurface )
21 LPDIRECTDRAWSURFACE7 CreatedSurface;
22 DDSURFACEDESC2 ddsd = { sizeof( ddsd ) };
23 HRESULT hr;
25 ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
26 ddsd.dwWidth = mSize.x;
27 ddsd.dwHeight = mSize.y;
29 ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
30 ddsd.ddsCaps.dwCaps2 = 0;
32 hr = gDirectDraw->CreateSurface( &ddsd, &CreatedSurface, 0 );
34 if( FAILED( hr ) )
35 return false;
37 const_cast<UIDirectDrawOffscreenCanvas *>( this )->SetSurface( CreatedSurface );
39 else if( mSurface->IsLost() )
41 if( FAILED( mSurface->Restore() ) )
42 return false;
45 return UICanvas::Generate();