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

Remove PlatformImplementation

This commit is contained in:
Danilo 2024-11-16 14:21:06 -03:00
parent 61da1aac46
commit f5049cae2a
9 changed files with 31 additions and 35 deletions

View File

@ -1,7 +1,6 @@
#ifndef XNA_GRAPHICS_ADAPTER_HPP #ifndef XNA_GRAPHICS_ADAPTER_HPP
#define XNA_GRAPHICS_ADAPTER_HPP #define XNA_GRAPHICS_ADAPTER_HPP
#include "../platform.hpp"
#include "displaymode.hpp" #include "displaymode.hpp"
#include <cstdint> #include <cstdint>
#include <memory> #include <memory>
@ -12,7 +11,7 @@ namespace xna {
struct GraphicsAdapterImplementation; struct GraphicsAdapterImplementation;
//Provides methods to retrieve and manipulate graphics adapters. //Provides methods to retrieve and manipulate graphics adapters.
class GraphicsAdapter : public PlatformImplementation<GraphicsAdapterImplementation> { class GraphicsAdapter {
public: public:
//Collection of available adapters on the system. //Collection of available adapters on the system.
static void Adapters(std::vector<std::unique_ptr<GraphicsAdapter>>& adapters); static void Adapters(std::vector<std::unique_ptr<GraphicsAdapter>>& adapters);
@ -81,6 +80,8 @@ namespace xna {
int32_t& selectedMultiSampleCount int32_t& selectedMultiSampleCount
) const; ) const;
std::unique_ptr<GraphicsAdapterImplementation> Implementation;
private: private:
std::string description; std::string description;
uint32_t deviceId{0}; uint32_t deviceId{0};

View File

@ -2,7 +2,6 @@
#define XNA_GRAPHICS_BLENDSTATE_HPP #define XNA_GRAPHICS_BLENDSTATE_HPP
#include "../common/color.hpp" #include "../common/color.hpp"
#include "../platform.hpp"
#include "gresource.hpp" #include "gresource.hpp"
#include <cstdint> #include <cstdint>
#include <vector> #include <vector>
@ -104,7 +103,7 @@ namespace xna {
struct BlendStateImplementation; struct BlendStateImplementation;
//Contains blend state for the device. //Contains blend state for the device.
class BlendState : public GraphicsResource, public PlatformImplementation<BlendStateImplementation> { class BlendState : public GraphicsResource {
public: public:
BlendState(); BlendState();
BlendState(std::shared_ptr<GraphicsDevice> const& device); BlendState(std::shared_ptr<GraphicsDevice> const& device);
@ -168,6 +167,8 @@ namespace xna {
//A built-in state object with settings for blending with non-premultipled alpha, //A built-in state object with settings for blending with non-premultipled alpha,
//that is blending source and destination data using alpha while assuming the color data contains no alpha information. //that is blending source and destination data using alpha while assuming the color data contains no alpha information.
static std::unique_ptr<BlendState> NonPremultiplied(); static std::unique_ptr<BlendState> NonPremultiplied();
std::unique_ptr< BlendStateImplementation> Implementation;
}; };
} }

View File

@ -1,7 +1,6 @@
#ifndef XNA_GRAPHICS_DEPTHSTENCILSTATE_HPP #ifndef XNA_GRAPHICS_DEPTHSTENCILSTATE_HPP
#define XNA_GRAPHICS_DEPTHSTENCILSTATE_HPP #define XNA_GRAPHICS_DEPTHSTENCILSTATE_HPP
#include "../platform.hpp"
#include "gresource.hpp" #include "gresource.hpp"
#include "shared.hpp" #include "shared.hpp"
#include <cstdint> #include <cstdint>
@ -23,7 +22,7 @@ namespace xna {
struct DepthStencilStateImplementation; struct DepthStencilStateImplementation;
//Contains depth-stencil state for the device. //Contains depth-stencil state for the device.
class DepthStencilState : public GraphicsResource, public PlatformImplementation<DepthStencilStateImplementation> { class DepthStencilState : public GraphicsResource {
public: public:
DepthStencilState(); DepthStencilState();
DepthStencilState(std::shared_ptr<GraphicsDevice> const& device); DepthStencilState(std::shared_ptr<GraphicsDevice> const& device);
@ -104,6 +103,8 @@ namespace xna {
bool Initialize(); bool Initialize();
bool Apply(); bool Apply();
std::unique_ptr<DepthStencilStateImplementation> Implementation;
}; };
} }

View File

@ -1,7 +1,6 @@
#ifndef XNA_GRAPHICS_DEVICE_HPP #ifndef XNA_GRAPHICS_DEVICE_HPP
#define XNA_GRAPHICS_DEVICE_HPP #define XNA_GRAPHICS_DEVICE_HPP
#include "../platform.hpp"
#include "presentparams.hpp" #include "presentparams.hpp"
#include "viewport.hpp" #include "viewport.hpp"
#include <memory> #include <memory>
@ -10,10 +9,10 @@ namespace xna {
struct GraphicsDeviceImplementation; struct GraphicsDeviceImplementation;
//Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders. //Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders.
class GraphicsDevice : public std::enable_shared_from_this<GraphicsDevice>, public PlatformImplementation<GraphicsDeviceImplementation> { class GraphicsDevice : public std::enable_shared_from_this<GraphicsDevice> {
public: public:
GraphicsDevice(); GraphicsDevice();
GraphicsDevice( GraphicsDevice(
std::shared_ptr<GraphicsAdapter> const& adapter, std::shared_ptr<GraphicsAdapter> const& adapter,
GraphicsProfile const& graphicsProfile, GraphicsProfile const& graphicsProfile,
@ -42,9 +41,9 @@ namespace xna {
//Clears resource buffers. //Clears resource buffers.
void Clear(Color const& color) const; void Clear(Color const& color) const;
//Clears resource buffers. //Clears resource buffers.
void Clear(ClearOptions options, Color const& color, float depth, Int stencil) const; void Clear(ClearOptions options, Color const& color, float depth, Int stencil) const;
//Presents the display with the contents of the next buffer in the sequence of back buffers owned by the GraphicsDevice. //Presents the display with the contents of the next buffer in the sequence of back buffers owned by the GraphicsDevice.
bool Present() const; bool Present() const;
//Resets the presentation parameters for the current GraphicsDevice. //Resets the presentation parameters for the current GraphicsDevice.
void Reset(std::shared_ptr<PresentationParameters> const& presentationParameters, std::shared_ptr<GraphicsAdapter> const& graphicsAdapter); void Reset(std::shared_ptr<PresentationParameters> const& presentationParameters, std::shared_ptr<GraphicsAdapter> const& graphicsAdapter);
//Gets or sets a viewport identifying the portion of the render target to receive draw calls. //Gets or sets a viewport identifying the portion of the render target to receive draw calls.
@ -56,6 +55,8 @@ namespace xna {
void Initialize(); void Initialize();
std::unique_ptr<GraphicsDeviceImplementation> Implementation;
private: private:
std::shared_ptr<GraphicsAdapter> adapter{ nullptr }; std::shared_ptr<GraphicsAdapter> adapter{ nullptr };
std::shared_ptr<xna::BlendState> blendState{ nullptr }; std::shared_ptr<xna::BlendState> blendState{ nullptr };
@ -65,7 +66,7 @@ namespace xna {
std::shared_ptr<PresentationParameters> presentationParameters{ nullptr }; std::shared_ptr<PresentationParameters> presentationParameters{ nullptr };
std::shared_ptr<RenderTarget2D> renderTarget{ nullptr }; std::shared_ptr<RenderTarget2D> renderTarget{ nullptr };
GraphicsProfile graphicsProfile{ GraphicsProfile::HiDef }; GraphicsProfile graphicsProfile{ GraphicsProfile::HiDef };
xna::Viewport viewport{}; xna::Viewport viewport{};
}; };
} }

View File

@ -2,7 +2,6 @@
#define XNA_GRAPHICS_RASTERIZER_HPP #define XNA_GRAPHICS_RASTERIZER_HPP
#include "gresource.hpp" #include "gresource.hpp"
#include "../platform.hpp"
namespace xna { namespace xna {
@ -28,7 +27,7 @@ namespace xna {
struct RasterizerStateImplementation; struct RasterizerStateImplementation;
//Contains rasterizer state, which determines how to convert vector data (shapes) into raster data (pixels). //Contains rasterizer state, which determines how to convert vector data (shapes) into raster data (pixels).
class RasterizerState : public GraphicsResource, public PlatformImplementation<RasterizerStateImplementation> { class RasterizerState : public GraphicsResource {
public: public:
RasterizerState(); RasterizerState();
RasterizerState(std::shared_ptr<GraphicsDevice> const& device); RasterizerState(std::shared_ptr<GraphicsDevice> const& device);
@ -75,6 +74,8 @@ namespace xna {
bool Initialize(); bool Initialize();
bool Apply(); bool Apply();
std::unique_ptr<RasterizerStateImplementation> Implementation;
}; };
} }

View File

@ -1,7 +1,6 @@
#ifndef XNA_GRAPHICS_SAMPLERSTATE_HPP #ifndef XNA_GRAPHICS_SAMPLERSTATE_HPP
#define XNA_GRAPHICS_SAMPLERSTATE_HPP #define XNA_GRAPHICS_SAMPLERSTATE_HPP
#include "../platform.hpp"
#include "gresource.hpp" #include "gresource.hpp"
#include "shared.hpp" #include "shared.hpp"
#include <memory> #include <memory>
@ -50,7 +49,7 @@ namespace xna {
struct SamplerStateImplementation; struct SamplerStateImplementation;
//Contains sampler state, which determines how to sample texture data. //Contains sampler state, which determines how to sample texture data.
class SamplerState : public GraphicsResource, public PlatformImplementation<SamplerStateImplementation> { class SamplerState : public GraphicsResource {
public: public:
SamplerState(); SamplerState();
SamplerState(std::shared_ptr<GraphicsDevice> const& device); SamplerState(std::shared_ptr<GraphicsDevice> const& device);
@ -109,6 +108,8 @@ namespace xna {
bool Initialize(); bool Initialize();
bool Apply(); bool Apply();
std::unique_ptr<SamplerStateImplementation> Implementation;
}; };
//Collection of SamplerState objects. //Collection of SamplerState objects.

View File

@ -4,7 +4,6 @@
#include "../common/color.hpp" #include "../common/color.hpp"
#include "../common/numerics.hpp" #include "../common/numerics.hpp"
#include "../graphics/gresource.hpp" #include "../graphics/gresource.hpp"
#include "../platform.hpp"
#include <memory> #include <memory>
#include <optional> #include <optional>
#include <string> #include <string>
@ -35,7 +34,7 @@ namespace xna {
struct SpriteBatchImplementation; struct SpriteBatchImplementation;
//Enables a group of sprites to be drawn using the same settings. //Enables a group of sprites to be drawn using the same settings.
class SpriteBatch : public GraphicsResource, public PlatformImplementation<SpriteBatchImplementation> { class SpriteBatch : public GraphicsResource {
public: public:
SpriteBatch(std::shared_ptr<GraphicsDevice> const& device); SpriteBatch(std::shared_ptr<GraphicsDevice> const& device);
@ -147,12 +146,14 @@ namespace xna {
float rotation, Vector2 const& origin, float scale, SpriteEffects effects, float layerDepth) { DrawString(*spriteFont, text, position, color, rotation, origin, scale, effects, layerDepth); } float rotation, Vector2 const& origin, float scale, SpriteEffects effects, float layerDepth) { DrawString(*spriteFont, text, position, color, rotation, origin, scale, effects, layerDepth); }
void DrawString(SpriteFont& spriteFont, std::string const& text, Vector2 const& position, Color const& color, void DrawString(SpriteFont& spriteFont, std::string const& text, Vector2 const& position, Color const& color,
float rotation, Vector2 const& origin, float scale, SpriteEffects effects, float layerDepth); float rotation, Vector2 const& origin, float scale, SpriteEffects effects, float layerDepth);
std::unique_ptr<SpriteBatchImplementation> Implementation;
}; };
struct SpriteFontImplementation; struct SpriteFontImplementation;
//Represents a font texture. //Represents a font texture.
class SpriteFont : public PlatformImplementation<SpriteFontImplementation> { class SpriteFont {
public: public:
SpriteFont( SpriteFont(
std::shared_ptr<Texture2D> const& texture, std::shared_ptr<Texture2D> const& texture,
@ -177,6 +178,8 @@ namespace xna {
int32_t LineSpacing() const; int32_t LineSpacing() const;
//Gets or sets the vertical distance (in pixels) between the base lines of two consecutive lines of text //Gets or sets the vertical distance (in pixels) between the base lines of two consecutive lines of text
void LineSpacing(float value); void LineSpacing(float value);
std::unique_ptr<SpriteFontImplementation> Implementation;
}; };
} }

View File

@ -2,7 +2,6 @@
#define XNA_GRAPHICS_TEXTURE_HPP #define XNA_GRAPHICS_TEXTURE_HPP
#include "../csharp/stream.hpp" #include "../csharp/stream.hpp"
#include "../platform.hpp"
#include "gresource.hpp" #include "gresource.hpp"
#include "shared.hpp" #include "shared.hpp"
#include <cstdint> #include <cstdint>
@ -24,7 +23,7 @@ namespace xna {
struct Texture2DImplementation; struct Texture2DImplementation;
//Represents a 2D grid of texels. //Represents a 2D grid of texels.
class Texture2D : public Texture, public PlatformImplementation<Texture2DImplementation> { class Texture2D : public Texture {
public: public:
Texture2D(); Texture2D();
Texture2D(std::shared_ptr<GraphicsDevice> const& device); Texture2D(std::shared_ptr<GraphicsDevice> const& device);
@ -60,6 +59,8 @@ namespace xna {
void Initialize(); void Initialize();
std::unique_ptr<Texture2DImplementation> Implementation;
protected: protected:
SurfaceFormat surfaceFormat{ SurfaceFormat::Color }; SurfaceFormat surfaceFormat{ SurfaceFormat::Color };
int32_t levelCount{ 0 }; int32_t levelCount{ 0 };

View File

@ -1,14 +0,0 @@
#ifndef XNA_PLATFORM_HPP
#define XNA_PLATFORM_HPP
#include <memory>
namespace xna {
template <typename T> struct PlatformImplementation {
virtual ~PlatformImplementation() {}
std::unique_ptr<T> Implementation;
};
}
#endif