#ifndef BOO_WIN32COMMON_HPP #define BOO_WIN32COMMON_HPP #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS 1 /* STFU MSVC */ #endif #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif #include #include #include "boo/System.hpp" namespace boo {class IWindow;} #if _WIN32_WINNT_WIN10 #include #include #include struct D3D12Context { ComPtr m_dxFactory; ComPtr m_dev; ComPtr m_qalloc[2]; ComPtr m_q; ComPtr m_loadqalloc; ComPtr m_loadq; ComPtr m_loadfence; UINT64 m_loadfenceval = 0; HANDLE m_loadfencehandle; ComPtr m_loadlist; ComPtr m_rs; struct Window { ComPtr m_swapChain; UINT m_backBuf = 0; bool m_needsResize = false; size_t width, height; }; std::unordered_map m_windows; }; #elif _WIN32_WINNT_WIN7 #include #include #else #error Unsupported Windows target #endif struct D3D11Context { ComPtr m_dxFactory; ComPtr m_dev; ComPtr m_devCtx; struct Window { IDXGISwapChain1* m_swapChain; bool m_needsResize = false; size_t width, height; }; std::unordered_map m_windows; }; struct D3DAppContext { D3D11Context m_ctx11; #if _WIN32_WINNT_WIN10 D3D12Context m_ctx12; #endif void resize(boo::IWindow* window, size_t width, size_t height) { #if _WIN32_WINNT_WIN10 if (m_ctx12.m_dev) { m_ctx12.m_windows[window].width = width; m_ctx12.m_windows[window].height = height; m_ctx12.m_windows[window].m_needsResize = true; } else #endif { m_ctx11.m_windows[window].width = width; m_ctx11.m_windows[window].height = height; m_ctx11.m_windows[window].m_needsResize = true; } } }; struct HWNDEvent { UINT uMsg; WPARAM wParam; LPARAM lParam; HWNDEvent(UINT m, WPARAM w, LPARAM l) : uMsg(m), wParam(w), lParam(l) {} }; #endif // BOO_WIN32COMMON_HPP