   Does anyone have a solid understanding about converting Exclusive to windowed mode?
  Trying to go from fullscreen to window modeSorry guys, i've checked documentation and couldn't find where my problem is.  I need info regarding my project and what I could be doing wrong:I have a bmp background which displays constantly, and everything else is a bmp sprite or clipped sprite etc.  I have followed the conversion tutorial which is a bit out of date (1999) and I couldn't contact the author so I thought I'd seek another means of help.  I feel like I have done everything he suggested, but there is something missing.  Anyone have any idea what I didn't do right?  ThanksHovig[edited by - Toonkides on February 4, 2004 3:23:24 AM]
  Have you tried looking at the samples? Most of the samples that come with the SDK (well, at least with the last several versions, I''m not sure which you''re using) can be viewed in either full-screen or windowed mode.  Sorry I can''t help you from specific knowledge, but I think you should be able to look at those and find the necessary steps.HTH ;  AFAIK, all that you need to switch from fullscreen to windowed mode is to set the appropriate flags in the device creation parameters. Of course, if you''re doing something funky with the back buffer, it may not work in windowed mode.Also, some *very* old video cards may support 3D in fullscreen but not in windowed mode, but it''s not really an issue you have to address unless you''re targeting that audience. ;  hmm, I am using page flipping with a secondary surface for exclusive mode, but when I go to windowed I need to use a backbuffer.  In order for me not to create a new variable I used the secondary surface as the backbuffer and blting as mentioned in tutorials etc.  I think that is not the problem--I am guessing it has something to do with drawing the bmp to the screen or the buffer, but perhaps the order I have it in from my exclusive mode needs major revision in order for the bmp background or the clipped sprites(bmp) to be displayed in windowed mode?I would love to post the code, but it will require a lot of time to sift through which I don''t expect anyone to giveThanks ;  Some more information might help; if you''re using DirectDraw or Direct3D, which version you''re using, how you''re copying the bitmap.  ;  I have dx9, but I am told Directdraw stopped at 8 or 7, so I am using the latest I would assume, here are some snippets of the code I am usingby function BOOL CreateSurfaces(BOOL bExclusive,int nWidth,int nHeight,int nBPP){if(bExclusive){// exclusive codeif(FAILED(DirectDrawCreate(NULL,&lpDirectDrawObject,NULL)))return FALSE;if(FAILED(lpDirectDrawObject->SetCooperativeLevel(hwnd,DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN)))return FALSE;if(FAILED(lpDirectDrawObject->SetDisplayMode(SCREEN_WIDTH,SCREEN_HEIGHT,COLOR_DEPTH)))return FALSE;DDSURFACEDESC ddsd;DDSCAPS ddscaps;ddsd.dwSize=sizeof(ddsd);ddsd.dwFlags=DDSD_CAPS|DDSD_BACKBUFFERCOUNT;ddsd.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE|DDSCAPS_FLIP|DDSCAPS_COMPLEX;ddsd.dwBackBufferCount=1;if(FAILED(lpDirectDrawObject->CreateSurface(&ddsd,&lpPrimary,NULL)))return FALSE;lpPrimaryPalette=CreatePalette(lpPrimary);ddscaps.dwCaps=DDSCAPS_BACKBUFFER;if(FAILED(lpPrimary->GetAttachedSurface(&ddscaps,&lpSecondary)))return FALSE;lpSecondaryPalette=CreatePalette(lpSecondary);ddsd.dwSize=sizeof(ddsd);ddsd.dwFlags=DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH;ddsd.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN;ddsd.dwHeight=SCREEN_HEIGHT;ddsd.dwWidth=SCREEN_WIDTH;if(FAILED(lpDirectDrawObject->CreateSurface(&ddsd,&lpBackground,NULL)))return FALSE;if(FAILED(lpDirectDrawObject->CreateClipper(NULL,&lpClipper,NULL)))return FALSE;if(FAILED(lpClipper->SetHWnd(NULL,hwnd)))return FALSE;if(FAILED(lpSecondary->SetClipper(lpClipper)))return FALSE;}else{// windowed code//if(FAILED(DirectDrawCreate(NULL,&lpDirectDrawObject,NULL)))//return FALSE;if(FAILED(lpDirectDrawObject->SetCooperativeLevel(hwnd,DDSCL_NORMAL)))return FALSE;//primary surfaceDDSURFACEDESC ddsd;ZeroMemory(&ddsd,sizeof(ddsd));ddsd.dwSize=sizeof(ddsd);ddsd.dwFlags=DDSD_CAPS;ddsd.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE;//backbuffer nowif(FAILED(lpDirectDrawObject->CreateSurface(&ddsd,&lpPrimary,NULL)))return FALSE;ZeroMemory(&ddsd,sizeof(ddsd));ddsd.dwSize=sizeof(ddsd);ddsd.dwFlags=DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT;ddsd.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN;ddsd.dwWidth=nWidth;ddsd.dwHeight=nHeight;//clipperif(FAILED(lpDirectDrawObject->CreateSurface(&ddsd,&lpSecondary,NULL)))return FALSE;if(FAILED(lpDirectDrawObject->CreateClipper(0,&lpClipper,NULL)))return FALSE;if(FAILED(lpClipper->SetHWnd(0,hwnd)))return FALSE;if(FAILED(lpPrimary->SetClipper(lpClipper)))return FALSE;}// save the modeg_bExclusive=bExclusive;return TRUE;}void DestroySurfaces(){if(g_bExclusive){// exclusive codeif(lpSecondary!=NULL)lpSecondary->Release();if(lpPrimary!=NULL)lpPrimary->Release();if(lpBackground!=NULL)lpBackground->Release();}else{//windowed codeif(lpSecondary!=NULL){lpSecondary->Release();lpSecondary=NULL;}if(lpPrimary!=NULL){// release the clipper (indirectly)lpPrimary->SetClipper(NULL);lpClipper=NULL;// release the primary surfacelpPrimary->Release();lpPrimary=NULL;}}for(int i=0;i<NUM_SPRITES;i++){if(g_pSprite[i])g_pSprite[i]->Release();delete g_pSprite[i];}lpDirectDrawObject->Release();lpDirectDrawObject=NULL;}BOOL PageFlip(){if(g_bExclusive){// exclusive codeif(lpPrimary->Flip(NULL,DDFLIP_WAIT)==DDERR_SURFACELOST)return RestoreSurfaces();}else{// windowed code// calculate the client rect in screen coodrinatesRECT rect;ZeroMemory(&rect,sizeof(rect));// get the client areaGetClientRect(hwnd,&rect);// copy the rect''s data into two pointsPOINT p1;POINT p2;p1.x=rect.left;p1.y=rect.top;p2.x=rect.right;p2.y=rect.bottom;// convert it to screen coordinates (like DirectDraw uses)ClientToScreen(hwnd,&p1);ClientToScreen(hwnd,&p2);// copy the two point'' data back into the rectrect.left=p1.x;rect.top=p1.y;rect.right=p2.x;rect.bottom=p2.y;// blit the back buffer to our window''s positionlpPrimary->Blt(&rect,lpSecondary ,NULL,DDBLT_WAIT,NULL);}return TRUE;}// I don''t know if this is needed, it''s a chunk of my compose fram// There was a call to Blt which I thought might be important to// windowed/exclusive so I added itBOOL ComposeFrame(){int i;RECT rect;GetClientRect(hwnd,&rect);rect.left=0; rect.right=SCREEN_WIDTH;rect.top=0; rect.bottom=SCREEN_HEIGHT;lpSecondary->Blt(&rect,lpBackground,&rect,DDBLT_WAIT,NULL);}HWND CreateDefaultWindow(char *name,HINSTANCE hInstance){WNDCLASS wc;wc.style=CS_HREDRAW|CS_VREDRAW;wc.lpfnWndProc=WindowProc;wc.cbClsExtra=wc.cbWndExtra=0;wc.hInstance=hInstance;wc.hIcon=LoadIcon(hInstance,IDI_APPLICATION);wc.hCursor=LoadCursor(NULL,IDC_ARROW);wc.hbrBackground=NULL;wc.lpszMenuName=NULL;wc.lpszClassName=name;RegisterClass(&wc);return CreateWindowEx(WS_EX_TOPMOST,name,name,WS_POPUP,0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN),NULL,NULL,hInstance,NULL);}This code will show you both the exclusive code and the windowed code.  Good luck ;  Oh.. man.. DirectDrawCreate()?  IIRC, you''re using a _really_ old version of DirectDraw.  Oh, and DD stopped at DX7.  I''m afraid my knowledge of graphics comes only with later versions of D3D (versions 8+), so I wouldn''t be much help.  Perhaps someone else could help you with DirectDraw code..subliminal message: might I suggest switching to Direct3D? ;--*waits patiently* ;  I found the problem, but I don't know how to fix it: if(FAILED(lpDirectDrawObject->SetCooperativeLevel(hwnd,DDSCL_NORMAL)))return FALSE;I thought i followed all the necessary precautions, but this is the cause--(found it by placing a windows message box before the call to setcoop and it popuped up--then after the call and evidently it returned FALSE)any suggestions?   [edited by - Toonkides on February 4, 2004 8:47:06 PM];  when you go from fullscreen to windowed mode you lose control of the output pixel format, so your code will have to be able to either change the desktop''s graphics mode (naughty program), or convert your output to the desktop''s pixel format.Theres a great article on gamasutra on pixel format conversions, but I wish you good luck. Its a damn useful thihng to be able to switch between the two once you get things running properly. So much easier to debug, for one. 