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:
parent
a6231a1fbd
commit
86a1d257b9
@ -18,10 +18,6 @@ namespace xna {
|
|||||||
_gameComponents = snew<GameComponentCollection>();
|
_gameComponents = snew<GameComponentCollection>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::~Game() {
|
|
||||||
impl = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::Exit() {
|
void Game::Exit() {
|
||||||
_gameWindow->impl->Close();
|
_gameWindow->impl->Close();
|
||||||
}
|
}
|
||||||
@ -147,4 +143,19 @@ namespace xna {
|
|||||||
sptr<GameServiceContainer> Game::Services() { return services; }
|
sptr<GameServiceContainer> Game::Services() { return services; }
|
||||||
sptr<ContentManager> Game::Content() { return _contentManager; }
|
sptr<ContentManager> Game::Content() { return _contentManager; }
|
||||||
void Game::EnableGameComponents(bool value) { _enabledGameComponents = value; }
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,19 +107,12 @@ namespace xna {
|
|||||||
MassagePresentParameters(*newInfo.PresentParameters);
|
MassagePresentParameters(*newInfo.PresentParameters);
|
||||||
ValidateGraphicsDeviceInformation(newInfo);
|
ValidateGraphicsDeviceInformation(newInfo);
|
||||||
|
|
||||||
const auto windowBounds = game->Window()->ClientBounds();
|
game->ResizeWindow(newInfo.PresentParameters->BackBufferWidth, newInfo.PresentParameters->BackBufferHeight);
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
device = snew<GraphicsDevice>(newInfo.Adapter, newInfo.Profile, newInfo.PresentParameters);
|
device = snew<GraphicsDevice>(newInfo.Adapter, newInfo.Profile, newInfo.PresentParameters);
|
||||||
device->Initialize();
|
device->Initialize();
|
||||||
|
|
||||||
game->graphicsDevice = this->device;
|
game->AttachGraphicsDevice(device);
|
||||||
|
|
||||||
//device.DeviceResetting += new EventHandler<EventArgs>(this.HandleDeviceResetting);
|
//device.DeviceResetting += new EventHandler<EventArgs>(this.HandleDeviceResetting);
|
||||||
//device.DeviceReset += new EventHandler<EventArgs>(this.HandleDeviceReset);
|
//device.DeviceReset += new EventHandler<EventArgs>(this.HandleDeviceReset);
|
||||||
|
@ -8,7 +8,6 @@ namespace xna {
|
|||||||
class Game : public std::enable_shared_from_this<Game> {
|
class Game : public std::enable_shared_from_this<Game> {
|
||||||
public:
|
public:
|
||||||
Game();
|
Game();
|
||||||
~Game();
|
|
||||||
void Exit();
|
void Exit();
|
||||||
int Run();
|
int Run();
|
||||||
sptr<GameWindow> Window();
|
sptr<GameWindow> Window();
|
||||||
@ -18,6 +17,9 @@ namespace xna {
|
|||||||
sptr<ContentManager> Content();
|
sptr<ContentManager> Content();
|
||||||
void EnableGameComponents(bool value);
|
void EnableGameComponents(bool value);
|
||||||
|
|
||||||
|
void AttachGraphicsDevice(sptr<GraphicsDevice> const& graphicsDevice);
|
||||||
|
void ResizeWindow(int width, int heigth);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Draw(GameTime const& gameTime);
|
virtual void Draw(GameTime const& gameTime);
|
||||||
virtual void Initialize();
|
virtual void Initialize();
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef XNA_GAME_GRAPHICSDEVICEMANAGER_HPP
|
#ifndef XNA_GAME_GRAPHICSDEVICEMANAGER_HPP
|
||||||
#define XNA_GAME_GRAPHICSDEVICEMANAGER_HPP
|
#define XNA_GAME_GRAPHICSDEVICEMANAGER_HPP
|
||||||
|
|
||||||
|
#include "../csharp/eventhandler.hpp"
|
||||||
#include "../default.hpp"
|
#include "../default.hpp"
|
||||||
#include "gdeviceinfo.hpp"
|
#include "gdeviceinfo.hpp"
|
||||||
#include "../csharp/eventhandler.hpp"
|
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
struct IGraphicsDeviceService {
|
struct IGraphicsDeviceService {
|
||||||
@ -21,6 +21,7 @@ namespace xna {
|
|||||||
//virtual void EndDraw() = 0;
|
//virtual void EndDraw() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Handles the configuration and management of the graphics device.
|
||||||
class GraphicsDeviceManager : public IGraphicsDeviceService, public IGraphicsDeviceManager {
|
class GraphicsDeviceManager : public IGraphicsDeviceService, public IGraphicsDeviceManager {
|
||||||
public:
|
public:
|
||||||
//Creates a new GraphicsDeviceManager and registers it to handle the configuration and management of the graphics device for the specified Game.
|
//Creates a new GraphicsDeviceManager and registers it to handle the configuration and management of the graphics device for the specified Game.
|
||||||
|
@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
# Add source to this project's executable.
|
# Add source to this project's executable.
|
||||||
add_subdirectory ("01_blank")
|
add_subdirectory ("01_blank")
|
||||||
add_subdirectory ("02_PlatfformerStarterKit")
|
#add_subdirectory ("02_PlatfformerStarterKit")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user