From 4580196f6df62574cab8d7045ae05b0335c0b310 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 6 Feb 2018 15:37:25 -1000 Subject: [PATCH] Fix setWindowFrameDefault() for windows --- lib/graphicsdev/D3D11.cpp | 2 +- lib/graphicsdev/D3D12.cpp | 2 +- lib/win/WindowWin32.cpp | 24 +++++++++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/graphicsdev/D3D11.cpp b/lib/graphicsdev/D3D11.cpp index 67a5ec8..25eb4f2 100644 --- a/lib/graphicsdev/D3D11.cpp +++ b/lib/graphicsdev/D3D11.cpp @@ -1269,7 +1269,7 @@ class D3D11DataFactory : public ID3DDataFactory, public GraphicsDataFactoryHead m_gammaVFMT = ctx.newVertexFormat(2, vfmt); m_gammaShader = static_cast(ctx).newShaderPipeline(GammaVS, GammaFS, nullptr, nullptr, nullptr, m_gammaVFMT, BlendFactor::One, BlendFactor::Zero, - Primitive::TriStrips, ZTest::None, false, true, false, CullMode::None); + Primitive::TriStrips, ZTest::None, false, true, false, CullMode::None, true); m_gammaLUT = ctx.newDynamicTexture(256, 256, TextureFormat::I16, TextureClampMode::ClampToEdge); setDisplayGamma(1.f); const struct Vert { diff --git a/lib/graphicsdev/D3D12.cpp b/lib/graphicsdev/D3D12.cpp index 53402ec..cffdfbc 100644 --- a/lib/graphicsdev/D3D12.cpp +++ b/lib/graphicsdev/D3D12.cpp @@ -1688,7 +1688,7 @@ class D3D12DataFactory : public ID3DDataFactory, public GraphicsDataFactoryHead m_gammaVFMT = ctx.newVertexFormat(2, vfmt); m_gammaShader = static_cast(ctx).newShaderPipeline(GammaVS, GammaFS, nullptr, nullptr, nullptr, m_gammaVFMT, BlendFactor::One, BlendFactor::Zero, - Primitive::TriStrips, ZTest::None, false, true, false, CullMode::None); + Primitive::TriStrips, ZTest::None, false, true, false, CullMode::None, true); m_gammaLUT = ctx.newDynamicTexture(256, 256, TextureFormat::I16, TextureClampMode::ClampToEdge); setDisplayGamma(1.f); const struct Vert { diff --git a/lib/win/WindowWin32.cpp b/lib/win/WindowWin32.cpp index 3e44540..952337b 100644 --- a/lib/win/WindowWin32.cpp +++ b/lib/win/WindowWin32.cpp @@ -1022,8 +1022,18 @@ public: WindowWin32(SystemStringView title, Boo3DAppContextWin32& b3dCtx) { + const POINT ptZero = { 0, 0 }; + HMONITOR monitor = MonitorFromPoint(ptZero, MONITOR_DEFAULTTOPRIMARY); + MONITORINFO monInfo = {}; + monInfo.cbSize = sizeof(MONITORINFO); + GetMonitorInfo(monitor, &monInfo); + int x, y, w, h; + genFrameDefault(&monInfo, x, y, w, h); + RECT r = {x, y, x + w, y + h}; + AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW, FALSE); + m_hwnd = CreateWindowW(L"BooWindow", title.data(), WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + r.left, r.top, r.right - r.left, r.bottom - r.top, NULL, NULL, NULL, NULL); HINSTANCE wndInstance = HINSTANCE(GetWindowLongPtr(m_hwnd, GWLP_HINSTANCE)); m_imc = ImmGetContext(m_hwnd); @@ -1118,8 +1128,10 @@ public: void setWindowFrameDefault() { - MONITORINFO monInfo; - GetMonitorInfo(MonitorFromWindow(m_hwnd, MONITOR_DEFAULTTOPRIMARY), &monInfo); + MONITORINFO monInfo = {}; + monInfo.cbSize = sizeof(MONITORINFO); + HMONITOR mon = MonitorFromWindow(m_hwnd, MONITOR_DEFAULTTOPRIMARY); + GetMonitorInfo(mon, &monInfo); int x, y, w, h; genFrameDefault(&monInfo, x, y, w, h); setWindowFrame(x, y, w, h); @@ -1155,12 +1167,14 @@ public: void setWindowFrame(float x, float y, float w, float h) { - MoveWindow(m_hwnd, x, y, w, h, true); + setWindowFrame(int(x), int(y), int(w), int(h)); } void setWindowFrame(int x, int y, int w, int h) { - MoveWindow(m_hwnd, x, y, w, h, true); + RECT r = {x, y, x + w, y + h}; + AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW, FALSE); + MoveWindow(m_hwnd, r.left, r.top, r.right - r.left, r.bottom - r.top, true); } float getVirtualPixelFactor() const