boo/lib/win/UWPCommon.hpp

75 lines
2.2 KiB
C++
Raw Normal View History

2018-10-07 03:36:44 +00:00
#pragma once
#include "lib/win/WinCommon.hpp"
2018-12-08 05:17:51 +00:00
struct Boo3DAppContextUWP : Boo3DAppContext {
bool isFullscreen(const boo::IWindow* window) {
#if _WIN32_WINNT_WIN10
2018-12-08 05:17:51 +00:00
if (m_ctx12.m_dev) {
D3D12Context::Window& win = m_ctx12.m_windows[window];
BOOL isFScr;
win.m_swapChain->GetFullscreenState(&isFScr, nullptr);
return isFScr != 0;
}
#endif
2018-12-08 05:17:51 +00:00
if (m_ctx11.m_dev) {
D3D11Context::Window& win = m_ctx11.m_windows[window];
BOOL isFScr;
win.m_swapChain->GetFullscreenState(&isFScr, nullptr);
return isFScr != 0;
}
2018-12-08 05:17:51 +00:00
return false;
}
2018-12-08 05:17:51 +00:00
bool setFullscreen(boo::IWindow* window, bool fs) {
#if _WIN32_WINNT_WIN10
2018-12-08 05:17:51 +00:00
if (m_ctx12.m_dev) {
D3D12Context::Window& win = m_ctx12.m_windows[window];
BOOL isFScr;
win.m_swapChain->GetFullscreenState(&isFScr, nullptr);
if (fs && isFScr)
return false;
else if (!fs && !isFScr)
return false;
2018-12-08 05:17:51 +00:00
if (fs) {
ComPtr<IDXGIOutput> out;
win.m_swapChain->GetContainingOutput(&out);
DXGI_OUTPUT_DESC outDesc;
out->GetDesc(&outDesc);
2018-12-08 05:17:51 +00:00
win.m_swapChain->SetFullscreenState(true, nullptr);
DXGI_MODE_DESC mdesc = {UINT(outDesc.DesktopCoordinates.right - outDesc.DesktopCoordinates.left),
UINT(outDesc.DesktopCoordinates.bottom - outDesc.DesktopCoordinates.top)};
win.m_swapChain->ResizeTarget(&mdesc);
} else
win.m_swapChain->SetFullscreenState(false, nullptr);
return true;
}
#endif
2018-12-08 05:17:51 +00:00
if (m_ctx11.m_dev) {
D3D11Context::Window& win = m_ctx11.m_windows[window];
BOOL isFScr;
win.m_swapChain->GetFullscreenState(&isFScr, nullptr);
if (fs && isFScr)
return false;
else if (!fs && !isFScr)
return false;
2018-12-08 05:17:51 +00:00
if (fs) {
ComPtr<IDXGIOutput> out;
win.m_swapChain->GetContainingOutput(&out);
DXGI_OUTPUT_DESC outDesc;
out->GetDesc(&outDesc);
2018-12-08 05:17:51 +00:00
win.m_fsdesc.Width = outDesc.DesktopCoordinates.right;
win.m_fsdesc.Height = outDesc.DesktopCoordinates.bottom;
}
win.m_fs = fs;
win.m_needsFSTransition = true;
return true;
}
2018-12-08 05:17:51 +00:00
return false;
}
};