mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementações em ApplyChanges em GraphicsDeviceManager
This commit is contained in:
parent
60193f3a75
commit
6663aeb756
@ -39,9 +39,11 @@ namespace xna {
|
||||
|
||||
adp->supportedDisplayModes = getSupportedDisplayModes(pAdapter);
|
||||
|
||||
setCurrentDisplayMode(*adp->supportedDisplayModes, SurfaceFormat::Color,
|
||||
GraphicsDeviceManager::DefaultBackBufferWidth,
|
||||
GraphicsDeviceManager::DefaultBackBufferHeight, adp->currentDisplayMode);
|
||||
if (adp->supportedDisplayModes && adp->supportedDisplayModes->Count() > 0) {
|
||||
setCurrentDisplayMode(*adp->supportedDisplayModes, SurfaceFormat::Color,
|
||||
GraphicsDeviceManager::DefaultBackBufferWidth,
|
||||
GraphicsDeviceManager::DefaultBackBufferHeight, adp->currentDisplayMode);
|
||||
}
|
||||
|
||||
return adp;
|
||||
}
|
||||
@ -75,12 +77,14 @@ namespace xna {
|
||||
|
||||
setOutputVars(pAdapter, adp->deviceName, adp->monitorHandle);
|
||||
|
||||
setCurrentDisplayMode(*adp->supportedDisplayModes, SurfaceFormat::Color,
|
||||
GraphicsDeviceManager::DefaultBackBufferWidth,
|
||||
GraphicsDeviceManager::DefaultBackBufferHeight, adp->currentDisplayMode);
|
||||
|
||||
adp->supportedDisplayModes = getSupportedDisplayModes(pAdapter);
|
||||
|
||||
if (adp->supportedDisplayModes && adp->supportedDisplayModes->Count() > 0) {
|
||||
setCurrentDisplayMode(*adp->supportedDisplayModes, SurfaceFormat::Color,
|
||||
GraphicsDeviceManager::DefaultBackBufferWidth,
|
||||
GraphicsDeviceManager::DefaultBackBufferHeight, adp->currentDisplayMode);
|
||||
}
|
||||
|
||||
adapters.push_back(std::move(adp));
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ namespace xna {
|
||||
GraphicsDevice::GraphicsDevice(sptr<GraphicsAdapter> const& adapter, GraphicsProfile const& graphicsProfile, sptr<PresentationParameters> const& presentationParameters) {
|
||||
impl = unew<PlatformImplementation>();
|
||||
impl->_adapter = adapter;
|
||||
impl->_presentationParameters = presentationParameters;
|
||||
impl->_presentationParameters = presentationParameters;
|
||||
}
|
||||
|
||||
bool GraphicsDevice::Initialize() {
|
||||
|
@ -64,7 +64,12 @@ namespace xna {
|
||||
|
||||
int Game::Run() {
|
||||
try {
|
||||
Initialize();
|
||||
if (!_gameWindow->impl->Create()) {
|
||||
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||
return false;
|
||||
}
|
||||
|
||||
Initialize();
|
||||
|
||||
if (graphicsDevice == nullptr) {
|
||||
MessageBox(nullptr, "O dispositivo gráfico não foi inicializado corretamente", "XN65", MB_OK);
|
||||
|
@ -14,10 +14,8 @@ namespace xna {
|
||||
parameters->BackBufferHeight = backBufferHeight;
|
||||
parameters->BackBufferFormat = SurfaceFormat::Color;
|
||||
parameters->IsFullscreen = false;
|
||||
_information.PresentParameters = parameters;
|
||||
|
||||
if (game)
|
||||
_information.Window = game->Window();
|
||||
_information.PresentParameters = parameters;
|
||||
_information.Window = game->Window();
|
||||
}
|
||||
|
||||
bool GraphicsDeviceManager::Initialize() {
|
||||
@ -92,14 +90,13 @@ namespace xna {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void GraphicsDeviceManager::CreateDevice() {
|
||||
if (isDeviceDirty) {
|
||||
_information.PresentParameters->BackBufferWidth = backBufferWidth;
|
||||
_information.PresentParameters->BackBufferHeight = backBufferHeight;
|
||||
}
|
||||
|
||||
auto result = initWindow(_information, *game, backBufferWidth, backBufferHeight);
|
||||
//auto result = initWindow(_information, *game, backBufferWidth, backBufferHeight);
|
||||
|
||||
//if (!result) return false;
|
||||
|
||||
@ -135,29 +132,30 @@ namespace xna {
|
||||
device->Reset(deviceInformation->PresentParameters, deviceInformation->Adapter);
|
||||
//GraphicsDeviceManager.ConfigureTouchInput(deviceInformation.PresentationParameters);
|
||||
flag2 = false;
|
||||
}
|
||||
|
||||
if (flag2)
|
||||
CreateDevice(*bestDevice);
|
||||
|
||||
auto presentationParameters = device->PresentParameters();
|
||||
|
||||
screenDeviceName = device->Adapter()->DeviceName();
|
||||
|
||||
isReallyFullScreen = presentationParameters.IsFullscreen;
|
||||
|
||||
if (presentationParameters.BackBufferWidth != 0)
|
||||
clientWidth = presentationParameters.BackBufferWidth;
|
||||
|
||||
if (presentationParameters.BackBufferHeight != 0)
|
||||
clientHeight = presentationParameters.BackBufferHeight;
|
||||
|
||||
isDeviceDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag2)
|
||||
CreateDevice(*bestDevice);
|
||||
|
||||
auto presentationParameters = device->PresentParameters();
|
||||
|
||||
screenDeviceName = device->Adapter()->DeviceName();
|
||||
|
||||
isReallyFullScreen = presentationParameters.IsFullscreen;
|
||||
|
||||
if (presentationParameters.BackBufferWidth != 0)
|
||||
clientWidth = presentationParameters.BackBufferWidth;
|
||||
|
||||
if (presentationParameters.BackBufferHeight != 0)
|
||||
clientHeight = presentationParameters.BackBufferHeight;
|
||||
|
||||
isDeviceDirty = false;
|
||||
|
||||
//if (flag1) game->Window()->EndScreenDeviceChange(screenDeviceName, clientWidth, clientHeight);
|
||||
|
||||
currentWindowOrientation = game->Window()->CurrentOrientation();
|
||||
game->graphicsDevice = this->device;
|
||||
inDeviceTransition = false;
|
||||
}
|
||||
|
||||
@ -171,6 +169,7 @@ namespace xna {
|
||||
ValidateGraphicsDeviceInformation(newInfo);
|
||||
|
||||
device = snew<GraphicsDevice>(newInfo.Adapter, newInfo.Profile, newInfo.PresentParameters);
|
||||
device->Initialize();
|
||||
|
||||
//device.DeviceResetting += new EventHandler<EventArgs>(this.HandleDeviceResetting);
|
||||
//device.DeviceReset += new EventHandler<EventArgs>(this.HandleDeviceReset);
|
||||
@ -187,7 +186,7 @@ namespace xna {
|
||||
std::vector<uptr<GraphicsAdapter>> adapters;
|
||||
GraphicsAdapter::Adapters(adapters);
|
||||
|
||||
for (size_t i = 0; adapters.size(); ++i) {
|
||||
for (size_t i = 0; i < adapters.size(); ++i) {
|
||||
auto& adapter = adapters[i];
|
||||
|
||||
if (!anySuitableDevice) {
|
||||
@ -433,6 +432,9 @@ namespace xna {
|
||||
}
|
||||
|
||||
bool IsWindowOnAdapter(intptr_t windowHandle, GraphicsAdapter const& adapter) {
|
||||
return GameWindow::ScreenFromAdapter(adapter) == GameWindow::ScreenFromHandle(windowHandle);
|
||||
const auto fromAdapter = GameWindow::ScreenFromAdapter(adapter);
|
||||
const auto fromHandle = GameWindow::ScreenFromHandle(windowHandle);
|
||||
|
||||
return (fromAdapter && fromHandle) && (*fromAdapter == *fromHandle);
|
||||
}
|
||||
}
|
@ -85,7 +85,8 @@ namespace xna {
|
||||
winRect.bottom - winRect.top,
|
||||
TRUE);
|
||||
|
||||
return _windowHandle ? true : false;
|
||||
if (!_windowHandle)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -93,7 +94,9 @@ namespace xna {
|
||||
// GameWindow
|
||||
//
|
||||
|
||||
gameWindow->handle = reinterpret_cast<intptr_t>(_windowHandle);
|
||||
const auto handle = reinterpret_cast<intptr_t>(_windowHandle);
|
||||
|
||||
gameWindow->handle = handle;
|
||||
gameWindow->title = _windowTitle;
|
||||
gameWindow->clientBounds = { _windowPosX, _windowPosY, _windowWidth, _windowHeight };
|
||||
gameWindow->currentOrientation = DisplayOrientation::Default;
|
||||
@ -200,15 +203,14 @@ namespace xna {
|
||||
|
||||
if (screen->DeviceName() == adapter.DeviceName())
|
||||
return std::move(screen);
|
||||
}
|
||||
|
||||
Exception::Throw("Invalid screen adapter.");
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uptr<Screen> GameWindow::ScreenFromHandle(intptr_t windowHandle) {
|
||||
auto hMonitor = reinterpret_cast<HMONITOR>(windowHandle);
|
||||
const auto handle = reinterpret_cast<HWND>(windowHandle);
|
||||
auto hMonitor = MonitorFromWindow(handle, MONITOR_DEFAULTTOPRIMARY);
|
||||
|
||||
if (!hMonitor)
|
||||
return nullptr;
|
||||
|
@ -41,7 +41,7 @@ namespace xna {
|
||||
bool IsWindowMinimized() const;
|
||||
|
||||
inline static constexpr Int DefaultClientWidth = 800;
|
||||
inline static constexpr Int DefaultClientHeight = 600;
|
||||
inline static constexpr Int DefaultClientHeight = 480;
|
||||
|
||||
private:
|
||||
String title;
|
||||
@ -53,6 +53,7 @@ namespace xna {
|
||||
|
||||
public:
|
||||
struct PlatformImplementation;
|
||||
friend struct PlatformImplementation;
|
||||
uptr<PlatformImplementation> impl = nullptr;
|
||||
};
|
||||
}
|
||||
|
@ -778,7 +778,7 @@ namespace xna {
|
||||
|
||||
private:
|
||||
friend class GameWindow;
|
||||
GameWindow*& gameWindow;
|
||||
GameWindow* gameWindow = nullptr;
|
||||
|
||||
HINSTANCE _hInstance{ nullptr };
|
||||
HWND _windowHandle{ nullptr };
|
||||
|
@ -17,7 +17,8 @@ namespace xna {
|
||||
void Initialize() override {
|
||||
auto game = reinterpret_cast<Game*>(this);
|
||||
graphics = snew<GraphicsDeviceManager>(game->shared_from_this());
|
||||
graphics->Initialize();
|
||||
//graphics->Initialize();
|
||||
graphics->ApplyChanges();
|
||||
|
||||
std::any device = graphicsDevice;
|
||||
services->AddService(*typeof<GraphicsDevice>(), device);
|
||||
|
Loading…
x
Reference in New Issue
Block a user