Quick Example Code Snippets [Creating A DirectDraw Object] LPDIRECTDRAW lpDD; HRESULT ddrval; ddrval = DirectDrawCreate( NULL, &lpDD, NULL ); if( ddrval != DD_OK ) { // Do some error checking here } [Setting Cooperative Level] ddrval = lpDD->SetCooperativeLevel( hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN ); if( ddrval != DD_OK) { //Do some error checking here } [Setting Video Mode] ddrval = lpDD->SetDisplayMode( 640, 480, 8); if( ddrval != DD_OK) { //Do some error checking here } [Creating Primary Surface] LPDIRECTDRAWSURFACE lpDDSPrimary; DDURFACEDESC ddsd; HRESULT ddrval; //Clear all fields in structure memset( &&ddsd, 0, sizeof(ddsd) ); //Set flags in structure ddsd.dwSize = sizeof( ddsd ); ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; ddsd.dwBackBufferCount = 1; //Create Surface ddrval = lpDD->CreateSurface( &ddsd, &lpDDSPrimary, NULL ); [Creating Back Surface] DDSCAPS ddscaps; LPDIRECTDRAWSURFACE lpDDSBack; ddscaps.dwCaps = DDSCAPS_BACKBUFFER; ddrval = lpDDSPrimary->GetAttachedSurface( &ddscaps, &lpDDSBack ); if( ddrval != DD_OK ) { //Do error checking here } [Creating Offscreen Surface] LPDIRECTDRAWSURFACE lpDDSOffscreen; DDSURFACEDESC ddsd; HRESULT ddrval; ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.dwHeight = 480; ddsd.dwWidth = 640; ddrval = lpDD->CreateSurface( &ddsd, &lpDDSOffscreen, NULL ); if( ddrval != DD_OK ) { //Do error checking here } Discuss this article in the forums
See Also: © 1999-2011 Gamedev.net. All rights reserved. Terms of Use Privacy Policy
|