Switching from FullScreen to windowed problems

Hi!
I’m using SDL with DirectX. I’m initializing like that:

Code:

SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
SDL_SetVideoMode( width, height, 32, SDL_HWSURFACE | (fullScreen?SDL_FULLSCREEN:0));

After that I initialize DirectX, and draw everything manually by DX. Now, when I change my window from Windowed to FullScreen or otherwise I use that code:

Code:

d3dpp.Windowed = !d3dpp.Windowed;
SDL_WM_ToggleFullScreen(screenSurface);
//SDL_SetVideoMode( windowWidth, windowHeight, 32, SDL_HWSURFACE | (d3dpp.Windowed?0:SDL_FULLSCREEN));

//reseting D3D device, set DX settings

I tried both SDL_WM_ToggleFullScreen or SDL_SetVideoMode. Both works the same way for me. When I change from FullScreen to Windowed I get window without frame, minimize, close buttons like I’d use SDL_NOFRAME flag which I’m not using. BUT… When I minimize window (using taskbar) and then maximize I get normal window with border and minimize/close buttons. Also, when in NOFRAME state minimize/close buttons appear when there is mouse over it (border doesn’t appear).
Other problem I get is to make window 1024x768 resolution not including border. My window is 1024x768 but it’s full window including border so client rect is smaller and my graphic doesn’t look the same like I’d like to see it. I can make just bigger window f.e. 1100x770 or something but it’s not a solution I suppose. Users got different window settings in Windows OS and window would look different on other machines.

I’m waiting for replies :slight_smile:

Best,
ElChupacabra.

ElChupacabra wrote:

Hi!
After that I initialize DirectX, and draw everything manually by DX. Now, when I change my window from Windowed to FullScreen or otherwise I use that code:

Code:

d3dpp.Windowed = !d3dpp.Windowed;
SDL_WM_ToggleFullScreen(screenSurface);
//SDL_SetVideoMode( windowWidth, windowHeight, 32, SDL_HWSURFACE | (d3dpp.Windowed?0:SDL_FULLSCREEN));

//reseting D3D device, set DX settings

It looks like SDL_SetVideoMode or SDL_WM_ToggleFullScreen are both not working. Nothing changed when I remove those functions.

I think I solved it manually without using SDL functions.
For next generations:

Code:

void toggleFullScreen() {
d3dpp.Windowed = !d3dpp.Windowed; //D3DPRESENT_PARAMETERS struct
int w = windowWidth;
int h = windowHeight;

if(d3dpp.Windowed) {
	getRealWindowSize(&w, &h);
	MoveWindow(d3dpp.hDeviceWindow, 0, 0, w, h, true);
}
dxLog(pd3dDevice->Reset(&d3dpp)); //dxLog is just a function which write log if parameter is not D
initRenderState(); //pd3dDevice->setRenderState() functions
dxLog(pd3dDevice->BeginScene());
clear(); //d3d device clear()
drawingOn = true;

}

void getRealWindowSize(int *w, int *h) {
RECT rect;
rect.left = 0;
rect.right = *w;
rect.top = 0;
rect.bottom = *h;
AdjustWindowRect(&rect, WS_CAPTION, false);
*w = rect.right-rect.left;
*h = rect.bottom-rect.top;
}