2024-03-30 14:25:08 -03:00
|
|
|
|
#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"
|
2024-03-30 14:25:08 -03:00
|
|
|
|
|
|
|
|
|
namespace xna {
|
2024-04-16 16:13:36 -03:00
|
|
|
|
GraphicsDeviceManager::GraphicsDeviceManager(Game*& game) : _game(game) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GraphicsDeviceManager::Initialize() {
|
2024-04-01 11:29:32 -03:00
|
|
|
|
GraphicsDeviceInformation information;
|
2024-04-16 16:13:36 -03:00
|
|
|
|
|
2024-04-21 16:06:22 -03:00
|
|
|
|
auto adp = GraphicsAdapter::DefaultAdapter();
|
|
|
|
|
const PGraphicsAdapter sadp = std::move(adp);
|
|
|
|
|
information.Adapter(sadp);
|
2024-04-01 11:29:32 -03:00
|
|
|
|
information.GraphicsProfile(xna::GraphicsProfile::HiDef);
|
2024-04-16 16:13:36 -03:00
|
|
|
|
|
2024-04-01 11:29:32 -03:00
|
|
|
|
PresentationParameters parameters;
|
|
|
|
|
parameters.BackBufferWidth = _backBufferWidth;
|
|
|
|
|
parameters.BackBufferHeight = _backBufferHeight;
|
2024-04-23 16:11:17 -03:00
|
|
|
|
parameters.BackBufferFormat = SurfaceFormat::Color;
|
|
|
|
|
parameters.IsFullScreen = false;
|
2024-04-01 11:29:32 -03:00
|
|
|
|
information.PresentationParameters(parameters);
|
|
|
|
|
|
2024-04-16 16:13:36 -03:00
|
|
|
|
information.Window(_game->Window());
|
2024-04-01 11:29:32 -03:00
|
|
|
|
|
|
|
|
|
CreateDevice(information);
|
2024-04-16 16:13:36 -03:00
|
|
|
|
|
|
|
|
|
return true;
|
2024-04-01 11:29:32 -03:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-30 14:25:08 -03:00
|
|
|
|
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;
|
2024-03-30 14:25:08 -03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GraphicsDeviceManager::CreateDevice(GraphicsDeviceInformation const& info) {
|
2024-04-01 11:29:32 -03:00
|
|
|
|
_device = New<GraphicsDevice>(info);
|
2024-04-16 16:13:36 -03:00
|
|
|
|
auto window = info.Window();
|
2024-03-30 14:25:08 -03:00
|
|
|
|
|
2024-04-22 16:14:55 -03:00
|
|
|
|
window->Size(_backBufferWidth, _backBufferHeight);
|
|
|
|
|
|
2024-04-01 11:29:32 -03:00
|
|
|
|
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
|
|
|
|
|
2024-04-01 11:29:32 -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;
|
2024-03-30 14:25:08 -03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GraphicsDeviceManager::ChangeDevice() {
|
|
|
|
|
}
|
|
|
|
|
}
|