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

104 lines
3.5 KiB
C++
Raw Permalink Normal View History

2024-03-18 15:41:46 -03:00
#ifndef XNA_GRAPHICS_ADAPTER_HPP
#define XNA_GRAPHICS_ADAPTER_HPP
#include "displaymode.hpp"
#include <cstdint>
#include <memory>
#include <string>
2024-03-18 15:41:46 -03:00
namespace xna {
struct GraphicsAdapterImplementation;
2024-06-22 22:05:35 -03:00
//Provides methods to retrieve and manipulate graphics adapters.
2024-11-16 14:21:06 -03:00
class GraphicsAdapter {
2024-03-18 15:41:46 -03:00
public:
2024-07-19 22:11:57 -03:00
//Collection of available adapters on the system.
static void Adapters(std::vector<std::unique_ptr<GraphicsAdapter>>& adapters);
2024-07-19 22:11:57 -03:00
//Gets the current display mode.
inline std::shared_ptr<DisplayMode> CurrentDisplayMode() const { return currentDisplayMode; }
2024-07-19 22:11:57 -03:00
//Gets the default adapter.
static std::unique_ptr<GraphicsAdapter> DefaultAdapter();
2024-07-19 22:11:57 -03:00
2024-06-22 22:05:35 -03:00
//Retrieves a string used for presentation to the user.
constexpr std::string Description() const { return description; }
2024-07-19 22:11:57 -03:00
2024-06-22 22:05:35 -03:00
//Retrieves a value that is used to help identify a particular chip set.
constexpr uint32_t DeviceId() const { return deviceId; }
2024-07-19 22:11:57 -03:00
2024-06-22 22:05:35 -03:00
//Retrieves a string that contains the device name.
constexpr std::string DeviceName() const { return deviceName; }
2024-07-19 22:11:57 -03:00
2024-06-22 22:05:35 -03:00
//Determines if this instance of GraphicsAdapter is the default adapter.
2024-07-19 22:11:57 -03:00
constexpr bool IsDefaultAdapter() const { return isDefault; }
//Determines if the graphics adapter is in widescreen mode.
2024-07-20 19:08:40 -03:00
inline bool IsWideScreen() const {
return currentDisplayMode->AspectRatio() > 1.6000000238418579;
}
2024-07-19 22:11:57 -03:00
2024-06-22 22:05:35 -03:00
//Retrieves the handle of the monitor
2024-07-19 22:11:57 -03:00
constexpr intptr_t MonitorHandle() const { return monitorHandle; }
2024-06-22 22:05:35 -03:00
//Retrieves a value used to help identify the revision level of a particular chip set.
constexpr uint32_t Revision() const { return revision; }
2024-07-19 22:11:57 -03:00
2024-06-22 22:05:35 -03:00
//Retrieves a value used to identify the subsystem.
constexpr uint32_t SubSystemId() const { return subSystemId; }
2024-07-19 22:11:57 -03:00
2024-06-23 23:14:06 -03:00
//Returns a collection of supported display modes for the current adapter.
inline std::shared_ptr<DisplayModeCollection> SupportedDisplayModes() const { return supportedDisplayModes; }
2024-04-21 16:06:22 -03:00
2024-07-19 22:11:57 -03:00
//Retrieves a value used to identify the manufacturer.
constexpr uint32_t VendorId() const { return vendorId; }
2024-07-20 23:44:10 -03:00
//Gets or sets a NULL device.
static bool UseNullDevice() { return useNullDevice; }
//Gets or sets a NULL device.
static void UseNullDevice(bool value) { useNullDevice = value; }
//Gets or sets a reference device.
constexpr static bool UseReferenceDevice() { return useReferenceDevice; }
//Gets or sets a reference device.
constexpr static void UseReferenceDevice(bool value) { useReferenceDevice = value; }
2024-07-19 22:11:57 -03:00
//Tests to see if the adapter supports the requested profile.
bool IsProfileSupported(GraphicsProfile graphicsProfile) {
2024-07-20 23:44:10 -03:00
return true;
}
2024-07-19 22:11:57 -03:00
//Queries the adapter for support for the requested back buffer format.
bool QueryBackBufferFormat(
GraphicsProfile graphicsProfile,
SurfaceFormat format,
DepthFormat depthFormat,
int32_t multiSampleCount,
2024-07-19 22:11:57 -03:00
SurfaceFormat& selectedFormat,
DepthFormat& selectedDepthFormat,
int32_t& selectedMultiSampleCount
2024-07-21 20:37:16 -03:00
) const;
2024-07-19 22:11:57 -03:00
2024-11-16 14:21:06 -03:00
std::unique_ptr<GraphicsAdapterImplementation> Implementation;
2024-07-19 22:11:57 -03:00
private:
std::string description;
uint32_t deviceId{0};
std::string deviceName;
2024-07-19 22:11:57 -03:00
bool isDefault{ false };
intptr_t monitorHandle{ 0 };
uint32_t revision{ 0 };
uint32_t subSystemId{ 0 };
uint32_t vendorId{ 0 };
std::shared_ptr<DisplayMode> currentDisplayMode{ nullptr };
std::shared_ptr<DisplayModeCollection> supportedDisplayModes{ nullptr };
2024-05-19 17:52:27 -03:00
2024-07-20 23:44:10 -03:00
inline static bool useNullDevice = false;
inline static bool useReferenceDevice = false;
GraphicsAdapter();
2024-03-18 15:41:46 -03:00
};
}
#endif