DirectX10 Fullscreen sample?
Everywhere online I find how to go to fullscreen using either alt+enter or use Swapchain->FullscreenState(true,NULL). As it is, when I do this, I get big black borders on the screen and the viewport is only a part of the entire screen.
How can I go fullscreen and change the display resolution of the monitor to match the client area of my window?
Thanks in advance.
To enable resolution switching, use the DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH for DXGI_SWAP_CHAIN_DESC::Flags when creating your swap-chain. Also use this flag for IDXGISwapChain::ResizeBuffers, which you should be using on WM_SIZE messages to resize the back-buffer. If the monitor doesn't support exactly the resolution of your client area, the resolution you actually get might be different, and always resize your buffers to match exactly the resolution whenever possible. You can use the IDXGISwapChain::ResizeTarget to set the screen-resolution, when using the flag to allow mode switch and fullscreen mode (in windowed mode this will change the window size instead). It's best to enumerate available modes for the display, and pass one of them to ResizeTarget, instead of relying on a pre-defined one that happens to work on your computer.
That's pretty much what I'm doing at the moment but I'm still getting those borders.
m_pSwapChain->SetFullscreenState(false,0); // Resize the swap chain and recreate the render target view. HR(m_pSwapChain->ResizeBuffers( 1, DXWINDOW->GetWidth(), DXWINDOW->GetHeight(), DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH)); DXGI_MODE_DESC requestedMode; requestedMode.Width = DXWINDOW->GetWidth(); requestedMode.Height = DXWINDOW->GetHeight(); requestedMode.RefreshRate.Numerator = 60; requestedMode.RefreshRate.Denominator = 1; requestedMode.Format = DXGI_FORMAT_R8G8B8A8_UNORM; requestedMode.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; requestedMode.Scaling = DXGI_MODE_SCALING_STRETCHED; m_pSwapChain->ResizeTarget(&requestedMode); if (DXWINDOW->GetFullScreen()) m_pSwapChain->SetFullscreenState(true,0);
What do you mean with borders?
Do they show up in a screenshot?
Might just be the monitor that isn't calibrated. I would use ResizeBuffers after ResizeTarget though, unless you already do that in WM_SIZE.
Do they show up in a screenshot?
Might just be the monitor that isn't calibrated. I would use ResizeBuffers after ResizeTarget though, unless you already do that in WM_SIZE.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement