本文整理汇总了C++中LPDIRECTDRAWSURFACE7::Restore方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE7::Restore方法的具体用法?C++ LPDIRECTDRAWSURFACE7::Restore怎么用?C++ LPDIRECTDRAWSURFACE7::Restore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTDRAWSURFACE7
的用法示例。
在下文中一共展示了LPDIRECTDRAWSURFACE7::Restore方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vdraw_ddraw_restore_graphics
/**
* vdraw_ddraw_restore_graphics(): Restore the DirectDraw surface if it is lost.
* @return HRESULT.
*/
HRESULT vdraw_ddraw_restore_graphics(void)
{
HRESULT rval1 = lpDDS_Primary->Restore();
HRESULT rval2 = lpDDS_Back->Restore();
// Modif N. -- fixes lost surface handling when the color depth has changed
if (rval1 == DDERR_WRONGMODE || rval2 == DDERR_WRONGMODE)
return vdraw_ddraw_init() ? DD_OK : DDERR_GENERIC;
return SUCCEEDED(rval2) ? rval1 : rval2;
}
示例2: Flip
//-----------------------------------------------------------------------------
// Name: Flip()
// Desc: this function flips a surface onto the primary surface
//-----------------------------------------------------------------------------
int Flip(LPDIRECTDRAWSURFACE7 lpddsSurface, RECT destrect)
{// this function flips a surface onto the primary surface
//Blt the frame
ddReturnVal = lpddsPrimary->Blt(&destrect/*dest rect*/,lpddsSurface, //pointer to source surface
NULL, //pointer to the source rectangle
DDBLT_WAIT | DDBLT_KEYSRC, NULL/*ddbltfx struct*/);//NULL means entire surface
if(ddReturnVal!=DD_OK)
if(ddReturnVal==DDERR_SURFACELOST)
{ OutputDebugString("Surfacelost Flip(RECT)\n"); lpddsSurface->Restore(); lpddsPrimary->Restore(); return(1); }
else
if (DDFailedCheck(ddReturnVal, "Flip(lpddsSurface, RECT), Blt failed", cpErrorBuf ))
{ MessageBox(NULL, cpErrorBuf, "SurfaceFuncs", MB_ICONEXCLAMATION); return(0); }
return 1;
}
示例3: dx_CopieBitmap
//-----------------------------------------------------------------------------
// Name: dx_CopieBitmap(...)
// Desc: Copie le contenu d'un bitmap dans le buffer d'affichage
//-----------------------------------------------------------------------------
bool dx_CopieBitmap (HBITMAP pBitmap, uint16 pPosX, uint16 pTailleX,
uint16 pPosY, uint16 pTailleY)
{
HDC hdcImage;
HDC hdc;
BITMAP bm;
if (pBitmap == NULL) return false;
SurfaceBack->Restore();
hdcImage = CreateCompatibleDC (NULL);
SelectObject (hdcImage, pBitmap);
GetObject (pBitmap, sizeof(bm), &bm);
pTailleX = pTailleX == 0 ? bm.bmWidth : pTailleX;
pTailleY = pTailleY == 0 ? bm.bmHeight : pTailleY;
SurfaceBack->GetDC(&hdc);
BitBlt (hdc, pPosX, pPosY, pTailleX, pTailleY, hdcImage, 0, 0, SRCCOPY);
SurfaceBack->ReleaseDC(hdc);
DeleteDC (hdcImage);
return true;
}
示例4: DDAccurateUpdateDisplay
void DDAccurateUpdateDisplay(bool singlestep)
{
static int framecounter=0;
HRESULT hRet;
RECT rDest;
if (++framecounter > zx81.frameskip || singlestep)
framecounter=0;
else
return;
DDFrame->Unlock(NULL);
POINT p = {0, 0};
if(!Form1->FullScreen) p=Form1->ClientToScreen(p);
rDest=rcdest;
rDest.left += p.x;
rDest.top += p.y;
rDest.right += p.x;
rDest.bottom += p.y;
//if (Form1->FullScreen) DDDrawBorder();
while(1)
{
hRet = m_pddsFrontBuffer->Blt(&rDest, DDFrame, &rcsource, DDBLT_WAIT, NULL);
if (hRet == DD_OK) break;
else
if(hRet == DDERR_SURFACELOST)
{
m_pddsFrontBuffer->Restore();
m_pddsFrame->Restore();
}
else if(hRet != DDERR_WASSTILLDRAWING) return;
}
DDFrame->Lock(NULL, &DDFrameSurface, DDLOCK_WAIT | DDLOCK_NOSYSLOCK, NULL);
dest=buffer= (BYTE*)DDFrameSurface.lpSurface;
}
示例5: FlipToClient
//-----------------------------------------------------------------------------
// Name: Flip()
// Desc: this function flips a surface onto the primary surface
// primary surface expected to be a normal window (non-fullscreen).
// flips to client area only
//-----------------------------------------------------------------------------
int FlipToClient(LPDIRECTDRAWSURFACE7 lpddsSurface)
{// this function flips a surface onto the primary surface
static RECT temp;
GetWindowRect(main_window_handle, &temp);
temp.top +=20;
temp.left +=4;
temp.right -=4;
temp.bottom -=4;
//Blt the frame
ddReturnVal = lpddsPrimary->Blt(&temp/*dest rect*/,lpddsSurface, //pointer to source surface
NULL, //pointer to the source rectangle
DDBLT_WAIT | DDBLT_KEYSRC, NULL/*ddbltfx struct*/);//NULL means entire surface
if(ddReturnVal!=DD_OK)
if(ddReturnVal==DDERR_SURFACELOST)
{ OutputDebugString("Surfacelost FlipToClient()\n"); lpddsSurface->Restore(); lpddsPrimary->Restore(); return(1); }
else
if (DDFailedCheck(ddReturnVal, "FlipToClient(lpddsSurface), Blt failed", cpErrorBuf ))
{ MessageBox(NULL, cpErrorBuf, "SurfaceFuncs", MB_ICONEXCLAMATION); return(0); }
return 1;
}
示例6: ProcessIdle
void ProcessIdle()
{
HRESULT hRet;
static int iX = 0, iY = 0;
static iLastBlit;
if(GetTickCount() - iLastBlit < 50)
{
return;
}
g_surfCar.Draw(g_pDDSBack, 245, 170, iX, iY, 150, 140);
while( 1 )
{
hRet = g_pDDSFront->Flip(NULL, 0 );
if( hRet == DD_OK )
{
break;
}
if( hRet == DDERR_SURFACELOST )
{
g_pDDSFront->Restore();
}
if( hRet != DDERR_WASSTILLDRAWING )
{
break;
}
}
iX += 150;
if(iX >= 1500)
{
iX = 0;
iY += 140;
if(iY >= 280)
{
iY = 0;
}
}
iLastBlit = GetTickCount();
}
示例7: Lock
//-----------------------------------------------------------------------------
// Name: Lock()
// Desc: Fucntion to lock the entire surface
//-----------------------------------------------------------------------------
int Lock(LPDIRECTDRAWSURFACE7 lpddsSurface)
{
memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddReturnVal = lpddsSurface->Lock(NULL,&ddsd,DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);
if (DDFailedCheck(ddReturnVal, "Lock() failed", cpErrorBuf ))
{
if(ddReturnVal==DDERR_SURFACELOST)
{
lpddsSurface->Restore();
return(1);
}
else
{
MessageBox(main_window_handle, cpErrorBuf, "Lock()", MB_ICONEXCLAMATION);
return(0);
}
}
return (1);
}
示例8: Restore
HRESULT STDMETHODCALLTYPE Restore(LPDIRECTDRAWSURFACE7 surface)
{
//logOutput << CurrentTimeString() << "Hooked Restore()" << endl;
ddrawSurfaceRestore.Unhook();
HRESULT hr = surface->Restore();
if (bHasTextures)
{
if (surface == g_frontSurface)
{
logOutput << CurrentTimeString() << "SurfaceRestore: restoring offscreen buffers" << endl;
bool success = true;
for (UINT i = 0; i < NUM_BUFFERS; i++)
{
HRESULT err;
if (FAILED(err = ddCaptures[i]->Restore()))
{
logOutput << CurrentTimeString() << "SurfaceRestore: error restoring offscreen buffer" << endl;
printDDrawError(err, "Restore");
success = false;
}
}
if (!success)
{
CleanUpDDraw();
}
}
}
ddrawSurfaceRestore.Rehook();
if (!bHasTextures)
{
getFrontSurface(surface);
}
return hr;
}
示例9: Draw
// Draw video to DirectDraw surface.
BOOL CDShow::Draw(LPDIRECTDRAWSURFACE7 lpDDSurface7)
{
// Return FALSE if media was not open
if (!m_bMediaOpen) {
return FALSE;
}
// Update media stream.
// If it does not return S_OK, we are not playing.
if (m_pSample->Update(0,NULL,NULL,0)!=S_OK) {
m_bPlaying=FALSE;
}
// Now blit video to specified surface and rect.
// Restore surface if lost.
if (lpDDSurface7->Blt(NULL,m_pDDSurface7, &m_rSrcRect,DDBLT_WAIT,NULL)==DDERR_SURFACELOST)
lpDDSurface7->Restore();
// Ok. return TRUE.
return TRUE;
}
示例10: main
////FUNCTIONS//////////////////
//-----------------------------------------------------------------------------
// Name: Main()
// Desc: Whwere all work is done
//-----------------------------------------------------------------------------
bool main()
{
static SCCOLOR col;
static UCHAR* back_buf;
static HDC hDC;
static int iFrames=0;
static int x=0;
col.b = col.r = col.g = 255;
if(GetKeyStatus(VK_ESCAPE) == true)
return(0);
//Clear the surface
if(!ClrS(lpddsSecondary,wndRect))//can't be within a lock-Unlock block or u can't blt
return(0);
//Write text to the Secondary surface remember to Release the DC
ddReturnVal = lpddsSecondary->GetDC(&hDC);
if (DDFailedCheck(ddReturnVal, "GetDC() failed", cpErrorBuf ))
{
if(ddReturnVal == DDERR_SURFACELOST)
{
lpddsSecondary->Restore();
lpddsSecondary->GetDC(&hDC);
}
else
{
MessageBox(main_window_handle, cpErrorBuf, "main()", MB_ICONEXCLAMATION);
return(0);
}
}
static char buffer[1024];
SetBkColor(hDC,RGB(0,0,0));
SetBkMode(hDC,OPAQUE);
sprintf(buffer, "Time elapsed(s)= %d", (int)(gametimer.GetStartElapsedTime()*0.001) );//0.00001666666f
static DWORD starttime=GetTickCount();
if( gametimer.Elapsed(starttime,(60/0.001)) )
sprintf(buffer,"TIME!"," 1 minute");
SetTextColor(hDC,RGB(255,255,255));
iFrames++;
static int FramesPerSec=0;
FramesPerSec = iFrames/( ((int)(gametimer.GetStartElapsedTime()*0.001)+1) );
sprintf(buffer, "Frames/s = %d", FramesPerSec);
TextOut(hDC, 100,100, buffer, strlen(buffer));
sprintf(buffer, "X= %d", x);
TextOut(hDC, 100,140, buffer, strlen(buffer));
ddReturnVal = lpddsSecondary->ReleaseDC(hDC);
if (DDFailedCheck(ddReturnVal, "ReleaseDC() failed", cpErrorBuf ))
{
MessageBox(main_window_handle, cpErrorBuf, "main()", MB_ICONEXCLAMATION);
return(0);
}
//Lock the surface for drawing
if(!Lock(lpddsSecondary))
return(0);
back_buf = (UCHAR*)ddsd.lpSurface;
//test drawing pixels
DrawPixel(ddsd,x+200,100,col);
DrawPixel(ddsd,x+200,101,col);
DrawPixel(ddsd,x+200,102,col);
DrawPixel(ddsd,x+200,103,col);
DrawPixel(ddsd,x+200,104,col);
DrawPixel(ddsd,x+200,105,col);
DrawPixel(ddsd,x+200,106,col);
DrawPixel(ddsd,x+200,107,col);
DrawPixel(ddsd,x+200,108,col);
x++;
if(x>780)
x=0;
//test bitmap class
for (int y=0; y < bitmap1.GetHeight(); y++)
{
// copy the line
memcpy(&back_buf[100+(y+200)*ddsd.lPitch], // dest address
&bitmap1.GetImageData()[y*bitmap1.GetWidth()*2], // src address
bitmap1.GetWidth()*2); // bytes to copy
} // end for y
//Unlock the surface
if(!UnLock(lpddsSecondary))
return(0);
if(!Lock(Temp))
return(0);
back_buf = (UCHAR*)ddsd.lpSurface;
for (int y=0; y < bitmap2.GetHeight(); y++)
{
// copy the line
//.........这里部分代码省略.........