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

76 lines
1.9 KiB
C++
Raw Normal View History

#include "gdevicemanager-dx.hpp"
#include "device-dx.hpp"
#include "game-dx.hpp"
#include "window-dx.hpp"
#include "gdeviceinfo-dx.hpp"
2024-04-22 16:14:55 -03:00
#include "adapter-dx.hpp"
namespace xna {
GraphicsDeviceManager::GraphicsDeviceManager(Game*& game) : _game(game) {
}
bool GraphicsDeviceManager::Initialize() {
GraphicsDeviceInformation information;
2024-04-21 16:06:22 -03:00
auto adp = GraphicsAdapter::DefaultAdapter();
const PGraphicsAdapter sadp = std::move(adp);
information.Adapter(sadp);
information.GraphicsProfile(xna::GraphicsProfile::HiDef);
PresentationParameters parameters;
parameters.BackBufferWidth = _backBufferWidth;
parameters.BackBufferHeight = _backBufferHeight;
2024-04-23 16:11:17 -03:00
parameters.BackBufferFormat = SurfaceFormat::Color;
parameters.IsFullScreen = false;
information.PresentationParameters(parameters);
information.Window(_game->Window());
CreateDevice(information);
return true;
}
void GraphicsDeviceManager::ApplyChanges() {
}
void GraphicsDeviceManager::ToggleFullScreen() {
2024-04-22 16:14:55 -03:00
if (!_game || !_game->_graphicsDevice || !_game->_graphicsDevice->_swapChain)
return;
auto& swap = _game->_graphicsDevice->_swapChain;
BOOL state = false;
2024-04-23 16:11:17 -03:00
auto hr = swap->dxSwapChain->GetFullscreenState(&state, nullptr);
if (FAILED(hr)) return;
hr = swap->dxSwapChain->SetFullscreenState(!state, nullptr);
if (FAILED(hr)) return;
_ifFullScreen = !state;
}
void GraphicsDeviceManager::CreateDevice(GraphicsDeviceInformation const& info) {
_device = New<GraphicsDevice>(info);
auto window = info.Window();
2024-04-22 16:14:55 -03:00
window->Size(_backBufferWidth, _backBufferHeight);
if (!window->Create()) {
MessageBox(nullptr, "Falha na cria<69><61>o da janela", "Xna Game Engine", MB_OK);
return;
}
2024-04-22 16:14:55 -03:00
if (!_device->Initialize(*window)) {
MessageBox(nullptr, "Falha na inicializa<7A><61>o do dispositivo gr<67>fico", "Xna Game Engine", MB_OK);
return;
}
2024-04-07 14:06:12 -03:00
_game->_graphicsDevice = _device;
}
void GraphicsDeviceManager::ChangeDevice() {
}
}