2024-03-18 15:41:46 -03:00
|
|
|
#ifndef XNA_GRAPHICS_ADAPTER_HPP
|
|
|
|
#define XNA_GRAPHICS_ADAPTER_HPP
|
|
|
|
|
2024-11-13 09:38:31 -03:00
|
|
|
#include "displaymode.hpp"
|
2024-11-12 20:48:28 -03:00
|
|
|
#include <cstdint>
|
2024-11-13 09:38:31 -03:00
|
|
|
#include <memory>
|
2024-11-12 20:48:28 -03:00
|
|
|
#include <string>
|
2024-03-18 15:41:46 -03:00
|
|
|
|
|
|
|
namespace xna {
|
2024-11-13 09:38:31 -03:00
|
|
|
|
2024-11-13 09:47:59 -03:00
|
|
|
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.
|
2024-11-12 20:48:28 -03:00
|
|
|
static void Adapters(std::vector<std::unique_ptr<GraphicsAdapter>>& adapters);
|
2024-07-19 22:11:57 -03:00
|
|
|
|
|
|
|
//Gets the current display mode.
|
2024-11-12 20:48:28 -03:00
|
|
|
inline std::shared_ptr<DisplayMode> CurrentDisplayMode() const { return currentDisplayMode; }
|
2024-07-19 22:11:57 -03:00
|
|
|
|
|
|
|
//Gets the default adapter.
|
2024-11-12 20:48:28 -03:00
|
|
|
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.
|
2024-11-12 20:48:28 -03:00
|
|
|
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.
|
2024-11-12 20:48:28 -03:00
|
|
|
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.
|
2024-11-12 20:48:28 -03:00
|
|
|
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.
|
2024-11-12 20:48:28 -03:00
|
|
|
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.
|
2024-11-12 20:48:28 -03:00
|
|
|
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.
|
2024-11-12 20:48:28 -03:00
|
|
|
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.
|
2024-11-12 20:48:28 -03:00
|
|
|
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,
|
2024-11-12 20:48:28 -03:00
|
|
|
int32_t multiSampleCount,
|
2024-07-19 22:11:57 -03:00
|
|
|
SurfaceFormat& selectedFormat,
|
|
|
|
DepthFormat& selectedDepthFormat,
|
2024-11-12 20:48:28 -03:00
|
|
|
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:
|
2024-11-12 20:48:28 -03:00
|
|
|
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 };
|
2024-11-12 20:48:28 -03:00
|
|
|
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;
|
|
|
|
|
2024-11-12 20:48:28 -03:00
|
|
|
GraphicsAdapter();
|
2024-03-18 15:41:46 -03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|