mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Corrige DisplayMode
This commit is contained in:
parent
60d106588d
commit
6dada4f616
@ -1,9 +1,9 @@
|
||||
#include "platform-dx/gdevicemanager-dx.hpp"
|
||||
#include "platform-dx/implementations.hpp"
|
||||
#include "graphics/adapter.hpp"
|
||||
#include "platform-dx/displaymode-dx.hpp"
|
||||
#include "graphics/displaymode.hpp"
|
||||
#include "platform-dx/dxheaders.hpp"
|
||||
#include "platform-dx/dxhelpers.hpp"
|
||||
#include "platform-dx/gdevicemanager-dx.hpp"
|
||||
#include "platform-dx/implementations.hpp"
|
||||
|
||||
namespace xna {
|
||||
static size_t getDisplayModesCount(IDXGIAdapter* adapter);
|
||||
@ -245,13 +245,13 @@ namespace xna {
|
||||
void GraphicsAdapter::CurrentDisplayMode(SurfaceFormat surfaceFormat, Uint width, Uint height) {
|
||||
const auto modes = SupportedDisplayModes(surfaceFormat);
|
||||
|
||||
for (size_t i = 0; i < modes->_displayModes.size(); ++i) {
|
||||
auto& m = modes->_displayModes[i];
|
||||
for (size_t i = 0; i < modes->DisplayModes.size(); ++i) {
|
||||
auto& m = modes->DisplayModes[i];
|
||||
|
||||
if (m->_format == surfaceFormat && m->_width == width && m->_height == height) {
|
||||
if (m->Format == surfaceFormat && m->Width == width && m->Height == height) {
|
||||
impl->_currentDisplayMode = m;
|
||||
}
|
||||
else if(i + 1 == modes->_displayModes.size()) {
|
||||
else if(i + 1 == modes->DisplayModes.size()) {
|
||||
impl->_currentDisplayMode = m;
|
||||
}
|
||||
}
|
||||
@ -304,20 +304,20 @@ namespace xna {
|
||||
description._scaling = static_cast<DisplayModeScaling>(modedesc.Scaling);
|
||||
description._scanlineOrdering = static_cast<DisplayModeScanlineOrder>(modedesc.ScanlineOrdering);
|
||||
|
||||
if (pDisplay && pDisplay->_width == modedesc.Width && pDisplay->_height == modedesc.Height && pDisplay->_format == DxHelpers::ConvertDXGIFORMATToSurface(modedesc.Format)) {
|
||||
pDisplay->_descriptions.push_back(description);
|
||||
if (pDisplay && pDisplay->Width == modedesc.Width && pDisplay->Height == modedesc.Height && pDisplay->Format == DxHelpers::ConvertDXGIFORMATToSurface(modedesc.Format)) {
|
||||
pDisplay->impl->Descriptions.push_back(description);
|
||||
}
|
||||
else {
|
||||
pDisplay = New<DisplayMode>();
|
||||
pDisplay->_width = modedesc.Width;
|
||||
pDisplay->_height = modedesc.Height;
|
||||
pDisplay->_format = DxHelpers::ConvertDXGIFORMATToSurface(modedesc.Format);
|
||||
pDisplay->_descriptions.push_back(description);
|
||||
pDisplay->Width = modedesc.Width;
|
||||
pDisplay->Height = modedesc.Height;
|
||||
pDisplay->Format = DxHelpers::ConvertDXGIFORMATToSurface(modedesc.Format);
|
||||
pDisplay->impl->Descriptions.push_back(description);
|
||||
displayList.push_back(pDisplay);
|
||||
}
|
||||
}
|
||||
|
||||
collection->_displayModes = displayList;
|
||||
collection->DisplayModes = displayList;
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
@ -1,12 +1,21 @@
|
||||
#include "platform-dx/displaymode-dx.hpp"
|
||||
#include "platform-dx/implementations.hpp"
|
||||
#include "graphics/displaymode.hpp"
|
||||
|
||||
namespace xna {
|
||||
DisplayMode::DisplayMode() {
|
||||
impl = uNew<PlatformImplementation>();
|
||||
}
|
||||
|
||||
DisplayMode::~DisplayMode() {
|
||||
impl = nullptr;
|
||||
}
|
||||
|
||||
size_t DisplayModeCollection::SurfaceCount(SurfaceFormat format) const
|
||||
{
|
||||
size_t counter = 0;
|
||||
|
||||
for (size_t i = 0; i < _displayModes.size(); ++i) {
|
||||
if (_displayModes[i]->Format() == format) {
|
||||
for (size_t i = 0; i < DisplayModes.size(); ++i) {
|
||||
if (DisplayModes[i]->Format == format) {
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
@ -21,9 +30,9 @@ namespace xna {
|
||||
size_t index = 0;
|
||||
std::vector<sptr<DisplayMode>> modes(count);
|
||||
|
||||
for (size_t i = 0; i < _displayModes.size(); ++i) {
|
||||
if (_displayModes[i]->Format() == format) {
|
||||
modes[index] = _displayModes[i];
|
||||
for (size_t i = 0; i < DisplayModes.size(); ++i) {
|
||||
if (DisplayModes[i]->Format == format) {
|
||||
modes[index] = DisplayModes[i];
|
||||
++index;
|
||||
}
|
||||
|
||||
@ -38,13 +47,13 @@ namespace xna {
|
||||
{
|
||||
sptr<DisplayMode> matched = nullptr;
|
||||
|
||||
for (size_t i = 0; i < _displayModes.size(); ++i) {
|
||||
const auto& mode = _displayModes[i];
|
||||
for (size_t i = 0; i < DisplayModes.size(); ++i) {
|
||||
const auto& mode = DisplayModes[i];
|
||||
|
||||
if (mode->Format() == format && mode->_width == width && mode->_height == height) {
|
||||
return _displayModes[i];
|
||||
if (mode->Format == format && mode->Width == width && mode->Height == height) {
|
||||
return DisplayModes[i];
|
||||
}
|
||||
else if(mode->Format() == format && mode->_width == width) {
|
||||
else if(mode->Format == format && mode->Width == width) {
|
||||
matched = mode;
|
||||
}
|
||||
}
|
||||
|
@ -6,20 +6,50 @@
|
||||
namespace xna {
|
||||
struct DisplayModeDescription;
|
||||
|
||||
class IDisplayMode {
|
||||
class DisplayMode {
|
||||
public:
|
||||
virtual ~IDisplayMode() {}
|
||||
virtual float AspectRatio() const = 0;
|
||||
virtual Int Width() const = 0;
|
||||
virtual Int Height() const = 0;
|
||||
virtual SurfaceFormat Format() const = 0;
|
||||
virtual std::vector<DisplayModeDescription> Descriptions() const = 0;
|
||||
};
|
||||
DisplayMode();
|
||||
~DisplayMode();
|
||||
|
||||
constexpr float AspectRatio() const {
|
||||
if (Height == 0 || Width == 0)
|
||||
return 0;
|
||||
|
||||
return static_cast<float>(Width) / static_cast<float>(Height);
|
||||
}
|
||||
|
||||
constexpr bool operator==(const DisplayMode& other) const {
|
||||
return Width == other.Width
|
||||
&& Height == other.Height
|
||||
&& Format == other.Format;
|
||||
}
|
||||
|
||||
class IDisplayModeCollection {
|
||||
public:
|
||||
virtual ~IDisplayModeCollection() {}
|
||||
virtual size_t SurfaceCount(SurfaceFormat format) const = 0;
|
||||
Int Width{ 0 };
|
||||
Int Height{ 0 };
|
||||
SurfaceFormat Format{ SurfaceFormat::Color };
|
||||
|
||||
public:
|
||||
struct PlatformImplementation;
|
||||
uptr<PlatformImplementation> impl;
|
||||
};
|
||||
|
||||
class DisplayModeCollection {
|
||||
public:
|
||||
constexpr DisplayModeCollection() = default;
|
||||
|
||||
DisplayModeCollection(size_t count) : DisplayModes(count) {}
|
||||
|
||||
DisplayModeCollection(std::vector<sptr<DisplayMode>> const& displayModes) :
|
||||
DisplayModes(displayModes) {}
|
||||
|
||||
size_t SurfaceCount(SurfaceFormat format) const;
|
||||
|
||||
std::vector<sptr<DisplayMode>> Query(SurfaceFormat format) const;
|
||||
sptr<DisplayMode> Query(SurfaceFormat format, Uint width, Uint height) const;
|
||||
|
||||
public:
|
||||
std::vector<sptr<DisplayMode>> DisplayModes;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,101 +0,0 @@
|
||||
#ifndef XNA_PLATFORM_DISPLAYMODE_DX_HPP
|
||||
#define XNA_PLATFORM_DISPLAYMODE_DX_HPP
|
||||
|
||||
#include "../graphics/displaymode.hpp"
|
||||
#include "dxheaders.hpp"
|
||||
|
||||
namespace xna {
|
||||
struct DisplayModeRefreshRate {
|
||||
constexpr DisplayModeRefreshRate() = default;
|
||||
|
||||
constexpr DisplayModeRefreshRate(DXGI_RATIONAL const& dxrational) {
|
||||
Numerator = dxrational.Numerator;
|
||||
Denominator = dxrational.Denominator;
|
||||
}
|
||||
constexpr DisplayModeRefreshRate(Uint numerator, Uint denominator)
|
||||
: Numerator(numerator), Denominator(denominator){}
|
||||
|
||||
Uint Numerator{ 0 };
|
||||
Uint Denominator{ 0 };
|
||||
|
||||
constexpr bool operator==(const DisplayModeRefreshRate& other) const
|
||||
{
|
||||
return Numerator == other.Numerator && Denominator == other.Denominator;
|
||||
}
|
||||
};
|
||||
|
||||
struct DisplayModeDescription {
|
||||
DisplayModeScanlineOrder _scanlineOrdering{ DisplayModeScanlineOrder::Unspecified };
|
||||
DisplayModeScaling _scaling{ DisplayModeScaling::Unspecified };
|
||||
DisplayModeRefreshRate _refreshRate{};
|
||||
|
||||
constexpr bool operator==(const DisplayModeDescription& other) const
|
||||
{
|
||||
return _scanlineOrdering == other._scanlineOrdering && _scaling == other._scaling && _refreshRate == other._refreshRate;
|
||||
}
|
||||
};
|
||||
|
||||
class DisplayMode : public IDisplayMode {
|
||||
public:
|
||||
constexpr DisplayMode() = default;
|
||||
|
||||
constexpr DisplayMode(Int width, Int height, SurfaceFormat format)
|
||||
: _width(width), _height(height), _format(format) {}
|
||||
|
||||
virtual constexpr float AspectRatio() const noexcept override {
|
||||
if (_height == 0 || _width == 0)
|
||||
return 0;
|
||||
|
||||
return static_cast<float>(_width) / static_cast<float>(_height);
|
||||
}
|
||||
|
||||
virtual constexpr Int Width() const override {
|
||||
return _width;
|
||||
}
|
||||
|
||||
virtual constexpr Int Height() const override {
|
||||
return _height;
|
||||
}
|
||||
|
||||
virtual constexpr SurfaceFormat Format() const override {
|
||||
return _format;
|
||||
}
|
||||
|
||||
virtual constexpr std::vector<DisplayModeDescription> Descriptions() const {
|
||||
return _descriptions;
|
||||
}
|
||||
|
||||
public:
|
||||
Int _width{ 0 };
|
||||
Int _height{ 0 };
|
||||
SurfaceFormat _format{ SurfaceFormat::Color };
|
||||
std::vector<DisplayModeDescription> _descriptions;
|
||||
|
||||
constexpr bool operator==(const DisplayMode& other) const {
|
||||
return _width == other._width
|
||||
&& _height == other._height
|
||||
&& _format == other._format
|
||||
&& _descriptions == other._descriptions;
|
||||
}
|
||||
};
|
||||
|
||||
class DisplayModeCollection : public IDisplayModeCollection {
|
||||
public:
|
||||
constexpr DisplayModeCollection() = default;
|
||||
|
||||
DisplayModeCollection(size_t count) : _displayModes(count) {}
|
||||
|
||||
DisplayModeCollection(std::vector<sptr<DisplayMode>> const& displayModes) :
|
||||
_displayModes(displayModes) {}
|
||||
|
||||
virtual size_t SurfaceCount(SurfaceFormat format) const override;
|
||||
|
||||
std::vector<sptr<DisplayMode>> Query(SurfaceFormat format) const;
|
||||
sptr<DisplayMode> Query(SurfaceFormat format, Uint width, Uint height) const;
|
||||
|
||||
public:
|
||||
std::vector<sptr<DisplayMode>> _displayModes;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -8,6 +8,7 @@
|
||||
#include "platform-dx/rendertarget-dx.hpp"
|
||||
#include "graphics/blendstate.hpp"
|
||||
#include "graphics/depthstencilstate.hpp"
|
||||
#include "graphics/displaymode.hpp"
|
||||
|
||||
namespace xna {
|
||||
struct SpriteFont::PlatformImplementation {
|
||||
@ -102,5 +103,39 @@ namespace xna {
|
||||
|
||||
ID3D11DepthStencilState* dxDepthStencil = nullptr;
|
||||
D3D11_DEPTH_STENCIL_DESC dxDescription{};
|
||||
};
|
||||
|
||||
struct DisplayModeRefreshRate {
|
||||
constexpr DisplayModeRefreshRate() = default;
|
||||
|
||||
constexpr DisplayModeRefreshRate(DXGI_RATIONAL const& dxrational) {
|
||||
Numerator = dxrational.Numerator;
|
||||
Denominator = dxrational.Denominator;
|
||||
}
|
||||
constexpr DisplayModeRefreshRate(Uint numerator, Uint denominator)
|
||||
: Numerator(numerator), Denominator(denominator) {}
|
||||
|
||||
Uint Numerator{ 0 };
|
||||
Uint Denominator{ 0 };
|
||||
|
||||
constexpr bool operator==(const DisplayModeRefreshRate& other) const
|
||||
{
|
||||
return Numerator == other.Numerator && Denominator == other.Denominator;
|
||||
}
|
||||
};
|
||||
|
||||
struct DisplayModeDescription {
|
||||
DisplayModeScanlineOrder _scanlineOrdering{ DisplayModeScanlineOrder::Unspecified };
|
||||
DisplayModeScaling _scaling{ DisplayModeScaling::Unspecified };
|
||||
DisplayModeRefreshRate _refreshRate{};
|
||||
|
||||
constexpr bool operator==(const DisplayModeDescription& other) const
|
||||
{
|
||||
return _scanlineOrdering == other._scanlineOrdering && _scaling == other._scaling && _refreshRate == other._refreshRate;
|
||||
}
|
||||
};
|
||||
|
||||
struct DisplayMode::PlatformImplementation {
|
||||
std::vector<DisplayModeDescription> Descriptions;
|
||||
};
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
#include "audioengine-dx.hpp"
|
||||
#include "device-dx.hpp"
|
||||
#include "displaymode-dx.hpp"
|
||||
#include "dxheaders.hpp"
|
||||
#include "game-dx.hpp"
|
||||
#include "gamepad-dx.hpp"
|
||||
|
Loading…
x
Reference in New Issue
Block a user