本文整理汇总了C++中LPDIRECTDRAWSURFACE::Restore方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE::Restore方法的具体用法?C++ LPDIRECTDRAWSURFACE::Restore怎么用?C++ LPDIRECTDRAWSURFACE::Restore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTDRAWSURFACE
的用法示例。
在下文中一共展示了LPDIRECTDRAWSURFACE::Restore方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// this restores memory when surface memory is lost
static int dd_restore(void)
{
HRESULT ret;
if (!lpDDSPrimary)
return 1;
ret = lpDDSPrimary->Restore();
if (ret == DD_OK)
{
if (lpDDSBitmap)
{
ret = lpDDSBitmap->Restore();
if (ret == DD_OK)
return 1;
else
{
module_logger(&win32DirectDrawVideo, _L|LOG_ERROR|L_0, _("video_restore: could not restore bitmap %8X\n"), ret);
return 0;
}
}
return 1;
}
else
{
module_logger(&win32DirectDrawVideo, _L|LOG_ERROR|L_0, _("video_restore: could not restore primary %8X\n"), ret);
return 0;
}
}
示例2: CreditsProc
int CreditsProc(PASSPROCVARS Params){
int r=0;
r+=ccbOK.ProcFunction(Params);
if(r){
//we have to flip the screen
Flip(Pass.DDFront);
Blit(Pass.DDBack, ddsCredits, 0, 0, 640, 480, 0, 0);
}
//now handle some messages
switch(Params.uMsg){
case WM_CLOSE:
Pass.ProgramFlow=PF_EXIT;
CreditsInfo=CREDITS_EXIT;
break;
case WM_PAINT:
ddsCredits->Restore();
ddsCreditsh->Restore();
DDReLoadBitmap(ddsCredits,BMP_CREDITS);
DDReLoadBitmap(ddsCreditsh,BMP_CREDITSH);
Blit(Pass.DDFront, ddsCredits, 0, 0, 640, 480, 0, 0);
Blit(Pass.DDBack, ddsCredits, 0, 0, 640, 480, 0, 0);
break;
case WM_KEYDOWN:
switch(Params.wParam){
case VK_ESCAPE:
CreditsInfo=CREDITS_EXIT;
break;
}
break;
}
return 0;
}
示例3: settingsRedrawScreen
void settingsRedrawScreen(){
ScreenHighlighted->Restore();
ScreenUnhighlighted->Restore();
DDReLoadBitmap(ScreenHighlighted,BMP_SETTINGSH);
DDReLoadBitmap(ScreenUnhighlighted,BMP_SETTINGS);
DrawString("Setting up alpha table/@", 0, 0, 8);
Blit(Pass.DDFront, ScreenUnhighlighted, 0, 0, 640, 480, 0, 0);
Blit(Pass.DDBack, ScreenUnhighlighted, 0, 0, 640, 480, 0, 0);
}
示例4: flip_fullscreen
void dd_Window::flip_fullscreen()
{
int i=0;
HRESULT hr;
//hack for 320x200 letterboxing
if(xres == 320 && yres == 200)
{
hr = dx_bs->BltFast(0,20,dx_os,NULL,DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY);
DDBLTFX ddbltfx;
memset(&ddbltfx, 0, sizeof(DDBLTFX));
ddbltfx.dwSize = sizeof(DDBLTFX);
ddbltfx.dwFillColor = 0;
RECT rBlit;
rBlit.left = 0; rBlit.top = 0; rBlit.right = 320; rBlit.bottom = 20;
dx_bs->Blt(&rBlit, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
rBlit.left = 0; rBlit.top = 220; rBlit.right = 320; rBlit.bottom = 240;
dx_bs->Blt(&rBlit, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
}
//regular case
else
hr = dx_bs->BltFast(0,0,dx_os,NULL,DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY);
if(hr==DDERR_SURFACELOST)
{
dx_bs->Restore();
dx_os->Restore();
dx_bs->BltFast(0,0,dx_os,NULL,DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY);
}
hr=dx_ps->Flip(0,DDFLIP_WAIT | DDFLIP_NOVSYNC);
//dx_ps->Flip(0,0);
if(hr==DDERR_SURFACELOST)
{
dx_ps->Restore();
hr=dx_ps->Flip(0,DDFLIP_WAIT | DDFLIP_NOVSYNC);
}
hr=dx_os->Lock(0,&dx_osd,DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY | DDLOCK_WAIT,0);
if(hr==DDERR_SURFACELOST)
{
dx_os->Restore();
hr=dx_os->Lock(0,&dx_osd,DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY | DDLOCK_WAIT,0);
}
dx_os->Unlock(0);
img->data=(quad*)dx_osd.lpSurface;
img->pitch=dx_osd.lPitch/vid_bytesperpixel;
}
示例5: WinProc
HRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_PAINT:
if(flag)
{
RectClient = GetClientRect(hWnd, diff_x, diff_y);
HRESULT ddrval = lpDDSPrimary->Blt (&RectClient,
lpDDSTemp, &RectTemp, DDBLT_WAIT, NULL);
if(ddrval == DDERR_SURFACELOST)
{
ddrval = lpDDSPrimary->Restore();
if (ddrval != DD_OK)
break;
}
}
return 0; //这里一定要是return,而不是break,否则不显示画面
case WM_DESTROY:
FreeDDraw();
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
示例6: lock
bool lock(LPDIRECTDRAWSURFACE dd,_TPixelsRef& out_pixelsRef){
DDSURFACEDESC ddsdDest;
memset(&ddsdDest,0,sizeof(ddsdDest));
ddsdDest.dwSize=sizeof(ddsdDest);
//ddsdDest.dwFlags=DDSD_LPSURFACE | DDSD_PITCH | DDSD_WIDTH | DDSD_HEIGHT;
HRESULT ddrval=dd->Lock(NULL,&ddsdDest,DDLOCK_WAIT,NULL);
if( ddrval == DDERR_SURFACELOST ) {
ddrval = m_ddsprimary->Restore();
if( ddrval!= DD_OK )
return false;
dd->Lock(NULL,&ddsdDest,DDLOCK_WAIT,NULL);
}
if (ddsdDest.lpSurface==0) return false;
if (ddsdDest.lPitch<=4){
out_pixelsRef.pdata=ddsdDest.lpSurface;//获得页面首地址
out_pixelsRef.width=ddsdDest.dwHeight;
out_pixelsRef.height=ddsdDest.dwWidth;
out_pixelsRef.byte_width=-out_pixelsRef.width*ddsdDest.lPitch;
((Pixels32Ref&)out_pixelsRef).reversal();
}else{
out_pixelsRef.pdata=ddsdDest.lpSurface;//获得页面首地址
out_pixelsRef.width=ddsdDest.dwWidth;
out_pixelsRef.height=ddsdDest.dwHeight;
out_pixelsRef.byte_width=ddsdDest.lPitch;
}
return true;
}
示例7: flip
bool flip(long bltWidth,long bltHeight){
if (m_ddsback==0) return true;
if (m_IS_USER_BACK_BUFFER){
if ((bltWidth>0)&&(bltHeight>0)){
RECT rt; rt.left=0; rt.top=0;
rt.right=bltWidth; rt.bottom=bltHeight;
#ifdef WINCE
HRESULT ddrval=m_ddsprimary->Blt(&rt,m_ddsback, &rt,DDBLT_WAITNOTBUSY, NULL);
#else
HRESULT ddrval=m_ddsprimary->BltFast(0,0, m_ddsback, &rt, NULL);
#endif
return (ddrval == DD_OK);
}else
return true;
}else{ //flip
while( true ) {
HRESULT ddrval= m_ddsprimary->Flip( NULL, DDFLIP_WAIT );// 交换表面
if( ddrval == DD_OK )
return true;
if( ddrval == DDERR_SURFACELOST ) {
ddrval = m_ddsprimary->Restore();
if( ddrval!= DD_OK )
return false;
}
if( ddrval != DDERR_WASSTILLDRAWING ){
return false;
}
::Sleep(0);
}
}
}
示例8: RestoreSurfaces
BOOL RestoreSurfaces(){ //restore all surfaces
BOOL result=TRUE;
if(FAILED(lpPrimary->Restore()))return FALSE;
if(FAILED(lpSecondary->Restore()))return FALSE;
if(SUCCEEDED(lpSecondary->Restore())) //if secondary restored
result=result&&background.draw(lpSecondary); //redraw image
else return FALSE;
if(g_pSprite[STARFIRE_OBJECT]->Restore()) //if starfire restored
result=result&&LoadStarfireSprite(); //redraw image
else return FALSE;
if(g_pSprite[GUNSHIP_OBJECT]->Restore()) //if enemies restored
result=result&&LoadEnemySprites(); //redraw image
else return FALSE;
if(g_pSprite[EXPLOSION_OBJECT]->Restore()) //if enemies restored
result=result&&LoadExplosions(); //redraw image
else return FALSE;
if(g_pSprite[BULLET_OBJECT]->Restore()) //if restored
result=result&&LoadExplosions(); //redraw image
else return FALSE;
if(g_pSprite[DRONE_OBJECT]->Restore()) //if restored
result=result&&LoadExplosions(); //redraw image
else return FALSE;
if(g_pSprite[BLASTER_OBJECT]->Restore()) //if restored
result=result&&LoadExplosions(); //redraw image
else return FALSE;
if(g_pSprite[ENEMY_BLASTER_OBJECT]->Restore()) //if restored
result=result&&LoadExplosions(); //redraw image
else return FALSE;
if(g_pSprite[POWER_OBJECT]->Restore()) //if restored
result=result&&LoadExplosions(); //redraw image
else return FALSE;
if(g_pSprite[SHIELD_OBJECT]->Restore()) //if restored
result=result&&LoadExplosions(); //redraw image
if(g_pSprite[BONUS_OBJECT]->Restore()) //if restored
result=result&&LoadExplosions(); //redraw image
else return FALSE;
return result;
} //RestoreSurfaces
示例9: InitSurfaces
//-----------------------------------------------------------------------------
// Name: RestoreAll()
// Desc: Restore all lost objects
//-----------------------------------------------------------------------------
HRESULT
RestoreAll()
{
HRESULT hRet;
hRet = g_pDDSPrimary->Restore();
if (hRet == DD_OK)
{
#if 0
hRet = g_pDDSOne->Restore();
if (hRet == DD_OK)
{
hRet = g_pDDSTwo->Restore();
if (hRet == DD_OK)
{
InitSurfaces();
}
}
#endif
}
return hRet;
}
示例10: DDCopyBitmap
/*
* DDCopyBitmap:
* draw a bitmap into a DirectDrawSurface
*/
HRESULT DDCopyBitmap(LPDIRECTDRAWSURFACE pdds, HBITMAP hbm, int x, int y, int dx, int dy)
{
HDC hdcImage;
HDC hdc;
BITMAP bm;
DDSURFACEDESC ddsd;
HRESULT hr;
if (hbm == NULL || pdds == NULL) {
return E_FAIL;
}
// make sure this surface is restored.
pdds->Restore();
// select bitmap into a memoryDC so we can use it.
hdcImage = CreateCompatibleDC(NULL);
if (!hdcImage) {
OutputDebugString("createcompatible dc failed\n");
}
SelectObject(hdcImage, hbm);
// get size of the bitmap
GetObject(hbm, sizeof(bm), &bm); // get size of bitmap
dx = dx == 0 ? bm.bmWidth : dx; // use the passed size, unless zero
dy = dy == 0 ? bm.bmHeight : dy;
// get size of surface.
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
pdds->GetSurfaceDesc(&ddsd);
if ((hr = pdds->GetDC(&hdc)) == DD_OK) {
StretchBlt(hdc, 0, 0, ddsd.dwWidth, ddsd.dwHeight, hdcImage, x, y, dx, dy, SRCCOPY);
pdds->ReleaseDC(hdc);
}
DeleteDC(hdcImage);
return hr;
}
示例11: restoreAll
BOOL restoreAll()
{
return PrimarySurface->Restore() == DD_OK &&
BackSurface->Restore() == DD_OK;
}
示例12: RestoreSurfaces
//-----------------------------------------------------------------------------
// Name: RestoreSurfaces()
// Desc:
//-----------------------------------------------------------------------------
HRESULT RestoreSurfaces()
{
HRESULT hr;
HBITMAP hbm;
if( FAILED( hr = g_pddsFrontBuffer->Restore() ) )
return hr;
if( FAILED( hr = g_pddsBackBuffer->Restore() ) )
return hr;
for( DWORD i=0; i<4; i++ )
if( FAILED( hr = g_pddsShip[i]->Restore() ) )
return hr;
// Create and set the palette for the splash bitmap
g_pSplashPalette = DDUtil_LoadPalette( g_pDD, TEXT("SPLASH") );
if( NULL == g_pSplashPalette )
return E_FAIL;
// Create and set the palette for the art bitmap
g_pArtPalette = DDUtil_LoadPalette( g_pDD, TEXT("Duel8") );
if( NULL == g_pArtPalette )
return E_FAIL;
// set the palette before loading the art
g_pddsFrontBuffer->SetPalette( g_pArtPalette );
hbm = (HBITMAP)LoadImage( GetModuleHandle(NULL), TEXT("Duel8"),
IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );
if( NULL == hbm )
return E_FAIL;
if( FAILED( hr = DDUtil_CopyBitmap( g_pddsShip[0], hbm, 0, 0, 320, 128 ) ) )
{
DeleteObject( hbm );
return E_FAIL;
}
if( FAILED( hr = DDUtil_CopyBitmap( g_pddsShip[1], hbm, 0, 128, 320, 128 ) ) )
{
DeleteObject( hbm );
return E_FAIL;
}
if( FAILED( hr = DDUtil_CopyBitmap( g_pddsShip[2], hbm, 0, 256, 320, 128 ) ) )
{
DeleteObject( hbm );
return E_FAIL;
}
if( FAILED( hr = DDUtil_CopyBitmap( g_pddsShip[3], hbm, 0, 384, 320, 128 ) ) )
{
DeleteObject( hbm );
return E_FAIL;
}
if( FAILED( hr = DDUtil_CopyBitmap( g_pddsNumbers, hbm, 0, 512, 320, 16 ) ) )
{
DeleteObject( hbm );
return E_FAIL;
}
DeleteObject( hbm );
// set colorfill colors and colorkeys according to bitmap contents
g_dwFillColor = DDUtil_ColorMatch( g_pddsShip[0], CLR_INVALID );
DDUtil_SetColorKey( g_pddsShip[0], CLR_INVALID );
DDUtil_SetColorKey( g_pddsShip[1], CLR_INVALID );
DDUtil_SetColorKey( g_pddsShip[2], CLR_INVALID );
DDUtil_SetColorKey( g_pddsShip[3], CLR_INVALID );
DDUtil_SetColorKey( g_pddsNumbers, CLR_INVALID );
return S_OK;
}
示例13: SimLoop
/********************************************************************
* Function : SimLoop()
* Purpose : Performs a single Simulation Loop iteration. Includes
* drawing.
********************************************************************/
int SimLoop(void)
{
static int nFramesPerSecond = 0;
static int nFramesSinceLastTick;
static DWORD LastTicks = 0;
DWORD Ticks;
HDC hDC;
HFONT hOldFont;
char s[80];
int slen;
DDSURFACEDESC ddsd;
DDBLTFX BltFx;
HRESULT ddreturn;
/* Perform a single step in our world. */
if (StepWorld(bForwardKey, bBackKey, bLeftKey, bRightKey, nState, nGauge))
{
if (lpPrimary->IsLost() == DDERR_SURFACELOST)
lpPrimary->Restore();
/* Clear the backbuffer. */
#if CLEARBCKGRND
BltFx.dwSize = sizeof(BltFx);
BltFx.dwFillColor = 255;
ddreturn = lpBackbuffer->Blt(NULL,
NULL,
NULL,
DDBLT_COLORFILL | DDBLT_WAIT,
&BltFx);
#else
ddreturn = DD_OK;
#endif
if (ddreturn == DD_OK)
{ /* While this is running, prepare
* the drawing. */
if (PrepDrawWorld())
{
/* Lock the surface. */
memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(ddsd);
ddreturn = lpBackbuffer->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL);
if (ddreturn == DD_OK)
{
DrawWorld((unsigned char *)ddsd.lpSurface, (int)ddsd.lPitch);
int nX, nY;
static unsigned char dummy;
unsigned char ni;
ni = 0;
for (nY = 0; nY < 16; nY++)
for (nX = 0; nX < 16; nX++)
{
/* Draw a small block at (nX * 3, nY * 3) */
((unsigned char *)ddsd.lpSurface)[(nY * 3 * ddsd.lPitch) + (nX * 3)] = ni;
((unsigned char *)ddsd.lpSurface)[(nY * 3 * ddsd.lPitch) + (nX * 3 + 1)] = ni;
((unsigned char *)ddsd.lpSurface)[((nY * 3 + 1) * ddsd.lPitch) + (nX * 3)] = ni;
((unsigned char *)ddsd.lpSurface)[((nY * 3 + 1) * ddsd.lPitch) + (nX * 3 + 1)] = ni;
ni++;
}
lpBackbuffer->Unlock(NULL);
/* And now write Frames per second. */
/* Increment Frame counter. */
nFramesSinceLastTick++;
/* Get system tick count. */
Ticks = GetTickCount();
/* Update fps value every second. */
if (Ticks > (LastTicks + 1000))
{ nFramesPerSecond = nFramesSinceLastTick;
nFramesSinceLastTick = 0;
LastTicks = Ticks;
}
/* Get a DC to the buffer & write count. */
if (DD_OK == lpBackbuffer->GetDC(&hDC))
{
SetBkMode(hDC, TRANSPARENT);
hOldFont = SelectObject(hDC, AppFont);
/* Build a string for display. */
slen = wsprintf(s, "FPS : %d", nFramesPerSecond);
/* And draw the text. */
SetTextColor(hDC, RGB(0,0,0));
SIZE sz;
GetTextExtentPoint32(hDC, s, slen, &sz);
RECT rc;
rc.top = 0;
rc.left = 16 * 3;
rc.right = 16 * 3 + sz.cx + 10;
rc.bottom = sz.cy + 10;
DrawFrameControl(hDC, &rc, DFC_BUTTON, DFCS_BUTTONPUSH);
TextOut(hDC, 16*3 + 5, 5, s, slen);
SelectObject(hDC, hOldFont);
lpBackbuffer->ReleaseDC(hDC);
}
//.........这里部分代码省略.........