diff --git a/framework/game/game.hpp b/framework/game/game.hpp index 0278a33..c05451d 100644 --- a/framework/game/game.hpp +++ b/framework/game/game.hpp @@ -15,6 +15,7 @@ namespace xna { virtual void Exit() = 0; virtual int Run() = 0; virtual PGameWindow Window() = 0; + virtual PGraphicsDevice GetGraphicsDevice() = 0; protected: virtual void Draw(GameTime const& gameTime) = 0; diff --git a/framework/platform/game-dx.cpp b/framework/platform/game-dx.cpp index 59c44bc..50cfc8a 100644 --- a/framework/platform/game-dx.cpp +++ b/framework/platform/game-dx.cpp @@ -16,7 +16,7 @@ namespace xna { } int Game::Run() { - if (_graphicsDevice == nullptr) { + if (GraphicsDevice == nullptr) { MessageBox(nullptr, "O dispositivo gráfico não foi inicializar corretamente", "Xna Game Engine", MB_OK); return EXIT_FAILURE; } @@ -42,9 +42,7 @@ namespace xna { gameTime.ElapsedGameTime = elapsed - endElapsedTime; gameTime.TotalGameTime = _clock.TotalTime(); - this->Update(gameTime); - - //_graphicsDevice->Clear(); + this->Update(gameTime); elapsed = _clock.ElapsedTime(); gameTime.ElapsedGameTime = elapsed - endElapsedTime; @@ -52,7 +50,7 @@ namespace xna { this->Draw(gameTime); - _graphicsDevice->Present(); + GraphicsDevice->Present(); endElapsedTime = _clock.ElapsedTime(); } diff --git a/framework/platform/game-dx.hpp b/framework/platform/game-dx.hpp index 71e54ff..d4c3461 100644 --- a/framework/platform/game-dx.hpp +++ b/framework/platform/game-dx.hpp @@ -21,13 +21,17 @@ namespace xna { return _gameWindow; } + virtual PGraphicsDevice GetGraphicsDevice() override { + return GraphicsDevice; + } + protected: virtual void Draw(GameTime const& gameTime) override{} virtual void Initialize() override{} virtual void Update(GameTime const& gameTime) override{} public: - PGraphicsDevice _graphicsDevice{ nullptr }; + PGraphicsDevice GraphicsDevice{ nullptr }; protected: PGameWindow _gameWindow{ nullptr }; diff --git a/framework/platform/gdevicemanager-dx.cpp b/framework/platform/gdevicemanager-dx.cpp index 9fa3019..a486fe6 100644 --- a/framework/platform/gdevicemanager-dx.cpp +++ b/framework/platform/gdevicemanager-dx.cpp @@ -44,7 +44,7 @@ namespace xna { return; } - _game->_graphicsDevice = _device; + _game->GraphicsDevice = _device; } void GraphicsDeviceManager::ChangeDevice() { diff --git a/framework/xna.cpp b/framework/xna.cpp index 1f064cc..fd435ec 100644 --- a/framework/xna.cpp +++ b/framework/xna.cpp @@ -15,7 +15,7 @@ using namespace xna; class Game1 : public Game { public: Game1() { - manager = New(this); + graphics = New(this); } virtual void Update(GameTime const& gameTime) { @@ -24,13 +24,13 @@ public: } virtual void Draw(GameTime const& gameTime) { - _graphicsDevice->Clear(); + GraphicsDevice->Clear(); Game::Draw(gameTime); } private: - PGraphicsDeviceManager manager; + PGraphicsDeviceManager graphics; }; int APIENTRY WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) {