1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00
xn65/includes/xna/graphics/displaymode.hpp

108 lines
3.2 KiB
C++
Raw Permalink Normal View History

2024-03-18 15:41:46 -03:00
#ifndef XNA_GRAPHICS_DISPLAYMODE_HPP
#define XNA_GRAPHICS_DISPLAYMODE_HPP
2024-04-21 19:55:50 -03:00
#include "../default.hpp"
2024-07-19 23:21:25 -03:00
#include "../common/numerics.hpp"
2024-11-15 12:33:06 -03:00
#include "shared.hpp"
2024-03-18 15:41:46 -03:00
namespace xna {
2024-07-19 23:21:25 -03:00
//Flags indicating the method the raster uses to create an image on a surface
enum class DisplayModeScanlineOrder {
Unspecified = 0,
Progressive = 1,
UpperFieldFirst = 2,
LowerFieldFirst = 3
};
//Flags indicating how an image is stretched to fit a given monitor's resolution
enum class DisplayModeScaling {
Unspecified = 0,
Centered = 1,
Stretched = 2
};
struct DisplayModeRate {
constexpr DisplayModeRate() = default;
2024-07-20 22:20:18 -03:00
constexpr DisplayModeRate(DisplayModeScanlineOrder scanlineOrdering, DisplayModeScaling scaling, RationalNumber refreshRate, bool stereo) :
ScanlineOrdering(scanlineOrdering), Scaling(scaling), RefreshRate(refreshRate), Stereo(stereo){}
2024-07-19 23:21:25 -03:00
constexpr bool operator==(const DisplayModeRate& other) const {
return ScanlineOrdering == other.ScanlineOrdering && Scaling == other.Scaling && RefreshRate == other.RefreshRate;
}
//Gets the method the raster uses to create an image on a surface
DisplayModeScanlineOrder ScanlineOrdering{ DisplayModeScanlineOrder::Unspecified };
//Gets how an image is stretched to fit a given monitor's resolution
DisplayModeScaling Scaling{ DisplayModeScaling::Unspecified };
//Describing the refresh rate in hertz.
2024-07-20 22:20:18 -03:00
RationalNumber RefreshRate{};
//Specifies whether the full-screen display mode is stereo. TRUE if stereo; otherwise, FALSE.
bool Stereo{ false };
2024-07-19 23:21:25 -03:00
};
2024-03-18 15:41:46 -03:00
//Describes the display mode.
2024-05-20 11:51:32 -03:00
class DisplayMode {
2024-03-18 15:41:46 -03:00
public:
2024-07-19 23:21:25 -03:00
constexpr DisplayMode();
constexpr DisplayMode(Int width, Int height, SurfaceFormat format):
width(width), height(height), format(format){}
2024-05-20 11:51:32 -03:00
//Gets the aspect ratio used by the graphics device.
2024-05-20 11:51:32 -03:00
constexpr float AspectRatio() const {
2024-07-19 23:21:25 -03:00
if (height == 0 || width == 0)
2024-05-20 11:51:32 -03:00
return 0;
2024-07-19 23:21:25 -03:00
return static_cast<float>(width) / static_cast<float>(height);
2024-05-20 11:51:32 -03:00
}
//Gets a value indicating the screen width, in pixels.
2024-07-19 23:21:25 -03:00
constexpr Int Width() const { return width; }
//Gets a value indicating the screen height, in pixels.
2024-07-19 23:21:25 -03:00
constexpr Int Height() const { return height; }
//Gets a value indicating the surface format of the display mode.
constexpr SurfaceFormat Format() const { return format; }
constexpr bool operator==(const DisplayMode& other) const {
return width == other.width
&& height == other.height
&& format == other.format;
}
2024-05-20 11:51:32 -03:00
2024-07-19 23:21:25 -03:00
private:
2024-07-20 19:08:40 -03:00
friend class GraphicsAdapter;
2024-07-19 23:21:25 -03:00
Int width{ 0 };
Int height{ 0 };
SurfaceFormat format{ SurfaceFormat::Color };
2024-05-20 11:51:32 -03:00
public:
2024-07-19 23:21:25 -03:00
std::vector<DisplayModeRate> Rates;
2024-05-20 11:51:32 -03:00
};
//Manipulates a collection of DisplayMode structures.
2024-05-20 11:51:32 -03:00
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;
constexpr size_t Count() const {
return DisplayModes.size();
}
2024-03-24 16:12:17 -03:00
public:
2024-05-20 11:51:32 -03:00
std::vector<sptr<DisplayMode>> DisplayModes;
2024-03-18 15:41:46 -03:00
};
}
#endif