diff --git a/framework/platform-dx/game.cpp b/framework/platform-dx/game.cpp index 51389c5..b128ff8 100644 --- a/framework/platform-dx/game.cpp +++ b/framework/platform-dx/game.cpp @@ -18,10 +18,6 @@ namespace xna { _gameComponents = snew(); } - Game::~Game() { - impl = nullptr; - } - void Game::Exit() { _gameWindow->impl->Close(); } @@ -147,4 +143,19 @@ namespace xna { sptr Game::Services() { return services; } sptr Game::Content() { return _contentManager; } void Game::EnableGameComponents(bool value) { _enabledGameComponents = value; } + + void Game::AttachGraphicsDevice(sptr const& device) { + graphicsDevice = device; + } + + void Game::ResizeWindow(int width, int heigth) { + const auto windowBounds = _gameWindow->ClientBounds(); + + if (windowBounds.Width != width || windowBounds.Height != heigth) { + _gameWindow->impl->Size( + width, + heigth); + _gameWindow->impl->Update(); + } + } } diff --git a/framework/platform-dx/gdevicemanager.cpp b/framework/platform-dx/gdevicemanager.cpp index b124720..13ee4f7 100644 --- a/framework/platform-dx/gdevicemanager.cpp +++ b/framework/platform-dx/gdevicemanager.cpp @@ -107,19 +107,12 @@ namespace xna { MassagePresentParameters(*newInfo.PresentParameters); ValidateGraphicsDeviceInformation(newInfo); - const auto windowBounds = game->Window()->ClientBounds(); - - if (windowBounds.Width != newInfo.PresentParameters->BackBufferWidth || windowBounds.Height != newInfo.PresentParameters->BackBufferHeight) { - game->Window()->impl->Size( - newInfo.PresentParameters->BackBufferWidth, - newInfo.PresentParameters->BackBufferHeight); - game->Window()->impl->Update(); - } + game->ResizeWindow(newInfo.PresentParameters->BackBufferWidth, newInfo.PresentParameters->BackBufferHeight); device = snew(newInfo.Adapter, newInfo.Profile, newInfo.PresentParameters); device->Initialize(); - game->graphicsDevice = this->device; + game->AttachGraphicsDevice(device); //device.DeviceResetting += new EventHandler(this.HandleDeviceResetting); //device.DeviceReset += new EventHandler(this.HandleDeviceReset); diff --git a/inc/xna/game/game.hpp b/inc/xna/game/game.hpp index 01d74c5..6f67ee5 100644 --- a/inc/xna/game/game.hpp +++ b/inc/xna/game/game.hpp @@ -8,7 +8,6 @@ namespace xna { class Game : public std::enable_shared_from_this { public: Game(); - ~Game(); void Exit(); int Run(); sptr Window(); @@ -18,6 +17,9 @@ namespace xna { sptr Content(); void EnableGameComponents(bool value); + void AttachGraphicsDevice(sptr const& graphicsDevice); + void ResizeWindow(int width, int heigth); + protected: virtual void Draw(GameTime const& gameTime); virtual void Initialize(); diff --git a/inc/xna/game/gdevicemanager.hpp b/inc/xna/game/gdevicemanager.hpp index 0c09a22..4f2b78e 100644 --- a/inc/xna/game/gdevicemanager.hpp +++ b/inc/xna/game/gdevicemanager.hpp @@ -1,9 +1,9 @@ #ifndef XNA_GAME_GRAPHICSDEVICEMANAGER_HPP #define XNA_GAME_GRAPHICSDEVICEMANAGER_HPP +#include "../csharp/eventhandler.hpp" #include "../default.hpp" #include "gdeviceinfo.hpp" -#include "../csharp/eventhandler.hpp" namespace xna { struct IGraphicsDeviceService { @@ -21,6 +21,7 @@ namespace xna { //virtual void EndDraw() = 0; }; + //Handles the configuration and management of the graphics device. class GraphicsDeviceManager : public IGraphicsDeviceService, public IGraphicsDeviceManager { public: //Creates a new GraphicsDeviceManager and registers it to handle the configuration and management of the graphics device for the specified Game. diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 45257e9..24ef843 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -4,4 +4,4 @@ # Add source to this project's executable. add_subdirectory ("01_blank") -add_subdirectory ("02_PlatfformerStarterKit") +#add_subdirectory ("02_PlatfformerStarterKit")