1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00

Implementa AttachGraphicsDevice e ResizeWindow

This commit is contained in:
Danilo 2024-07-31 21:42:25 -03:00
parent a6231a1fbd
commit 86a1d257b9
5 changed files with 23 additions and 16 deletions

View File

@ -18,10 +18,6 @@ namespace xna {
_gameComponents = snew<GameComponentCollection>();
}
Game::~Game() {
impl = nullptr;
}
void Game::Exit() {
_gameWindow->impl->Close();
}
@ -147,4 +143,19 @@ namespace xna {
sptr<GameServiceContainer> Game::Services() { return services; }
sptr<ContentManager> Game::Content() { return _contentManager; }
void Game::EnableGameComponents(bool value) { _enabledGameComponents = value; }
void Game::AttachGraphicsDevice(sptr<GraphicsDevice> 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();
}
}
}

View File

@ -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<GraphicsDevice>(newInfo.Adapter, newInfo.Profile, newInfo.PresentParameters);
device->Initialize();
game->graphicsDevice = this->device;
game->AttachGraphicsDevice(device);
//device.DeviceResetting += new EventHandler<EventArgs>(this.HandleDeviceResetting);
//device.DeviceReset += new EventHandler<EventArgs>(this.HandleDeviceReset);

View File

@ -8,7 +8,6 @@ namespace xna {
class Game : public std::enable_shared_from_this<Game> {
public:
Game();
~Game();
void Exit();
int Run();
sptr<GameWindow> Window();
@ -18,6 +17,9 @@ namespace xna {
sptr<ContentManager> Content();
void EnableGameComponents(bool value);
void AttachGraphicsDevice(sptr<GraphicsDevice> const& graphicsDevice);
void ResizeWindow(int width, int heigth);
protected:
virtual void Draw(GameTime const& gameTime);
virtual void Initialize();

View File

@ -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.

View File

@ -4,4 +4,4 @@
# Add source to this project's executable.
add_subdirectory ("01_blank")
add_subdirectory ("02_PlatfformerStarterKit")
#add_subdirectory ("02_PlatfformerStarterKit")