red faction |
Voila , je cree une app en directdraw et affiche un bitmap, en plein ecran c impec, mais en mode fenetre ca rame (jaurais oublie qqch ???)
Code :
- DDSURFACEDESC ddsd;
- if( FAILED( DirectDrawCreate(NULL, &pDD, NULL))){
- MessageBox(NULL,"DirectDrawCreate() failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
- return false;
- }
- if( FAILED( pDD->SetCooperativeLevel(hWnd, DDSCL_NORMAL))){
- MessageBox(NULL,"SetCooperativeLevel() failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
- return false;
- }
- ZeroMemory(&ddsd, sizeof(ddsd));
- ddsd.dwSize = sizeof(ddsd);
- ddsd.dwFlags = DDSD_CAPS ;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
- if( FAILED( pDD->CreateSurface(&ddsd, &pDDSPrim, NULL))){
- MessageBox(NULL,"CreatePrimarySurface() failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
- return false;
- }
- if( FAILED(pDD->CreateClipper( 0, &pDDClip, NULL ))){
- MessageBox(NULL,"CreateClipper() failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
- return false;
- }
- if( FAILED(pDDClip->SetHWnd( 0, hWnd ))){
- MessageBox(NULL,"SetHWnd() failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
- return false;
- }
- if( FAILED(pDDSPrim->SetClipper( pDDClip ))){
- MessageBox(NULL,"SetClipper() failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
- return false;
- }
- ZeroMemory(&ddsd, sizeof(ddsd));
- ddsd.dwSize = sizeof( ddsd );
- ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- ddsd.dwWidth = 640;
- ddsd.dwHeight = 480;
- // create the backbuffer separately
- if( FAILED(pDD->CreateSurface( &ddsd, &pDDSBack, NULL ))){
- MessageBox(NULL,"CreateBackSurface() failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
- return false;
- }
-
- return true;
- }
- Flip()
- {
- RECT rcRectSrc;
- RECT rcRectDest;
- POINT p;
- p.x = 0; p.y = 0;
- ClientToScreen(hWnd, &p);
- GetClientRect(hWnd, &rcRectDest);
- OffsetRect(&rcRectDest, p.x, p.y);
- SetRect(&rcRectSrc, 0, 0, 640, 480);
- pDDSPrim->Blt( &rcRectDest, pDDSBack, &rcRectSrc,DDBLTFAST_WAIT , NULL);
- return false;
- }
- dans la boucle principale :
- SetRect(&rcRect, rand()%50, 0, 640, 480);
- pDDSBack->BltFast( 0, 0, lpDDSOne, &rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT);
- Flip();
|
|