Archived

This topic is now archived and is closed to further replies.

ta_tee473

SetCooperativeLevel

Recommended Posts

I would like to using the SetCooperativeLevel function in window mode Example Fullscreen mode => DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN result => I can use the CreateSurface function(return of CreateSurface function DD_OK). Example Window mode => DDSCL_NORMAL result => I can''t use the CreateSurface function(return of CreateSurface function DDERR_NOEXCLUSIVEMODE). What I do? Example Window mode => (what parameters?)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
It seems that there is no problem, although insufficient information. Are not you about to create flippable surfaces in windowed mode?

Make sure that DDSURFACEDESC2 you specified does not include incorrect (or not available) flag.

Kwanji

Share this post


Link to post
Share on other sites
My source code .....

result = ddraw->SetCooperativeLevel(hwnd, DDSCL_NORMAL);
if(result != DD_OK){
return;
}
result = ddraw->SetDisplayMode(Width, Height, Color, 0, 0);
if(result != DD_OK){
return;
}

/* create primary surface */
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS|DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE|DDSCAPS_FLIP|DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;
result = ddraw->CreateSurface(&ddsd, &primary, NULL);

End My source code .....

result = DDERR_NOEXCLUSIVEMODE
How I do?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
When your application runs in windowed mode, you CAN NOT create a flippable surface. Here I show you a snippet to create double buffered surfaces in windowed mode.


  
DDSURFACEDESC2 ddsdPlan;
IDirectDraw7* DirectDraw;
IDirectDrawSurface7* SurfaceFront;
IDirectDrawSurface7* SurfaceBack;
IDirectDrawClipper* Clipper;
HWND hWindow; // application''s window handle.

// first, create front surface.

::ZeroMemory( &ddsdPlan, sizeof( DDSURFACEDESC2 ) );
ddsdPlan.dwSize = sizeof( DDSURFACEDESC2 );
ddsdPlan.dwFlags = DDSD_CAPS;
ddsdPlan.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
DirectDraw->CreateSurface( &ddsdPlan, &SurfaceFront, NULL );
// second, create back surface.

::ZeroMemory( &ddsdPlan, sizeof( DDSURFACEDESC2 ) );
ddsdPlan.dwSize = sizeof( DDSURFACEDESC2 );
ddsdPlan.dwFlags = DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH;
ddsdPlan.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN|DDSCAPS_3DDEVICE|DDSCAPS_VIDEOMEMORY;
ddsdPlan.dwWidth = ( WIDTH_OF_SCREEN );
ddsdPlan.dwHeight = ( HEIGHT_OF_SCREEN );
DirectDraw->CreateSurface( &ddsdPlan, &SurfaceBack, NULL );
// then, create a clipper object and attach it to the front surface.

DirectDraw->CreateClipper( 0, &Clipper, NULL );
Clipper->SetHWnd( 0, hWindow );
SurfaceFront->SetClipper( Clipper );

// you must use Blt() instead of Flip() for updating screen.

RECT rectScreen;
rectScreen.left = 0;
rectScreen.top = 0;
::ClientToScreen( hWindow, reinterpret_cast< POINT* >( &rectScreen ) );
rectScreen.right = rectScreen.left + ( WIDTH_OF_SCREEN );
rectScreen.bottom = rectScreen.top + ( HEIGHT_OF_SCREEN );
SurfaceFront->Blt( &rectScreen, SurfaceBack, NULL, DDBLT_WAIT, NULL );


I hope this helps you. Cheerio.

Kwanji

Share this post


Link to post
Share on other sites