Sign in to follow this  
quaker

Fullscreen Mode?

Recommended Posts

Hi What window style should be used with a full screen D3D application, and is it correct to use the same normal window used in the windowed mode WS_OVERLAPPEDWINDOW for fullscreen mode switching? Thanks.

Share this post


Link to post
Share on other sites
Sorry I forget to add to my question:

Do I have to destroy and re-create the window, d3d resources even managed ones, when switching between windowed and fullscreen modes?

Share this post


Link to post
Share on other sites
I'd suggest using whatever window style the D3D samples use. It will be different between windowed and fullscreen.

Use SetWindowLong to change the window style. You must then call SetWindowPos to have the changes to the window style take effect. I seem to have it broken into sections, changing the style, doing the reset, then repositioning and resizing the window.


if (newMode != EWindowMode_Fullscreen)
{
RECT cli;

cli.left = cli.top = 0;
cli.right = g_WindowParameters.m_StoredWindowClientDimensionsX;
cli.bottom = g_WindowParameters.m_StoredWindowClientDimensionsY;
AdjustWindowRectEx(&cli, g_WindowParameters.m_nWindowedStyle, g_WindowParameters.m_bGameHasMenuBar, g_WindowParameters.m_nWindowedStyleEx);

SetWindowLong( g_pGfxDevInterface->m_d3dpp.hDeviceWindow, GWL_STYLE, g_WindowParameters.m_nWindowedStyle);
SetWindowLong( g_pGfxDevInterface->m_d3dpp.hDeviceWindow, GWL_EXSTYLE, g_WindowParameters.m_nWindowedStyleEx);
SetWindowPos(g_WindowParameters.m_hRenderWnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
g_pGfxDevInterface->Reset(false, false, false, true, false);
ShowWindow(g_WindowParameters.m_hRenderWnd, false);
SetWindowPos(g_WindowParameters.m_hRenderWnd, HWND_TOP,
g_WindowParameters.m_StoredWindowLocationX, g_WindowParameters.m_StoredWindowLocationY,
cli.right - cli.left, cli.bottom - cli.top,
SWP_DRAWFRAME | SWP_FRAMECHANGED);
ShowWindow(g_WindowParameters.m_hRenderWnd, true);
}
else
{
RECT rc;
GetWindowRect( g_WindowParameters.m_hRenderWnd, &rc);
g_WindowParameters.m_StoredWindowLocationX = rc.left;
g_WindowParameters.m_StoredWindowLocationY = rc.top;
GetClientRect( g_WindowParameters.m_hRenderWnd, &rc);
g_WindowParameters.m_StoredWindowClientDimensionsX = rc.right - rc.left;
g_WindowParameters.m_StoredWindowClientDimensionsY = rc.bottom - rc.top;
SetWindowLong( g_pGfxDevInterface->m_d3dpp.hDeviceWindow, GWL_STYLE, g_WindowParameters.m_nFullScreenStyle);
SetWindowLong( g_pGfxDevInterface->m_d3dpp.hDeviceWindow, GWL_EXSTYLE, g_WindowParameters.m_nFullScreenStyleEx);
SetWindowPos(g_WindowParameters.m_hRenderWnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
g_pGfxDevInterface->Reset(false, false, false, true, false);
ShowWindow(g_WindowParameters.m_hRenderWnd, false);
SetWindowPos(g_WindowParameters.m_hRenderWnd, HWND_TOP,
0, 0,
g_pGfxDevInterface->m_d3dpp.BackBufferWidth, g_pGfxDevInterface->m_d3dpp.BackBufferHeight,
SWP_FRAMECHANGED);
ShowWindow(g_WindowParameters.m_hRenderWnd, true);
}


Share this post


Link to post
Share on other sites
You want to use WS_POPUP for fullscreen windows.

Quote:
Original post by quaker
Sorry I forget to add to my question:

Do I have to destroy and re-create the window, d3d resources even managed ones, when switching between windowed and fullscreen modes?
You don't need to destroy the window or managed resources. The only thing you need to re-create are resources in the default pool (D3DPOOL_DEFAULT). You should also be using IDirect3DDevice9::Reset() to change between fullscreen and windowed mode, not destroying and re-creating your device.

Share this post


Link to post
Share on other sites
I'm not sure if you can use this and I'm more of an opengl person, but this code is Win32 and it's from the NeHe opengl tutorial in the setting up an opengl window, but before any opengl code is called.

DEVMODE dmScreenSettings; // Device Mode
memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // Makes Sure Memory's Cleared
dmScreenSettings.dmSize=sizeof(dmScreenSettings); // Size Of The Devmode Structure
dmScreenSettings.dmPelsWidth = width; // Selected Screen Width
dmScreenSettings.dmPelsHeight = height; // Selected Screen Height
dmScreenSettings.dmBitsPerPel = bits; // Selected Bits Per Pixel
dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;

if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
blah blah blah

this code is after the RegisterClass and before the CreateWindowEx call. He uses WS_EX_APPWINDOW and WS_POPUP for the window styles.

You can switch to full screen modes in resolutions other than what your current window resolution is. Like someone running 1200x1024 in windows but launching an 800x600 fullscreen app.

Maybe this isn't compatible with Direct3D for some reason but it is Win32 so maybe it will help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this