mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Remove PClass e UClass
This commit is contained in:
parent
0525626982
commit
cbf70bf079
@ -6,135 +6,67 @@
|
||||
namespace xna {
|
||||
//Audio
|
||||
class SoundEffect;
|
||||
using PSoundEffect = std::shared_ptr<SoundEffect>;
|
||||
struct SoundEffectInstance;
|
||||
using PSoundEffectInstance = std::shared_ptr<SoundEffectInstance>;
|
||||
class AudioEngine;
|
||||
using PAudioEngine = std::shared_ptr<AudioEngine>;
|
||||
struct WaveFormat;
|
||||
using PWaveFormat = std::shared_ptr<WaveFormat>;
|
||||
|
||||
//CShap
|
||||
struct TimeSpan;
|
||||
using PTimeSpan = std::shared_ptr<TimeSpan>;
|
||||
class Stream;
|
||||
using PStream = std::shared_ptr<Stream>;
|
||||
class FileStream;
|
||||
using PFileStream = std::shared_ptr<FileStream>;
|
||||
class MemoryStream;
|
||||
using PMemoryStream = std::shared_ptr<MemoryStream>;
|
||||
|
||||
//Framework
|
||||
class BoundingBox;
|
||||
using PBoundingBox = std::shared_ptr<BoundingBox>;
|
||||
class BoundingFrustum;
|
||||
using PBoundingFrustum = std::shared_ptr<BoundingFrustum>;
|
||||
class BoundinSphere;
|
||||
using PBoundinSphere = std::shared_ptr<BoundinSphere>;
|
||||
struct Color;
|
||||
using PColor = std::shared_ptr<Color>;
|
||||
class Curve;
|
||||
using PCurve = std::shared_ptr<Curve>;
|
||||
class CurveContinuity;
|
||||
using PCurveContinuity = std::shared_ptr<CurveContinuity>;
|
||||
class CurveKey;
|
||||
using PCurveKey = std::shared_ptr<CurveKey>;
|
||||
class CurveKeyCollection;
|
||||
using PCurveKeyCollection = std::shared_ptr<CurveKeyCollection>;
|
||||
struct Matrix;
|
||||
using PMatrix = std::shared_ptr<Matrix>;
|
||||
class Plane;
|
||||
using PPlane = std::shared_ptr<Plane>;
|
||||
struct Point;
|
||||
using PPoint = std::shared_ptr<Point>;
|
||||
struct Quaternion;
|
||||
using PQuaternion = std::shared_ptr<Quaternion>;
|
||||
class Ray;
|
||||
using PRay = std::shared_ptr<Ray>;
|
||||
struct Rectangle;
|
||||
using PRectangle = std::shared_ptr<Rectangle>;
|
||||
struct Vector2;
|
||||
using PVector2 = std::shared_ptr<Vector2>;
|
||||
struct Vector3;
|
||||
using PVector3 = std::shared_ptr<Vector3>;
|
||||
struct Vector4;
|
||||
using PVector4 = std::shared_ptr<Vector4>;
|
||||
|
||||
|
||||
//Game
|
||||
class DrawableGameComponent;
|
||||
using PDrawableGameComponent = std::shared_ptr<DrawableGameComponent>;
|
||||
//Game
|
||||
class Game;
|
||||
using PGame = std::shared_ptr<Game>;
|
||||
class GameComponent;
|
||||
using PGameComponent = std::shared_ptr<GameComponent>;
|
||||
class GameComponentCollection;
|
||||
using PGameComponentCollection = std::shared_ptr<GameComponentCollection>;
|
||||
class GameClock;
|
||||
using PGameClock = std::shared_ptr<GameClock>;
|
||||
class GameTime;
|
||||
using PGameTime = std::shared_ptr<GameTime>;
|
||||
class GameWindow;
|
||||
using PGameWindow = std::shared_ptr<GameWindow>;
|
||||
class GraphicsDeviceInformation;
|
||||
using PGraphicsDeviceInformation = std::shared_ptr<GraphicsDeviceInformation>;
|
||||
class GraphicsDeviceManager;
|
||||
using PGraphicsDeviceManager = std::shared_ptr<GraphicsDeviceManager>;
|
||||
class IDrawable;
|
||||
using PIDrawable = std::shared_ptr<IDrawable>;
|
||||
class IGameComponent;
|
||||
using PIGameComponent = std::shared_ptr<IGameComponent>;
|
||||
class IUpdatable;
|
||||
using PIUpdatable = std::shared_ptr<IUpdatable>;
|
||||
|
||||
//Graphics
|
||||
class BlendState;
|
||||
using PBlendState = std::shared_ptr<BlendState>;
|
||||
class ConstantBuffer;
|
||||
using PConstantBuffer = std::shared_ptr<ConstantBuffer>;
|
||||
class DataBuffer;
|
||||
using PDataBuffer = std::shared_ptr<DataBuffer>;
|
||||
class DepthStencilState;
|
||||
using PDepthStencilState = std::shared_ptr<DepthStencilState>;
|
||||
class DisplayMode;
|
||||
using PDisplayMode = std::shared_ptr<DisplayMode>;
|
||||
using UDisplayMode = std::unique_ptr<DisplayMode>;
|
||||
class DisplayModeCollection;
|
||||
using PDisplayModeCollection = std::shared_ptr<DisplayModeCollection>;
|
||||
using UDisplayModeCollection = std::unique_ptr<DisplayModeCollection>;
|
||||
class GraphicsAdapter;
|
||||
using PGraphicsAdapter = std::shared_ptr<GraphicsAdapter>;
|
||||
using UGraphicsAdapter = std::unique_ptr<GraphicsAdapter>;
|
||||
class GraphicsDevice;
|
||||
using PGraphicsDevice = std::shared_ptr<GraphicsDevice>;
|
||||
class GraphicsDeviceInformation;
|
||||
using PGraphicsDeviceInformation = std::shared_ptr<GraphicsDeviceInformation>;
|
||||
class PresentationParameters;
|
||||
using PPresentationParameters = std::shared_ptr< PresentationParameters>;
|
||||
class RenderTarget2D;
|
||||
using PRenderTarget2D = std::shared_ptr<RenderTarget2D>;
|
||||
class SwapChain;
|
||||
using PSwapChain = std::shared_ptr<SwapChain>;
|
||||
class Texture;
|
||||
using PTexture = std::shared_ptr<Texture>;
|
||||
class Texture2D;
|
||||
using PTexture2D = std::shared_ptr<Texture2D>;
|
||||
class RasterizerState;
|
||||
using PRasterizerState = std::shared_ptr<RasterizerState>;
|
||||
class SamplerState;
|
||||
using PSamplerState = std::shared_ptr<SamplerState>;
|
||||
class Shader;
|
||||
using PShader = std::shared_ptr<Shader>;
|
||||
class SpriteBatch;
|
||||
using PSpriteBatch = std::shared_ptr<SpriteBatch>;
|
||||
class SpriteFont;
|
||||
using PSpriteFont = std::shared_ptr<SpriteFont>;
|
||||
struct VertexPositionColor;
|
||||
using PVertexPositionColor = std::shared_ptr<VertexPositionColor>;
|
||||
class VertexShader;
|
||||
using pVertexShader = std::shared_ptr<VertexShader>;
|
||||
struct Viewport;
|
||||
using PViewport = std::shared_ptr<Viewport>;
|
||||
|
||||
//Input
|
||||
struct GamePadTriggers;
|
||||
|
@ -14,8 +14,8 @@ namespace xna {
|
||||
|
||||
virtual void Exit() = 0;
|
||||
virtual int Run() = 0;
|
||||
virtual PGameWindow Window() = 0;
|
||||
virtual PGraphicsDevice GetGraphicsDevice() = 0;
|
||||
virtual sptr<GameWindow> Window() = 0;
|
||||
virtual sptr<GraphicsDevice> GetGraphicsDevice() = 0;
|
||||
|
||||
protected:
|
||||
virtual void Draw(GameTime const& gameTime) = 0;
|
||||
|
@ -8,14 +8,14 @@ namespace xna {
|
||||
class IGraphicsDeviceInformation {
|
||||
public:
|
||||
virtual ~IGraphicsDeviceInformation(){}
|
||||
virtual PGraphicsAdapter Adapter() const = 0;
|
||||
virtual void Adapter(PGraphicsAdapter const& value) = 0;
|
||||
virtual sptr<GraphicsAdapter> Adapter() const = 0;
|
||||
virtual void Adapter(sptr<GraphicsAdapter> const& value) = 0;
|
||||
virtual xna::PresentationParameters PresentationParameters() const = 0;
|
||||
virtual void PresentationParameters(xna::PresentationParameters const& value) = 0;
|
||||
virtual xna::GraphicsProfile GraphicsProfile() const = 0;
|
||||
virtual void GraphicsProfile(xna::GraphicsProfile value) = 0;
|
||||
virtual PGameWindow Window() const = 0;
|
||||
virtual void Window(PGameWindow const& window) = 0;
|
||||
virtual sptr<GameWindow> Window() const = 0;
|
||||
virtual void Window(sptr<GameWindow> const& window) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -16,14 +16,14 @@ namespace xna {
|
||||
virtual Uint Revision() const = 0;
|
||||
virtual Uint SubSystemId() const = 0;
|
||||
virtual Uint VendorId() const = 0;
|
||||
virtual UDisplayModeCollection SupportedDisplayModes() const = 0;
|
||||
virtual UDisplayModeCollection SupportedDisplayModes(SurfaceFormat surfaceFormat) const = 0;
|
||||
virtual PDisplayMode CurrentDisplayMode() = 0;
|
||||
virtual uptr<DisplayModeCollection> SupportedDisplayModes() const = 0;
|
||||
virtual uptr<DisplayModeCollection> SupportedDisplayModes(SurfaceFormat surfaceFormat) const = 0;
|
||||
virtual sptr<DisplayMode> CurrentDisplayMode() = 0;
|
||||
virtual void CurrentDisplayMode(SurfaceFormat surfaceFormat, Uint width, Uint height) = 0;
|
||||
|
||||
static UGraphicsAdapter DefaultAdapter();
|
||||
static void Adapters(std::vector<PGraphicsAdapter>& adapters);
|
||||
static void Adapters(std::vector<UGraphicsAdapter>& adapters);
|
||||
static uptr<GraphicsAdapter> DefaultAdapter();
|
||||
static void Adapters(std::vector<sptr<GraphicsAdapter>>& adapters);
|
||||
static void Adapters(std::vector<uptr<GraphicsAdapter>>& adapters);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@ namespace xna {
|
||||
virtual void Clear(Color const& color) = 0;
|
||||
virtual bool Initialize(GameWindow& gameWindow) = 0;
|
||||
virtual bool Present() = 0;
|
||||
virtual PGraphicsAdapter Adapter() const = 0;
|
||||
virtual void Adapter(PGraphicsAdapter const& adapter) = 0;
|
||||
virtual sptr<GraphicsAdapter> Adapter() const = 0;
|
||||
virtual void Adapter(sptr<GraphicsAdapter> const& adapter) = 0;
|
||||
virtual xna::Viewport Viewport() const = 0;
|
||||
virtual void Viewport(xna::Viewport const& viewport) = 0;
|
||||
virtual void UseVSync(bool use) = 0;
|
||||
|
@ -7,7 +7,8 @@ namespace xna {
|
||||
class ISamplerState {
|
||||
public:
|
||||
virtual ~ISamplerState(){}
|
||||
virtual bool Initialize(GraphicsDevice& device, xna_error_nullarg) = 0;
|
||||
virtual bool Initialize(xna_error_nullarg) = 0;
|
||||
virtual bool Apply(xna_error_nullarg) = 0;
|
||||
virtual void Filter(TextureFilter value) = 0;
|
||||
virtual void AddressU(TextureAddressMode value) = 0;
|
||||
virtual void AddressV(TextureAddressMode value) = 0;
|
||||
@ -25,14 +26,7 @@ namespace xna {
|
||||
virtual float MipLODBias() const = 0;
|
||||
virtual float MinLOD() const = 0;
|
||||
virtual float MaxLOD() const = 0;
|
||||
virtual Uint MaxAnisotropy() const = 0;
|
||||
|
||||
static PSamplerState PoinWrap();
|
||||
static PSamplerState PointClamp();
|
||||
static PSamplerState LinearWrap();
|
||||
static PSamplerState LinearClamp();
|
||||
static PSamplerState AnisotropicWrap();
|
||||
static PSamplerState AnisotropicClamp();
|
||||
virtual Uint MaxAnisotropy() const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
namespace xna {
|
||||
static size_t getDisplayModesCount(IDXGIAdapter* adapter);
|
||||
static UDisplayModeCollection createDisplayModeCollection(std::vector<DXGI_MODE_DESC> const& source);
|
||||
static uptr<DisplayModeCollection> createDisplayModeCollection(std::vector<DXGI_MODE_DESC> const& source);
|
||||
|
||||
UGraphicsAdapter IGraphicsAdapter::DefaultAdapter() {
|
||||
uptr<GraphicsAdapter> IGraphicsAdapter::DefaultAdapter() {
|
||||
IDXGIFactory1* pFactory = nullptr;
|
||||
|
||||
if FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&pFactory))
|
||||
@ -28,7 +28,7 @@ namespace xna {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void IGraphicsAdapter::Adapters(std::vector<PGraphicsAdapter>& adapters){
|
||||
void IGraphicsAdapter::Adapters(std::vector<sptr<GraphicsAdapter>>& adapters){
|
||||
IDXGIFactory1* pFactory = nullptr;
|
||||
|
||||
if FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&pFactory))
|
||||
@ -50,7 +50,7 @@ namespace xna {
|
||||
pFactory = nullptr;
|
||||
}
|
||||
|
||||
void IGraphicsAdapter::Adapters(std::vector<UGraphicsAdapter>& adapters) {
|
||||
void IGraphicsAdapter::Adapters(std::vector<uptr<GraphicsAdapter>>& adapters) {
|
||||
IDXGIFactory1* pFactory = nullptr;
|
||||
|
||||
if FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&pFactory))
|
||||
@ -154,7 +154,7 @@ namespace xna {
|
||||
return static_cast<Uint>(desc.VendorId);
|
||||
}
|
||||
|
||||
UDisplayModeCollection GraphicsAdapter::SupportedDisplayModes() const {
|
||||
uptr<DisplayModeCollection> GraphicsAdapter::SupportedDisplayModes() const {
|
||||
if (!dxadapter) return nullptr;
|
||||
|
||||
const auto totalDisplay = getDisplayModesCount(dxadapter);
|
||||
@ -193,7 +193,7 @@ namespace xna {
|
||||
return createDisplayModeCollection(buffer);
|
||||
}
|
||||
|
||||
UDisplayModeCollection GraphicsAdapter::SupportedDisplayModes(SurfaceFormat surfaceFormat) const
|
||||
uptr<DisplayModeCollection> GraphicsAdapter::SupportedDisplayModes(SurfaceFormat surfaceFormat) const
|
||||
{
|
||||
if (!dxadapter) return nullptr;
|
||||
|
||||
@ -222,7 +222,7 @@ namespace xna {
|
||||
return uNew<DisplayModeCollection>();
|
||||
}
|
||||
|
||||
PDisplayMode GraphicsAdapter::CurrentDisplayMode() {
|
||||
sptr<DisplayMode> GraphicsAdapter::CurrentDisplayMode() {
|
||||
if (!_currentDisplayMode) {
|
||||
CurrentDisplayMode(SurfaceFormat::Color, GraphicsDeviceManager::DefaultBackBufferWidth, GraphicsDeviceManager::DefaultBackBufferHeight);
|
||||
}
|
||||
@ -278,11 +278,11 @@ namespace xna {
|
||||
return numModes;
|
||||
}
|
||||
|
||||
static UDisplayModeCollection createDisplayModeCollection(std::vector<DXGI_MODE_DESC> const& source) {
|
||||
static uptr<DisplayModeCollection> createDisplayModeCollection(std::vector<DXGI_MODE_DESC> const& source) {
|
||||
auto collection = uNew<DisplayModeCollection>();
|
||||
DisplayMode currentDisplayMode;
|
||||
std::vector<PDisplayMode> displayList;
|
||||
PDisplayMode pDisplay = nullptr;
|
||||
std::vector<sptr<DisplayMode>> displayList;
|
||||
sptr<DisplayMode> pDisplay = nullptr;
|
||||
|
||||
for (size_t i = 0; i < source.size(); ++i) {
|
||||
auto& modedesc = source[i];
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "displaymode-dx.hpp"
|
||||
#include "dxheaders.hpp"
|
||||
|
||||
|
||||
namespace xna {
|
||||
class GraphicsAdapter : public IGraphicsAdapter {
|
||||
public:
|
||||
@ -27,9 +26,9 @@ namespace xna {
|
||||
virtual Uint Revision() const override;
|
||||
virtual Uint SubSystemId() const override;
|
||||
virtual Uint VendorId() const override;
|
||||
virtual UDisplayModeCollection SupportedDisplayModes() const override;
|
||||
virtual UDisplayModeCollection SupportedDisplayModes(SurfaceFormat surfaceFormat) const override;
|
||||
virtual PDisplayMode CurrentDisplayMode() override;
|
||||
virtual uptr<DisplayModeCollection> SupportedDisplayModes() const override;
|
||||
virtual uptr<DisplayModeCollection> SupportedDisplayModes(SurfaceFormat surfaceFormat) const override;
|
||||
virtual sptr<DisplayMode> CurrentDisplayMode() override;
|
||||
virtual void CurrentDisplayMode(SurfaceFormat surfaceFormat, Uint width, Uint height) override;
|
||||
virtual constexpr bool IsDefaultAdapter() const { return _index == 0; }
|
||||
bool GetOutput(UINT slot, IDXGIOutput*& output);
|
||||
@ -38,7 +37,7 @@ namespace xna {
|
||||
IDXGIAdapter1* dxadapter{ nullptr };
|
||||
private:
|
||||
Uint _index{ 0 };
|
||||
PDisplayMode _currentDisplayMode = nullptr;
|
||||
sptr<DisplayMode> _currentDisplayMode = nullptr;
|
||||
|
||||
public:
|
||||
static constexpr DXGI_FORMAT ConvertSurfaceToDXGIFORMAT(SurfaceFormat format)
|
||||
|
@ -41,11 +41,11 @@ namespace xna {
|
||||
virtual bool Initialize(GameWindow& gameWindow) override;
|
||||
virtual bool Present() override;
|
||||
|
||||
virtual PGraphicsAdapter Adapter() const override {
|
||||
virtual sptr<GraphicsAdapter> Adapter() const override {
|
||||
return _adapter;
|
||||
}
|
||||
|
||||
virtual void Adapter(PGraphicsAdapter const& adapter) override {
|
||||
virtual void Adapter(sptr<GraphicsAdapter> const& adapter) override {
|
||||
_adapter = adapter;
|
||||
}
|
||||
|
||||
@ -75,10 +75,10 @@ namespace xna {
|
||||
ID3D11Device* _device{ nullptr };
|
||||
ID3D11DeviceContext* _context{ nullptr };
|
||||
IDXGIFactory1* _factory = nullptr;
|
||||
PSwapChain _swapChain{ nullptr };
|
||||
PGraphicsAdapter _adapter{ nullptr };
|
||||
PRenderTarget2D _renderTarget2D{ nullptr };
|
||||
PBlendState _blendState{ nullptr };
|
||||
sptr<SwapChain> _swapChain{ nullptr };
|
||||
sptr<GraphicsAdapter> _adapter{ nullptr };
|
||||
sptr<RenderTarget2D> _renderTarget2D{ nullptr };
|
||||
sptr<BlendState> _blendState{ nullptr };
|
||||
xna::Viewport _viewport{};
|
||||
xna::PresentationParameters _presentationParameters;
|
||||
|
||||
|
@ -14,12 +14,12 @@ namespace xna {
|
||||
return counter;
|
||||
}
|
||||
|
||||
std::vector<PDisplayMode> DisplayModeCollection::Query(SurfaceFormat format) const
|
||||
std::vector<sptr<DisplayMode>> DisplayModeCollection::Query(SurfaceFormat format) const
|
||||
{
|
||||
const auto count = SurfaceCount(format);
|
||||
|
||||
size_t index = 0;
|
||||
std::vector<PDisplayMode> modes(count);
|
||||
std::vector<sptr<DisplayMode>> modes(count);
|
||||
|
||||
for (size_t i = 0; i < _displayModes.size(); ++i) {
|
||||
if (_displayModes[i]->Format() == format) {
|
||||
@ -34,9 +34,9 @@ namespace xna {
|
||||
return modes;
|
||||
}
|
||||
|
||||
PDisplayMode DisplayModeCollection::Query(SurfaceFormat format, Uint width, Uint height) const
|
||||
sptr<DisplayMode> DisplayModeCollection::Query(SurfaceFormat format, Uint width, Uint height) const
|
||||
{
|
||||
PDisplayMode matched = nullptr;
|
||||
sptr<DisplayMode> matched = nullptr;
|
||||
|
||||
for (size_t i = 0; i < _displayModes.size(); ++i) {
|
||||
const auto& mode = _displayModes[i];
|
||||
|
@ -85,16 +85,16 @@ namespace xna {
|
||||
|
||||
DisplayModeCollection(size_t count) : _displayModes(count) {}
|
||||
|
||||
DisplayModeCollection(std::vector<PDisplayMode> const& displayModes) :
|
||||
DisplayModeCollection(std::vector<sptr<DisplayMode>> const& displayModes) :
|
||||
_displayModes(displayModes) {}
|
||||
|
||||
virtual size_t SurfaceCount(SurfaceFormat format) const override;
|
||||
|
||||
std::vector<PDisplayMode> Query(SurfaceFormat format) const;
|
||||
PDisplayMode Query(SurfaceFormat format, Uint width, Uint height) const;
|
||||
std::vector<sptr<DisplayMode>> Query(SurfaceFormat format) const;
|
||||
sptr<DisplayMode> Query(SurfaceFormat format, Uint width, Uint height) const;
|
||||
|
||||
public:
|
||||
std::vector<PDisplayMode> _displayModes;
|
||||
std::vector<sptr<DisplayMode>> _displayModes;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -18,11 +18,11 @@ namespace xna {
|
||||
|
||||
virtual int Run() override;
|
||||
|
||||
virtual PGameWindow Window() override {
|
||||
virtual sptr<GameWindow> Window() override {
|
||||
return _gameWindow;
|
||||
}
|
||||
|
||||
virtual PGraphicsDevice GetGraphicsDevice() override {
|
||||
virtual sptr<GraphicsDevice> GetGraphicsDevice() override {
|
||||
return _graphicsDevice;
|
||||
}
|
||||
|
||||
@ -36,11 +36,11 @@ namespace xna {
|
||||
virtual void Update(GameTime const& gameTime) override;
|
||||
|
||||
public:
|
||||
PGraphicsDevice _graphicsDevice{ nullptr };
|
||||
sptr<GraphicsDevice> _graphicsDevice{ nullptr };
|
||||
|
||||
protected:
|
||||
PGameWindow _gameWindow{ nullptr };
|
||||
PAudioEngine _audioEngine = nullptr;
|
||||
sptr<GameWindow> _gameWindow{ nullptr };
|
||||
sptr<AudioEngine> _audioEngine = nullptr;
|
||||
|
||||
GameTime _currentGameTime{};
|
||||
DX::StepTimer _stepTimer;
|
||||
|
@ -11,11 +11,11 @@ namespace xna {
|
||||
public:
|
||||
virtual ~GraphicsDeviceInformation() override {}
|
||||
|
||||
inline virtual PGraphicsAdapter Adapter() const override {
|
||||
inline virtual sptr<GraphicsAdapter> Adapter() const override {
|
||||
return _adapter;
|
||||
};
|
||||
|
||||
inline virtual void Adapter(PGraphicsAdapter const& value) override {
|
||||
inline virtual void Adapter(sptr<GraphicsAdapter> const& value) override {
|
||||
_adapter = value;
|
||||
}
|
||||
|
||||
@ -35,19 +35,19 @@ namespace xna {
|
||||
_profile = value;
|
||||
};
|
||||
|
||||
inline virtual PGameWindow Window() const override {
|
||||
inline virtual sptr<GameWindow> Window() const override {
|
||||
return _window;
|
||||
}
|
||||
|
||||
inline virtual void Window(PGameWindow const& window) override {
|
||||
inline virtual void Window(sptr<GameWindow> const& window) override {
|
||||
_window = window;
|
||||
}
|
||||
|
||||
public:
|
||||
PGraphicsAdapter _adapter{ nullptr };
|
||||
sptr<GraphicsAdapter> _adapter{ nullptr };
|
||||
xna::GraphicsProfile _profile{xna::GraphicsProfile::Reach};
|
||||
xna::PresentationParameters _parameters{};
|
||||
PGameWindow _window{ nullptr };
|
||||
sptr<GameWindow> _window{ nullptr };
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace xna {
|
||||
Int _backBufferWidth{ DefaultBackBufferWidth };
|
||||
Int _backBufferHeight{ DefaultBackBufferHeight };
|
||||
bool _isDeviceDirty{ false };
|
||||
PGraphicsDevice _device = nullptr;
|
||||
sptr<GraphicsDevice> _device = nullptr;
|
||||
bool _isFullScreen{ false };
|
||||
GraphicsDeviceInformation _information{};
|
||||
|
||||
|
@ -2,64 +2,80 @@
|
||||
#include "device-dx.hpp"
|
||||
|
||||
namespace xna {
|
||||
PSamplerState ISamplerState::PoinWrap() {
|
||||
auto state = New<SamplerState>();
|
||||
state->_description.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||
state->_description.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
state->_description.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
state->_description.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
return state;
|
||||
}
|
||||
|
||||
PSamplerState ISamplerState::PointClamp() {
|
||||
auto state = New<SamplerState>();
|
||||
state->_description.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||
state->_description.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
state->_description.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
state->_description.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
return state;
|
||||
}
|
||||
|
||||
PSamplerState ISamplerState::LinearWrap() {
|
||||
auto state = New<SamplerState>();
|
||||
state->_description.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
state->_description.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
state->_description.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
state->_description.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
return state;
|
||||
}
|
||||
|
||||
PSamplerState ISamplerState::LinearClamp() {
|
||||
auto state = New<SamplerState>();
|
||||
state->_description.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
state->_description.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
state->_description.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
state->_description.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
return state;
|
||||
}
|
||||
|
||||
PSamplerState ISamplerState::AnisotropicWrap() {
|
||||
auto state = New<SamplerState>();
|
||||
state->_description.Filter = D3D11_FILTER_ANISOTROPIC;
|
||||
state->_description.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
state->_description.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
state->_description.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
return state;
|
||||
}
|
||||
|
||||
PSamplerState ISamplerState::AnisotropicClamp() {
|
||||
auto state = New<SamplerState>();
|
||||
state->_description.Filter = D3D11_FILTER_ANISOTROPIC;
|
||||
state->_description.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
state->_description.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
state->_description.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
return state;
|
||||
}
|
||||
|
||||
bool SamplerState::Initialize(GraphicsDevice& device, xna_error_ptr_arg)
|
||||
bool SamplerState::Apply(xna_error_ptr_arg)
|
||||
{
|
||||
if (!device._device) {
|
||||
xna_error_apply(err, XnaErrorCode::ARGUMENT_IS_NULL);
|
||||
if (!m_device || !m_device->_context) {
|
||||
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_samplerState) {
|
||||
xna_error_apply(err, XnaErrorCode::UNINTIALIZED_RESOURCE);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_device->_context->PSSetSamplers(0, 1, &_samplerState);
|
||||
|
||||
return true;
|
||||
}
|
||||
uptr<SamplerState> SamplerState::PoinWrap() {
|
||||
auto state = std::unique_ptr<SamplerState>(new SamplerState());
|
||||
state->_description.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||
state->_description.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
state->_description.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
state->_description.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
return state;
|
||||
}
|
||||
|
||||
uptr<SamplerState> SamplerState::PointClamp() {
|
||||
auto state = std::unique_ptr<SamplerState>(new SamplerState());
|
||||
state->_description.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||
state->_description.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
state->_description.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
state->_description.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
return state;
|
||||
}
|
||||
|
||||
uptr<SamplerState> SamplerState::LinearWrap() {
|
||||
auto state = std::unique_ptr<SamplerState>(new SamplerState());
|
||||
state->_description.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
state->_description.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
state->_description.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
state->_description.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
return state;
|
||||
}
|
||||
|
||||
uptr<SamplerState> SamplerState::LinearClamp() {
|
||||
auto state = std::unique_ptr<SamplerState>(new SamplerState());
|
||||
state->_description.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
state->_description.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
state->_description.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
state->_description.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
return state;
|
||||
}
|
||||
|
||||
uptr<SamplerState> SamplerState::AnisotropicWrap() {
|
||||
auto state = std::unique_ptr<SamplerState>(new SamplerState());
|
||||
state->_description.Filter = D3D11_FILTER_ANISOTROPIC;
|
||||
state->_description.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
state->_description.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
state->_description.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
return state;
|
||||
}
|
||||
|
||||
uptr<SamplerState> SamplerState::AnisotropicClamp() {
|
||||
auto state = std::unique_ptr<SamplerState>(new SamplerState());
|
||||
state->_description.Filter = D3D11_FILTER_ANISOTROPIC;
|
||||
state->_description.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
state->_description.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
state->_description.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
return state;
|
||||
}
|
||||
|
||||
bool SamplerState::Initialize(xna_error_ptr_arg)
|
||||
{
|
||||
if (!m_device || !m_device->_device) {
|
||||
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -68,7 +84,7 @@ namespace xna {
|
||||
_samplerState = nullptr;
|
||||
}
|
||||
|
||||
const auto hr = device._device->CreateSamplerState(&_description, &_samplerState);
|
||||
const auto hr = m_device->_device->CreateSamplerState(&_description, &_samplerState);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
xna_error_apply(err, XnaErrorCode::FAILED_OPERATION);
|
||||
|
@ -2,13 +2,14 @@
|
||||
#define XNA_PLATFORM_SAMPLERSTATE_DX_HPP
|
||||
|
||||
#include "../graphics/samplerstate.hpp"
|
||||
#include "../graphics/gresource.hpp"
|
||||
#include "dxheaders.hpp"
|
||||
|
||||
namespace xna {
|
||||
class SamplerState : public ISamplerState {
|
||||
class SamplerState : public ISamplerState, public GraphicsResource {
|
||||
public:
|
||||
SamplerState() {
|
||||
_description.MaxAnisotropy = 4;
|
||||
SamplerState(GraphicsDevice* device) : GraphicsResource(device) {
|
||||
_description.MaxAnisotropy = 4;
|
||||
}
|
||||
|
||||
virtual ~SamplerState() override {
|
||||
@ -18,7 +19,8 @@ namespace xna {
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool Initialize(GraphicsDevice& device, xna_error_nullarg) override;
|
||||
virtual bool Initialize(xna_error_nullarg) override;
|
||||
virtual bool Apply(xna_error_nullarg) override;
|
||||
|
||||
virtual constexpr void Filter(TextureFilter value) override {
|
||||
switch (value)
|
||||
@ -50,7 +52,7 @@ namespace xna {
|
||||
case xna::TextureFilter::MinPointMagLinearMipPoint:
|
||||
_description.Filter = D3D11_FILTER::D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT;
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -68,7 +70,7 @@ namespace xna {
|
||||
}
|
||||
|
||||
virtual constexpr void Comparison(ComparisonFunction value) override {
|
||||
_description.ComparisonFunc = static_cast<D3D11_COMPARISON_FUNC>(static_cast<int>(value) + 1);
|
||||
_description.ComparisonFunc = static_cast<D3D11_COMPARISON_FUNC>(static_cast<int>(value) + 1);
|
||||
}
|
||||
|
||||
virtual constexpr void MipLODBias(float value) override {
|
||||
@ -91,26 +93,26 @@ namespace xna {
|
||||
switch (_description.Filter)
|
||||
{
|
||||
case D3D11_FILTER::D3D11_FILTER_MIN_MAG_MIP_LINEAR:
|
||||
return xna::TextureFilter::Linear;
|
||||
return xna::TextureFilter::Linear;
|
||||
case D3D11_FILTER_MIN_MAG_MIP_POINT:
|
||||
return xna::TextureFilter::Point;
|
||||
case D3D11_FILTER_ANISOTROPIC:
|
||||
case D3D11_FILTER_ANISOTROPIC:
|
||||
return xna::TextureFilter::Anisotropic;
|
||||
case D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT:
|
||||
return xna::TextureFilter::LinearMipPoint;
|
||||
case D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR:
|
||||
case D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT:
|
||||
return xna::TextureFilter::LinearMipPoint;
|
||||
case D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR:
|
||||
return xna::TextureFilter::PointMipLinear;
|
||||
case D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR:
|
||||
return xna::TextureFilter::MinLinearMagPointMipLinear;
|
||||
case D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT:
|
||||
case D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR:
|
||||
return xna::TextureFilter::MinLinearMagPointMipLinear;
|
||||
case D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT:
|
||||
return xna::TextureFilter::MinLinearMagPointMipPoint;
|
||||
case D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR:
|
||||
return xna::TextureFilter::MinPointMagLinearMipLinear;
|
||||
case D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT:
|
||||
case D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR:
|
||||
return xna::TextureFilter::MinPointMagLinearMipLinear;
|
||||
case D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT:
|
||||
return xna::TextureFilter::MinPointMagLinearMipPoint;
|
||||
default:
|
||||
return xna::TextureFilter::Linear;
|
||||
}
|
||||
return xna::TextureFilter::Linear;
|
||||
}
|
||||
}
|
||||
|
||||
virtual constexpr TextureAddressMode AddressU() const override {
|
||||
@ -118,7 +120,7 @@ namespace xna {
|
||||
ConvertAddressMode(_description.AddressU, mode);
|
||||
return mode;
|
||||
}
|
||||
|
||||
|
||||
virtual constexpr TextureAddressMode AddressV() const override {
|
||||
TextureAddressMode mode;
|
||||
ConvertAddressMode(_description.AddressV, mode);
|
||||
@ -132,17 +134,17 @@ namespace xna {
|
||||
}
|
||||
|
||||
virtual ComparisonFunction Comparison() const override {
|
||||
return static_cast<ComparisonFunction>(_description.ComparisonFunc - 1);
|
||||
return static_cast<ComparisonFunction>(_description.ComparisonFunc - 1);
|
||||
}
|
||||
|
||||
|
||||
virtual constexpr float MipLODBias() const override {
|
||||
return _description.MipLODBias;
|
||||
}
|
||||
|
||||
|
||||
virtual constexpr float MinLOD() const override {
|
||||
return _description.MinLOD;
|
||||
}
|
||||
|
||||
|
||||
virtual constexpr float MaxLOD() const override {
|
||||
return _description.MaxLOD;
|
||||
}
|
||||
@ -151,18 +153,28 @@ namespace xna {
|
||||
return _description.MaxAnisotropy;
|
||||
}
|
||||
|
||||
static uptr<SamplerState> PoinWrap();
|
||||
static uptr<SamplerState> PointClamp();
|
||||
static uptr<SamplerState> LinearWrap();
|
||||
static uptr<SamplerState> LinearClamp();
|
||||
static uptr<SamplerState> AnisotropicWrap();
|
||||
static uptr<SamplerState> AnisotropicClamp();
|
||||
|
||||
public:
|
||||
ID3D11SamplerState* _samplerState = nullptr;
|
||||
D3D11_SAMPLER_DESC _description{};
|
||||
|
||||
public:
|
||||
static constexpr void ConvertAddressMode(TextureAddressMode value, D3D11_TEXTURE_ADDRESS_MODE& target) {
|
||||
target = static_cast<D3D11_TEXTURE_ADDRESS_MODE>(static_cast<int>(value) + 1);
|
||||
target = static_cast<D3D11_TEXTURE_ADDRESS_MODE>(static_cast<int>(value) + 1);
|
||||
}
|
||||
|
||||
static constexpr void ConvertAddressMode(D3D11_TEXTURE_ADDRESS_MODE value, TextureAddressMode& target) {
|
||||
target = static_cast<TextureAddressMode>(value - 1);
|
||||
target = static_cast<TextureAddressMode>(value - 1);
|
||||
}
|
||||
|
||||
private:
|
||||
SamplerState() : GraphicsResource(nullptr) {}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ namespace xna {
|
||||
Texture2D::Texture2D() {
|
||||
}
|
||||
|
||||
PTexture2D Texture2D::FromStream(GraphicsDevice& device, String const& fileName, xna_error_ptr_arg)
|
||||
sptr<Texture2D> Texture2D::FromStream(GraphicsDevice& device, String const& fileName, xna_error_ptr_arg)
|
||||
{
|
||||
auto texture2d = New<Texture2D>();
|
||||
ID3D11Resource* resource = nullptr;
|
||||
|
@ -31,7 +31,7 @@ namespace xna {
|
||||
return _description.Height;
|
||||
}
|
||||
|
||||
static PTexture2D FromStream(GraphicsDevice& device, String const& fileName, xna_error_nullarg);
|
||||
static sptr<Texture2D> FromStream(GraphicsDevice& device, String const& fileName, xna_error_nullarg);
|
||||
|
||||
public:
|
||||
ID3D11Texture2D* _texture2D{nullptr};
|
||||
|
@ -48,9 +48,9 @@ namespace xna {
|
||||
}
|
||||
|
||||
private:
|
||||
PGraphicsDeviceManager graphics = nullptr;
|
||||
PSpriteBatch spriteBatch = nullptr;
|
||||
PTexture2D texture = nullptr; //200x200
|
||||
sptr<GraphicsDeviceManager> graphics = nullptr;
|
||||
sptr<SpriteBatch> spriteBatch = nullptr;
|
||||
sptr<Texture2D> texture = nullptr; //200x200
|
||||
Vector2 position{};
|
||||
std::vector<Vector2> points;
|
||||
MouseState currentState{};
|
||||
|
Loading…
x
Reference in New Issue
Block a user