directdraw en mode fenetre

directdraw en mode fenetre - C++ - Programmation

Marsh Posté le 25-12-2002 à 01:20:16    


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 :
  1. DDSURFACEDESC ddsd;
  2. if( FAILED( DirectDrawCreate(NULL, &pDD, NULL))){
  3.  MessageBox(NULL,"DirectDrawCreate() failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
  4.  return false;
  5. }
  6. if( FAILED( pDD->SetCooperativeLevel(hWnd, DDSCL_NORMAL))){
  7.  MessageBox(NULL,"SetCooperativeLevel() failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
  8.  return false;
  9. }
  10. ZeroMemory(&ddsd, sizeof(ddsd));
  11. ddsd.dwSize = sizeof(ddsd);
  12. ddsd.dwFlags = DDSD_CAPS ;
  13. ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
  14. if( FAILED( pDD->CreateSurface(&ddsd, &pDDSPrim, NULL))){
  15.  MessageBox(NULL,"CreatePrimarySurface() failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
  16.  return false;
  17. }
  18. if( FAILED(pDD->CreateClipper( 0, &pDDClip, NULL ))){
  19.  MessageBox(NULL,"CreateClipper() failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
  20.  return false;
  21. }
  22. if( FAILED(pDDClip->SetHWnd( 0, hWnd ))){
  23. MessageBox(NULL,"SetHWnd() failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
  24.  return false;
  25. }
  26. if( FAILED(pDDSPrim->SetClipper( pDDClip ))){
  27. MessageBox(NULL,"SetClipper() failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
  28.  return false;
  29. }
  30. ZeroMemory(&ddsd, sizeof(ddsd));
  31.     ddsd.dwSize = sizeof( ddsd );
  32.     ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
  33.     ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
  34.     ddsd.dwWidth = 640;
  35.     ddsd.dwHeight = 480;
  36.     // create the backbuffer separately
  37.     if( FAILED(pDD->CreateSurface( &ddsd, &pDDSBack, NULL ))){
  38. MessageBox(NULL,"CreateBackSurface() failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
  39.  return false;
  40. }
  41.  
  42. return true;
  43. }
  44. Flip()
  45. {
  46.     RECT rcRectSrc;
  47.     RECT rcRectDest;
  48.     POINT p;
  49.     p.x = 0; p.y = 0;
  50.     ClientToScreen(hWnd, &p);
  51.     GetClientRect(hWnd, &rcRectDest);
  52.     OffsetRect(&rcRectDest, p.x, p.y);
  53.     SetRect(&rcRectSrc, 0, 0, 640, 480);
  54.     pDDSPrim->Blt( &rcRectDest, pDDSBack, &rcRectSrc,DDBLTFAST_WAIT , NULL);
  55.     return false;
  56. }
  57. dans la boucle principale :
  58. SetRect(&rcRect, rand()%50, 0, 640, 480);
  59.  pDDSBack->BltFast( 0, 0, lpDDSOne, &rcRect,DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT);
  60.  Flip();

Reply

Marsh Posté le 25-12-2002 à 01:20:16   

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed