diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt index a0f3d55..cbb5e15 100644 --- a/framework/CMakeLists.txt +++ b/framework/CMakeLists.txt @@ -32,7 +32,7 @@ add_executable (xna WIN32 "platform/gamepad-dx.cpp" "platform/soundeffect-dx.cpp" "platform/displaymode-dx.cpp" -"platform/presentparameters-dx.cpp" + "game/component.cpp" "content/manager.cpp" "content/reader.cpp" diff --git a/framework/platform/device-dx.cpp b/framework/platform/device-dx.cpp index e62b6e7..e9f197c 100644 --- a/framework/platform/device-dx.cpp +++ b/framework/platform/device-dx.cpp @@ -18,7 +18,10 @@ namespace xna { GraphicsDevice::GraphicsDevice(GraphicsDeviceInformation const& info) { _adapter = info.Adapter(); _presentationParameters = info.PresentationParameters(); - _adapter->CurrentDisplayMode(_presentationParameters.backBufferFormat, _presentationParameters.backBufferWidth, _presentationParameters.backBufferHeight); + _adapter->CurrentDisplayMode( + _presentationParameters.BackBufferFormat, + _presentationParameters.BackBufferWidth, + _presentationParameters.BackBufferHeight); } bool GraphicsDevice::Initialize(GameWindow& gameWindow) { diff --git a/framework/platform/gdevicemanager-dx.cpp b/framework/platform/gdevicemanager-dx.cpp index 178d718..92cd3e7 100644 --- a/framework/platform/gdevicemanager-dx.cpp +++ b/framework/platform/gdevicemanager-dx.cpp @@ -3,7 +3,7 @@ #include "platform-dx/game-dx.hpp" #include "platform-dx/window-dx.hpp" #include "platform-dx/gdeviceinfo-dx.hpp" -#include "platform-dx/presentparameters-dx.hpp" +#include "graphics/presentparams.hpp" namespace xna { GraphicsDeviceManager::GraphicsDeviceManager(Game*& game) : _game(game) { @@ -12,10 +12,10 @@ namespace xna { _information.GraphicsProfile(xna::GraphicsProfile::HiDef); PresentationParameters parameters; - parameters.backBufferWidth = _backBufferWidth; - parameters.backBufferHeight = _backBufferHeight; - parameters.backBufferFormat = SurfaceFormat::Color; - parameters.fullscreen = false; + parameters.BackBufferWidth = _backBufferWidth; + parameters.BackBufferHeight = _backBufferHeight; + parameters.BackBufferFormat = SurfaceFormat::Color; + parameters.Fullscreen = false; _information.PresentationParameters(parameters); if(_game) _information.Window(_game->Window()); @@ -63,8 +63,8 @@ namespace xna { bool GraphicsDeviceManager::CreateDevice() { if (_isDeviceDirty) { - _information._parameters.backBufferWidth = _backBufferWidth; - _information._parameters.backBufferHeight = _backBufferHeight; + _information._parameters.BackBufferWidth = _backBufferWidth; + _information._parameters.BackBufferHeight = _backBufferHeight; } auto result = initWindow(); @@ -93,7 +93,7 @@ namespace xna { return false; } - _information._parameters.windowHandle = window->WindowHandle(); + _information._parameters.DeviceWindowHandle = reinterpret_cast(window->WindowHandle()); return true; } diff --git a/framework/platform/presentparameters-dx.cpp b/framework/platform/presentparameters-dx.cpp deleted file mode 100644 index 683d7df..0000000 --- a/framework/platform/presentparameters-dx.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "platform-dx/presentparameters-dx.hpp" -#include "platform-dx/gdevicemanager-dx.hpp" - -namespace xna { - PresentationParameters::PresentationParameters() : - backBufferWidth(GraphicsDeviceManager::DefaultBackBufferWidth), - backBufferHeight(GraphicsDeviceManager::DefaultBackBufferHeight) { - } -} - - diff --git a/framework/platform/swapchain-dx.cpp b/framework/platform/swapchain-dx.cpp index 36cfd10..0a735a2 100644 --- a/framework/platform/swapchain-dx.cpp +++ b/framework/platform/swapchain-dx.cpp @@ -47,23 +47,24 @@ namespace xna { const auto parameters = m_device->_presentationParameters; - dxDescription.Width = static_cast(parameters.backBufferWidth); - dxDescription.Height = static_cast(parameters.backBufferHeight); - dxDescription.Format = DxHelpers::ConvertSurfaceToDXGIFORMAT(parameters.backBufferFormat); + dxDescription.Width = static_cast(parameters.BackBufferWidth); + dxDescription.Height = static_cast(parameters.BackBufferHeight); + dxDescription.Format = DxHelpers::ConvertSurfaceToDXGIFORMAT(parameters.BackBufferFormat); dxDescription.SampleDesc.Count = 1; dxDescription.SampleDesc.Quality = 0; dxDescription.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; dxDescription.BufferCount = 2; - dxDescription.SwapEffect = static_cast(parameters.swapEffect); + dxDescription.SwapEffect = static_cast(parameters.PresentationSwapEffect); dxDescription.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; dxDescription.AlphaMode = DXGI_ALPHA_MODE::DXGI_ALPHA_MODE_UNSPECIFIED; dxFullScreenDescription.RefreshRate.Numerator = 60; dxFullScreenDescription.RefreshRate.Denominator = 1; dxFullScreenDescription.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; dxFullScreenDescription.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; - dxFullScreenDescription.Windowed = !parameters.fullscreen; + dxFullScreenDescription.Windowed = !parameters.Fullscreen; - return internalInit(*m_device, parameters.windowHandle, dxSwapChain, dxDescription, dxFullScreenDescription); + HWND hwnd = reinterpret_cast(parameters.DeviceWindowHandle); + return internalInit(*m_device, hwnd, dxSwapChain, dxDescription, dxFullScreenDescription); } bool SwapChain::Initialize(GameWindow const& gameWindow, DXGI_SWAP_CHAIN_DESC1 const& desc, DXGI_SWAP_CHAIN_FULLSCREEN_DESC const& fullScreenDesc, xna_error_ptr_arg) diff --git a/inc/forward.hpp b/inc/forward.hpp index 49f7324..335f2bc 100644 --- a/inc/forward.hpp +++ b/inc/forward.hpp @@ -64,7 +64,7 @@ namespace xna { class GraphicsAdapter; class GraphicsDevice; class GraphicsDeviceInformation; - class PresentationParameters; + struct PresentationParameters; class RenderTarget2D; class SwapChain; class Texture; diff --git a/inc/graphics/presentparams.hpp b/inc/graphics/presentparams.hpp index 86a4b0b..774fd97 100644 --- a/inc/graphics/presentparams.hpp +++ b/inc/graphics/presentparams.hpp @@ -4,13 +4,15 @@ #include "../default.hpp" namespace xna { - class IPresentationParameters { - virtual Uint BackBufferWidth() const = 0; - virtual Uint BackBufferHeight() const = 0; - virtual SurfaceFormat BackBufferFormat() const = 0; - virtual SwapEffect PresentationSwapEffect() const = 0; - virtual intptr_t DeviceWindowHandle() const = 0; - virtual bool IsFullScreen() const = 0; + struct PresentationParameters { + constexpr PresentationParameters() = default; + + Uint BackBufferWidth{ 0 }; + Uint BackBufferHeight{ 0 }; + SurfaceFormat BackBufferFormat{ SurfaceFormat::Color }; + SwapEffect PresentationSwapEffect{ SwapEffect::FlipDiscard }; + intptr_t DeviceWindowHandle{ 0 }; + bool Fullscreen{ false }; }; } diff --git a/inc/platform-dx/device-dx.hpp b/inc/platform-dx/device-dx.hpp index 7674866..c065cad 100644 --- a/inc/platform-dx/device-dx.hpp +++ b/inc/platform-dx/device-dx.hpp @@ -9,7 +9,7 @@ #include "gdeviceinfo-dx.hpp" #include "swapchain-dx.hpp" #include "window-dx.hpp" -#include "presentparameters-dx.hpp" +#include "graphics/presentparams.hpp" namespace xna { class GraphicsDevice : public IGraphicsDevice, public std::enable_shared_from_this { diff --git a/inc/platform-dx/gdeviceinfo-dx.hpp b/inc/platform-dx/gdeviceinfo-dx.hpp index f88142c..a5e760a 100644 --- a/inc/platform-dx/gdeviceinfo-dx.hpp +++ b/inc/platform-dx/gdeviceinfo-dx.hpp @@ -3,7 +3,7 @@ #include "../game/gdeviceinfo.hpp" #include "window-dx.hpp" -#include "presentparameters-dx.hpp" +#include "graphics/presentparams.hpp" namespace xna { class GraphicsDeviceInformation : public IGraphicsDeviceInformation { diff --git a/inc/platform-dx/implementations.hpp b/inc/platform-dx/implementations.hpp index 7658ce7..8bc18bc 100644 --- a/inc/platform-dx/implementations.hpp +++ b/inc/platform-dx/implementations.hpp @@ -9,7 +9,7 @@ #include "input/gamepad.hpp" #include "input/keyboard.hpp" #include "input/mouse.hpp" -#include "platform-dx/presentparameters-dx.hpp" +#include "graphics/presentparams.hpp" #include "platform-dx/rendertarget-dx.hpp" #include "platform-dx/swapchain-dx.hpp" diff --git a/inc/platform-dx/presentparameters-dx.hpp b/inc/platform-dx/presentparameters-dx.hpp deleted file mode 100644 index 27f8ef8..0000000 --- a/inc/platform-dx/presentparameters-dx.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef XNA_PLATFORM_PRESENTPARAMETERS_DX_HPP -#define XNA_PLATFORM_PRESENTPARAMETERS_DX_HPP - -#include "../graphics/presentparams.hpp" -#include "dxheaders.hpp" - -namespace xna { - class PresentationParameters : public IPresentationParameters { - public: - PresentationParameters(); - - virtual constexpr Uint BackBufferWidth() const override { - return backBufferWidth; - } - - virtual constexpr Uint BackBufferHeight() const override { - return backBufferHeight; - } - - virtual constexpr SurfaceFormat BackBufferFormat() const override { - return backBufferFormat; - } - - virtual constexpr SwapEffect PresentationSwapEffect() const override { - return swapEffect; - } - - virtual intptr_t DeviceWindowHandle() const override { - return reinterpret_cast(windowHandle); - } - - virtual constexpr bool IsFullScreen() const override { - return fullscreen; - } - - HWND DeviceWindowHWND() const { - return windowHandle; - } - - public: - Uint backBufferWidth {0 }; - Uint backBufferHeight{ 0 }; - SurfaceFormat backBufferFormat{ SurfaceFormat::Color }; - SwapEffect swapEffect{ SwapEffect::FlipDiscard }; - HWND windowHandle = nullptr; - bool fullscreen{ false }; - }; -} - -#endif \ No newline at end of file diff --git a/inc/platform-dx/xna-dx.hpp b/inc/platform-dx/xna-dx.hpp index 89441a8..a2d6468 100644 --- a/inc/platform-dx/xna-dx.hpp +++ b/inc/platform-dx/xna-dx.hpp @@ -7,7 +7,6 @@ #include "gdeviceinfo-dx.hpp" #include "gdevicemanager-dx.hpp" #include "init-dx.hpp" -#include "presentparameters-dx.hpp" #include "rasterizerstate-dx.hpp" #include "rendertarget-dx.hpp" #include "samplerstate-dx.hpp"