diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt index b7ae8c2..566b5d4 100644 --- a/framework/CMakeLists.txt +++ b/framework/CMakeLists.txt @@ -3,7 +3,7 @@ # # Add source to this project's executable. -add_executable (xna WIN32 "xna.cpp" "xna.h" "platform/window-dx.cpp" "platform/device-dx.cpp" "platform/adapter-dx.cpp" "platform/swapchain-dx.cpp" "platform/rendertarget-dx.cpp" "platform/texture-dx.cpp" "platform/blendstate-dx.cpp" "platform/game-dx.cpp" "platform/clock-dx.cpp" "csharp/stream.cpp" "platform/gdevicemanager-dx.cpp" "platform/vertexinput-dx.cpp" "platform/shader-dx.cpp" "platform/rasterizerstate-dx.cpp" "platform/vertexbuffer-dx.cpp" "platform/indexbuffer-dx.cpp" "common/matrix.cpp" "platform/constbuffer-dx.cpp" "platform/databuffer-dx.cpp" "platform/samplerstate-dx.cpp" "platform/spritebatch-dx.cpp" "platform/spritefont-dx.cpp" "platform/depthstencilstate-dx.cpp" "platform/keyboard-dx.cpp" "platform/mouse-dx.cpp" "platform/gamepad-dx.cpp" "common/vectors.cpp" "platform/soundeffect-dx.cpp" "platform/displaymode-dx.cpp") +add_executable (xna WIN32 "xna.cpp" "xna.h" "platform/window-dx.cpp" "platform/device-dx.cpp" "platform/adapter-dx.cpp" "platform/swapchain-dx.cpp" "platform/rendertarget-dx.cpp" "platform/texture-dx.cpp" "platform/blendstate-dx.cpp" "platform/game-dx.cpp" "platform/clock-dx.cpp" "csharp/stream.cpp" "platform/gdevicemanager-dx.cpp" "platform/vertexinput-dx.cpp" "platform/shader-dx.cpp" "platform/rasterizerstate-dx.cpp" "platform/vertexbuffer-dx.cpp" "platform/indexbuffer-dx.cpp" "common/matrix.cpp" "platform/constbuffer-dx.cpp" "platform/databuffer-dx.cpp" "platform/samplerstate-dx.cpp" "platform/spritebatch-dx.cpp" "platform/spritefont-dx.cpp" "platform/depthstencilstate-dx.cpp" "platform/keyboard-dx.cpp" "platform/mouse-dx.cpp" "platform/gamepad-dx.cpp" "common/vectors.cpp" "platform/soundeffect-dx.cpp" "platform/displaymode-dx.cpp" "platform/presentparameters-dx.cpp") if (CMAKE_VERSION VERSION_GREATER 3.12) set_property(TARGET xna PROPERTY CXX_STANDARD 20) diff --git a/framework/platform/gdeviceinfo-dx.hpp b/framework/platform/gdeviceinfo-dx.hpp index 0f3f1ef..d174fbf 100644 --- a/framework/platform/gdeviceinfo-dx.hpp +++ b/framework/platform/gdeviceinfo-dx.hpp @@ -19,19 +19,19 @@ namespace xna { _adapter = value; } - constexpr virtual xna::PresentationParameters PresentationParameters() const override{ + virtual xna::PresentationParameters PresentationParameters() const override{ return _parameters; }; - constexpr virtual void PresentationParameters(xna::PresentationParameters const& value) override{ + virtual void PresentationParameters(xna::PresentationParameters const& value) override{ _parameters = value; }; - constexpr virtual xna::GraphicsProfile GraphicsProfile() const override { + virtual xna::GraphicsProfile GraphicsProfile() const override { return _profile; }; - constexpr virtual void GraphicsProfile(xna::GraphicsProfile value) override { + virtual void GraphicsProfile(xna::GraphicsProfile value) override { _profile = value; }; diff --git a/framework/platform/gdevicemanager-dx.cpp b/framework/platform/gdevicemanager-dx.cpp index 8fa5eed..d656c69 100644 --- a/framework/platform/gdevicemanager-dx.cpp +++ b/framework/platform/gdevicemanager-dx.cpp @@ -41,13 +41,15 @@ namespace xna { BOOL state = false; auto hr = swap->dxSwapChain->GetFullscreenState(&state, nullptr); - if (FAILED(hr)) return; + if (FAILED(hr)) return false; hr = swap->dxSwapChain->SetFullscreenState(!state, nullptr); - if (FAILED(hr)) return; + if (FAILED(hr)) return false; _isFullScreen = !state; + + return true; } void GraphicsDeviceManager::PreferredBackBufferWidth(Int value) { @@ -66,10 +68,11 @@ namespace xna { _information._parameters.backBufferHeight = _backBufferHeight; } - initWindow(); - initDevice(); + auto result = initWindow(); + + if (!result) return false; - return true; + return initDevice(); } void GraphicsDeviceManager::ChangeDevice() { @@ -108,5 +111,7 @@ namespace xna { } _game->_graphicsDevice = _device; + + return true; } } \ No newline at end of file diff --git a/framework/platform/gdevicemanager-dx.hpp b/framework/platform/gdevicemanager-dx.hpp index e29c812..a961132 100644 --- a/framework/platform/gdevicemanager-dx.hpp +++ b/framework/platform/gdevicemanager-dx.hpp @@ -2,6 +2,7 @@ #define XNA_PLATFORM_GDEVICEMANAGER_DX_HPP #include "../game/gdevicemanager.hpp" +#include "gdeviceinfo-dx.hpp" namespace xna { class GraphicsDeviceManager : public IGraphicsDeviceManager { diff --git a/framework/platform/presentparameters-dx.cpp b/framework/platform/presentparameters-dx.cpp new file mode 100644 index 0000000..c0fef17 --- /dev/null +++ b/framework/platform/presentparameters-dx.cpp @@ -0,0 +1,11 @@ +#include "presentparameters-dx.hpp" +#include "gdevicemanager-dx.hpp" + +namespace xna { + PresentationParameters::PresentationParameters() : + backBufferWidth(GraphicsDeviceManager::DefaultBackBufferWidth), + backBufferHeight(GraphicsDeviceManager::DefaultBackBufferHeight) { + } +} + + diff --git a/framework/platform/presentparameters-dx.hpp b/framework/platform/presentparameters-dx.hpp index a084c52..27f8ef8 100644 --- a/framework/platform/presentparameters-dx.hpp +++ b/framework/platform/presentparameters-dx.hpp @@ -2,12 +2,13 @@ #define XNA_PLATFORM_PRESENTPARAMETERS_DX_HPP #include "../graphics/presentparams.hpp" -#include "gdevicemanager-dx.hpp" #include "dxheaders.hpp" namespace xna { class PresentationParameters : public IPresentationParameters { public: + PresentationParameters(); + virtual constexpr Uint BackBufferWidth() const override { return backBufferWidth; } @@ -37,8 +38,8 @@ namespace xna { } public: - Uint backBufferWidth { GraphicsDeviceManager::DefaultBackBufferWidth }; - Uint backBufferHeight{ GraphicsDeviceManager::DefaultBackBufferHeight }; + Uint backBufferWidth {0 }; + Uint backBufferHeight{ 0 }; SurfaceFormat backBufferFormat{ SurfaceFormat::Color }; SwapEffect swapEffect{ SwapEffect::FlipDiscard }; HWND windowHandle = nullptr;