From adeda5ca67bdb018a7b1a5c376bc1c9d89f8df15 Mon Sep 17 00:00:00 2001 From: Danilo Date: Tue, 12 Nov 2024 20:48:28 -0300 Subject: [PATCH] Adiciona ImplementationBase em GraphicsAdapter --- includes/xna-dx/implementations.hpp | 12 +++---- includes/xna/graphics/adapter.hpp | 53 ++++++++++++++--------------- includes/xna/platform.hpp | 13 +++++++ samples/CMakeLists.txt | 2 +- 4 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 includes/xna/platform.hpp diff --git a/includes/xna-dx/implementations.hpp b/includes/xna-dx/implementations.hpp index 0927318..5ee079b 100644 --- a/includes/xna-dx/implementations.hpp +++ b/includes/xna-dx/implementations.hpp @@ -4,6 +4,11 @@ #include "headers.hpp" namespace xna { + struct GraphicsAdapter::ImplementationBase::PlatformImplementation { + comptr dxAdapter; + comptr dxFactory; + }; + struct SpriteFont::PlatformImplementation { uptr dxSpriteFont{ nullptr }; }; @@ -12,12 +17,7 @@ namespace xna { sptr dxSpriteBatch = nullptr; comptr dxInputLayout = nullptr; sptr dxEffectBuffer = nullptr; - }; - - struct GraphicsAdapter::PlatformImplementation { - comptr dxAdapter = nullptr; - comptr dxFactory = nullptr; - }; + }; struct BlendRenderTarget { bool Enabled{ true }; diff --git a/includes/xna/graphics/adapter.hpp b/includes/xna/graphics/adapter.hpp index 55f978e..9bfa1af 100644 --- a/includes/xna/graphics/adapter.hpp +++ b/includes/xna/graphics/adapter.hpp @@ -1,30 +1,33 @@ #ifndef XNA_GRAPHICS_ADAPTER_HPP #define XNA_GRAPHICS_ADAPTER_HPP -#include "../default.hpp" #include "displaymode.hpp" +#include "../platform.hpp" +#include +#include +#include namespace xna { //Provides methods to retrieve and manipulate graphics adapters. - class GraphicsAdapter { + class GraphicsAdapter : public ImplementationBase { public: //Collection of available adapters on the system. - static void Adapters(std::vector>& adapters); + static void Adapters(std::vector>& adapters); //Gets the current display mode. - inline sptr CurrentDisplayMode() const { return currentDisplayMode; } + inline std::shared_ptr CurrentDisplayMode() const { return currentDisplayMode; } //Gets the default adapter. - static uptr DefaultAdapter(); + static std::unique_ptr DefaultAdapter(); //Retrieves a string used for presentation to the user. - constexpr String Description() const { return description; } + constexpr std::string Description() const { return description; } //Retrieves a value that is used to help identify a particular chip set. - constexpr Uint DeviceId() const { return deviceId; } + constexpr uint32_t DeviceId() const { return deviceId; } //Retrieves a string that contains the device name. - constexpr String DeviceName() const { return deviceName; } + constexpr std::string DeviceName() const { return deviceName; } //Determines if this instance of GraphicsAdapter is the default adapter. constexpr bool IsDefaultAdapter() const { return isDefault; } @@ -38,16 +41,16 @@ namespace xna { constexpr intptr_t MonitorHandle() const { return monitorHandle; } //Retrieves a value used to help identify the revision level of a particular chip set. - constexpr Uint Revision() const { return revision; } + constexpr uint32_t Revision() const { return revision; } //Retrieves a value used to identify the subsystem. - constexpr Uint SubSystemId() const { return subSystemId; } + constexpr uint32_t SubSystemId() const { return subSystemId; } //Returns a collection of supported display modes for the current adapter. - inline sptr SupportedDisplayModes() const { return supportedDisplayModes; } + inline std::shared_ptr SupportedDisplayModes() const { return supportedDisplayModes; } //Retrieves a value used to identify the manufacturer. - constexpr Uint VendorId() const { return vendorId; } + constexpr uint32_t VendorId() const { return vendorId; } //Gets or sets a NULL device. static bool UseNullDevice() { return useNullDevice; } @@ -69,32 +72,28 @@ namespace xna { GraphicsProfile graphicsProfile, SurfaceFormat format, DepthFormat depthFormat, - Int multiSampleCount, + int32_t multiSampleCount, SurfaceFormat& selectedFormat, DepthFormat& selectedDepthFormat, - Int& selectedMultiSampleCount + int32_t& selectedMultiSampleCount ) const; private: - String description; - Uint deviceId{0}; - String deviceName; + std::string description; + uint32_t deviceId{0}; + std::string deviceName; bool isDefault{ false }; intptr_t monitorHandle{ 0 }; - Uint revision{ 0 }; - Uint subSystemId{ 0 }; - Uint vendorId{ 0 }; - sptr currentDisplayMode{ nullptr }; - sptr supportedDisplayModes{ nullptr }; + uint32_t revision{ 0 }; + uint32_t subSystemId{ 0 }; + uint32_t vendorId{ 0 }; + std::shared_ptr currentDisplayMode{ nullptr }; + std::shared_ptr supportedDisplayModes{ nullptr }; inline static bool useNullDevice = false; inline static bool useReferenceDevice = false; - GraphicsAdapter(); - - public: - struct PlatformImplementation; - uptr impl = nullptr; + GraphicsAdapter(); }; } diff --git a/includes/xna/platform.hpp b/includes/xna/platform.hpp new file mode 100644 index 0000000..241a006 --- /dev/null +++ b/includes/xna/platform.hpp @@ -0,0 +1,13 @@ +#ifndef XNA_PLATFORM_HPP +#define XNA_PLATFORM_HPP + +#include + +namespace xna { + struct ImplementationBase { + struct PlatformImplementation; + std::unique_ptr impl; + }; +} + +#endif \ No newline at end of file diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 24ef843..45257e9 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -4,4 +4,4 @@ # Add source to this project's executable. add_subdirectory ("01_blank") -#add_subdirectory ("02_PlatfformerStarterKit") +add_subdirectory ("02_PlatfformerStarterKit")