mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementa segunda sobrecarga GraphicsDeviceManager::AddDevices
This commit is contained in:
parent
7dfd3b3fbd
commit
38e6779e12
@ -101,7 +101,7 @@ namespace xna {
|
|||||||
|
|
||||||
impl->_adapter = info.Adapter;
|
impl->_adapter = info.Adapter;
|
||||||
impl->_gameWindow = info.Window;
|
impl->_gameWindow = info.Window;
|
||||||
impl->_presentationParameters = info.Parameters;
|
impl->_presentationParameters = info.PresentParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GraphicsDevice::Initialize() {
|
bool GraphicsDevice::Initialize() {
|
||||||
|
@ -13,8 +13,8 @@ namespace xna {
|
|||||||
parameters->BackBufferWidth = backBufferWidth;
|
parameters->BackBufferWidth = backBufferWidth;
|
||||||
parameters->BackBufferHeight = backBufferHeight;
|
parameters->BackBufferHeight = backBufferHeight;
|
||||||
parameters->BackBufferFormat = SurfaceFormat::Color;
|
parameters->BackBufferFormat = SurfaceFormat::Color;
|
||||||
parameters->Fullscreen = false;
|
parameters->IsFullscreen = false;
|
||||||
_information.Parameters = parameters;
|
_information.PresentParameters = parameters;
|
||||||
|
|
||||||
if (game)
|
if (game)
|
||||||
_information.Window = game->Window();
|
_information.Window = game->Window();
|
||||||
@ -72,7 +72,7 @@ namespace xna {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
info.Parameters->DeviceWindowHandle = reinterpret_cast<intptr_t>(window->impl->WindowHandle());
|
info.PresentParameters->DeviceWindowHandle = reinterpret_cast<intptr_t>(window->impl->WindowHandle());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -95,8 +95,8 @@ namespace xna {
|
|||||||
|
|
||||||
void GraphicsDeviceManager::CreateDevice() {
|
void GraphicsDeviceManager::CreateDevice() {
|
||||||
if (isDeviceDirty) {
|
if (isDeviceDirty) {
|
||||||
_information.Parameters->BackBufferWidth = backBufferWidth;
|
_information.PresentParameters->BackBufferWidth = backBufferWidth;
|
||||||
_information.Parameters->BackBufferHeight = backBufferHeight;
|
_information.PresentParameters->BackBufferHeight = backBufferHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto result = initWindow(_information, *game, backBufferWidth, backBufferHeight);
|
auto result = initWindow(_information, *game, backBufferWidth, backBufferHeight);
|
||||||
@ -109,7 +109,7 @@ namespace xna {
|
|||||||
void GraphicsDeviceManager::ChangeDevice() {
|
void GraphicsDeviceManager::ChangeDevice() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsDeviceManager::AddDevice(bool anySuitableDevice, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices) {
|
void GraphicsDeviceManager::AddDevices(bool anySuitableDevice, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices) {
|
||||||
const auto handle = game->Window()->Handle();
|
const auto handle = game->Window()->Handle();
|
||||||
|
|
||||||
std::vector<uptr<GraphicsAdapter>> adapters;
|
std::vector<uptr<GraphicsAdapter>> adapters;
|
||||||
@ -122,9 +122,60 @@ namespace xna {
|
|||||||
if (!IsWindowOnAdapter(handle, *adapter))
|
if (!IsWindowOnAdapter(handle, *adapter))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (adapter->IsProfileSupported(graphicsProfile)) {
|
||||||
|
auto baseDeviceInfo = snew<GraphicsDeviceInformation>();
|
||||||
|
baseDeviceInfo->Adapter = std::move(adapter);
|
||||||
|
baseDeviceInfo->Profile = graphicsProfile;
|
||||||
|
baseDeviceInfo->PresentParameters = snew<PresentationParameters>();
|
||||||
|
baseDeviceInfo->PresentParameters->DeviceWindowHandle = handle;
|
||||||
|
baseDeviceInfo->PresentParameters->MultiSampleCount = 0;
|
||||||
|
baseDeviceInfo->PresentParameters->IsFullscreen = isFullScreen;
|
||||||
|
baseDeviceInfo->PresentParameters->PresentationInterval = synchronizeWithVerticalRetrace ? PresentInterval::One : PresentInterval::Immediate;
|
||||||
|
|
||||||
|
const auto& currentDisplayMode = baseDeviceInfo->Adapter->CurrentDisplayMode();
|
||||||
|
AddDevices(*baseDeviceInfo->Adapter, *currentDisplayMode, baseDeviceInfo, foundDevices);
|
||||||
|
|
||||||
|
if (isFullScreen) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphicsDeviceManager::AddDevices(GraphicsAdapter const& adapter, DisplayMode const& mode, sptr<GraphicsDeviceInformation>& baseDeviceInfo, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices) {
|
||||||
|
auto deviceInformation = snew<GraphicsDeviceInformation>(*baseDeviceInfo);
|
||||||
|
|
||||||
|
if (isFullScreen)
|
||||||
|
{
|
||||||
|
deviceInformation->PresentParameters->BackBufferWidth = mode.Width();
|
||||||
|
deviceInformation->PresentParameters->BackBufferHeight = mode.Height();
|
||||||
|
}
|
||||||
|
else if (useResizedBackBuffer) {
|
||||||
|
deviceInformation->PresentParameters->BackBufferWidth = resizedBackBufferWidth;
|
||||||
|
deviceInformation->PresentParameters->BackBufferHeight = resizedBackBufferHeight;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
deviceInformation->PresentParameters->BackBufferWidth = backBufferWidth;
|
||||||
|
deviceInformation->PresentParameters->BackBufferHeight = backBufferHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
SurfaceFormat selectedFormat;
|
||||||
|
DepthFormat selectedDepthFormat;
|
||||||
|
int selectedMultiSampleCount;
|
||||||
|
|
||||||
|
adapter.QueryBackBufferFormat(deviceInformation->Profile, mode.Format(), depthStencilFormat, allowMultiSampling ? 16 : 0, selectedFormat, selectedDepthFormat, selectedMultiSampleCount);
|
||||||
|
|
||||||
|
deviceInformation->PresentParameters->BackBufferFormat = selectedFormat;
|
||||||
|
deviceInformation->PresentParameters->DepthStencilFormat = selectedDepthFormat;
|
||||||
|
deviceInformation->PresentParameters->MultiSampleCount = selectedMultiSampleCount;
|
||||||
|
|
||||||
|
if (std::find(foundDevices.begin(), foundDevices.end(), deviceInformation) != foundDevices.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
foundDevices.push_back(deviceInformation);
|
||||||
|
}
|
||||||
|
|
||||||
bool IsWindowOnAdapter(intptr_t windowHandle, GraphicsAdapter const& adapter) {
|
bool IsWindowOnAdapter(intptr_t windowHandle, GraphicsAdapter const& adapter) {
|
||||||
return GameWindow::ScreenFromAdapter(adapter) == GameWindow::ScreenFromHandle(windowHandle);
|
return GameWindow::ScreenFromAdapter(adapter) == GameWindow::ScreenFromHandle(windowHandle);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ namespace xna {
|
|||||||
impl->dxFullScreenDescription.RefreshRate.Denominator = 1;
|
impl->dxFullScreenDescription.RefreshRate.Denominator = 1;
|
||||||
impl->dxFullScreenDescription.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
|
impl->dxFullScreenDescription.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
|
||||||
impl->dxFullScreenDescription.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
impl->dxFullScreenDescription.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
||||||
impl->dxFullScreenDescription.Windowed = !parameters->Fullscreen;
|
impl->dxFullScreenDescription.Windowed = !parameters->IsFullscreen;
|
||||||
|
|
||||||
HWND hwnd = reinterpret_cast<HWND>(parameters->DeviceWindowHandle);
|
HWND hwnd = reinterpret_cast<HWND>(parameters->DeviceWindowHandle);
|
||||||
return internalInit(*m_device, hwnd, impl->dxSwapChain, impl->dxDescription, impl->dxFullScreenDescription);
|
return internalInit(*m_device, hwnd, impl->dxSwapChain, impl->dxDescription, impl->dxFullScreenDescription);
|
||||||
|
@ -8,8 +8,8 @@ namespace xna {
|
|||||||
public:
|
public:
|
||||||
sptr<GraphicsAdapter> Adapter = nullptr;
|
sptr<GraphicsAdapter> Adapter = nullptr;
|
||||||
xna::GraphicsProfile Profile{ xna::GraphicsProfile::Reach };
|
xna::GraphicsProfile Profile{ xna::GraphicsProfile::Reach };
|
||||||
sptr<xna::PresentationParameters> Parameters = nullptr;
|
sptr<xna::PresentationParameters> PresentParameters = nullptr;
|
||||||
sptr<GameWindow> Window = nullptr;
|
sptr<GameWindow> Window = nullptr;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +104,15 @@ namespace xna {
|
|||||||
isDeviceDirty = true;
|
isDeviceDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool PreferMultiSampling() const {
|
||||||
|
return allowMultiSampling;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr void PreferMultiSampling(bool value) {
|
||||||
|
allowMultiSampling = value;
|
||||||
|
isDeviceDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
//Gets or sets the display orientations that are available if automatic rotation and scaling is enabled.
|
//Gets or sets the display orientations that are available if automatic rotation and scaling is enabled.
|
||||||
constexpr DisplayOrientation SupportedOrientations() const {
|
constexpr DisplayOrientation SupportedOrientations() const {
|
||||||
return supportedOrientations;
|
return supportedOrientations;
|
||||||
@ -134,7 +143,8 @@ namespace xna {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void ChangeDevice(bool forceCreate){}
|
void ChangeDevice(bool forceCreate){}
|
||||||
void AddDevice(bool anySuitableDevice, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices);
|
void AddDevices(bool anySuitableDevice, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices);
|
||||||
|
void AddDevices(GraphicsAdapter const& adapter, DisplayMode const& mode, sptr<GraphicsDeviceInformation>& baseDeviceInfo, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CreateDevice();
|
void CreateDevice();
|
||||||
@ -153,11 +163,17 @@ namespace xna {
|
|||||||
bool isFullScreen{ false };
|
bool isFullScreen{ false };
|
||||||
Int backBufferWidth{ DefaultBackBufferWidth };
|
Int backBufferWidth{ DefaultBackBufferWidth };
|
||||||
Int backBufferHeight{ DefaultBackBufferHeight };
|
Int backBufferHeight{ DefaultBackBufferHeight };
|
||||||
GraphicsProfile graphicsProfile;
|
GraphicsProfile graphicsProfile{GraphicsProfile::HiDef};
|
||||||
DepthFormat depthStencilFormat{ DepthFormat::Depth24 };
|
DepthFormat depthStencilFormat{ DepthFormat::Depth24 };
|
||||||
SurfaceFormat backBufferFormat;
|
SurfaceFormat backBufferFormat{SurfaceFormat::Color};
|
||||||
DisplayOrientation supportedOrientations;
|
DisplayOrientation supportedOrientations{DisplayOrientation::Default};
|
||||||
bool synchronizeWithVerticalRetrace{ true };
|
bool synchronizeWithVerticalRetrace{ true };
|
||||||
|
bool useResizedBackBuffer{ false };
|
||||||
|
Int resizedBackBufferWidth{ 0 };
|
||||||
|
Int resizedBackBufferHeight{ 0 };
|
||||||
|
bool allowMultiSampling{ false };
|
||||||
|
|
||||||
|
std::vector<sptr<GraphicsDeviceInformation>> foundDevices;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,10 @@ namespace xna {
|
|||||||
SurfaceFormat BackBufferFormat{ SurfaceFormat::Color };
|
SurfaceFormat BackBufferFormat{ SurfaceFormat::Color };
|
||||||
SwapEffect PresentationSwapEffect{ SwapEffect::FlipDiscard };
|
SwapEffect PresentationSwapEffect{ SwapEffect::FlipDiscard };
|
||||||
intptr_t DeviceWindowHandle{ 0 };
|
intptr_t DeviceWindowHandle{ 0 };
|
||||||
bool Fullscreen{ false };
|
bool IsFullscreen{ false };
|
||||||
|
Int MultiSampleCount{ 0 };
|
||||||
|
PresentInterval PresentationInterval{ PresentInterval::Default };
|
||||||
|
DepthFormat DepthStencilFormat{ DepthFormat::None };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user