diff --git a/includes/xna-dx/implementations.hpp b/includes/xna-dx/implementations.hpp index ff89487..83fd917 100644 --- a/includes/xna-dx/implementations.hpp +++ b/includes/xna-dx/implementations.hpp @@ -5,15 +5,11 @@ namespace xna { struct GraphicsAdapterImplementation { - friend class GraphicsAdapter; - comptr Adapter; comptr Factory; }; struct BlendStateImplementation { - friend class BlendState; - D3D11_BLEND_DESC Description{}; float BlendFactor[4]{ 1.0F, 1.0F, 1.0F, 1.0F }; UINT SampleMask{ 0xffffffff }; @@ -22,6 +18,11 @@ namespace xna { static constexpr int MAX_RENDER_TARGETS = 8; }; + struct DepthStencilStateImplementation { + comptr DepthStencil; + D3D11_DEPTH_STENCIL_DESC Description{}; + }; + struct SpriteFont::PlatformImplementation { uptr dxSpriteFont{ nullptr }; }; @@ -30,12 +31,7 @@ namespace xna { sptr dxSpriteBatch = nullptr; comptr dxInputLayout = nullptr; sptr dxEffectBuffer = nullptr; - }; - - struct DepthStencilState::PlatformImplementation { - comptr dxDepthStencil = nullptr; - D3D11_DEPTH_STENCIL_DESC dxDescription{}; - }; + }; struct GamePad::PlatformImplementation { uptr _dxGamePad = unew(); diff --git a/includes/xna/graphics/depthstencilstate.hpp b/includes/xna/graphics/depthstencilstate.hpp index 0664143..ce2a1d2 100644 --- a/includes/xna/graphics/depthstencilstate.hpp +++ b/includes/xna/graphics/depthstencilstate.hpp @@ -3,10 +3,14 @@ #include "../default.hpp" #include "gresource.hpp" +#include "../platform.hpp" namespace xna { + + struct DepthStencilStateImplementation; + //Contains depth-stencil state for the device. - class DepthStencilState : public GraphicsResource { + class DepthStencilState : public GraphicsResource, public PlatformImplementation { public: DepthStencilState(); DepthStencilState(sptr const& device); @@ -86,14 +90,8 @@ namespace xna { static uptr DepthRead(); bool Initialize(); - bool Apply(); - - public: - struct PlatformImplementation; - uptr impl = nullptr; + bool Apply(); }; - - using PDepthStencilState = sptr; } #endif \ No newline at end of file diff --git a/sources/framework-dx/depthstencilstate.cpp b/sources/framework-dx/depthstencilstate.cpp index 8b86328..1f4a051 100644 --- a/sources/framework-dx/depthstencilstate.cpp +++ b/sources/framework-dx/depthstencilstate.cpp @@ -26,13 +26,13 @@ namespace xna { } DepthStencilState::DepthStencilState() : GraphicsResource(nullptr) { - impl = unew(); - impl->dxDescription = defaultDesc(); + Implementation = unew(); + Implementation->Description = defaultDesc(); } DepthStencilState::DepthStencilState(sptr const& device) : GraphicsResource(device) { - impl = unew(); - impl->dxDescription = defaultDesc(); + Implementation = unew(); + Implementation->Description = defaultDesc(); } bool DepthStencilState::Initialize() @@ -41,13 +41,13 @@ namespace xna { Exception::Throw(Exception::UNABLE_TO_INITIALIZE); } - if (impl->dxDepthStencil) { - impl->dxDepthStencil = nullptr; + if (Implementation->DepthStencil) { + Implementation->DepthStencil = nullptr; } const auto hr = m_device->impl->_device->CreateDepthStencilState( - &impl->dxDescription, - impl->dxDepthStencil.GetAddressOf()); + &Implementation->Description, + Implementation->DepthStencil.GetAddressOf()); if (FAILED(hr)) { Exception::Throw(Exception::FAILED_TO_CREATE); @@ -62,166 +62,166 @@ namespace xna { Exception::Throw(Exception::INVALID_OPERATION); } - if (!impl->dxDepthStencil) { + if (!Implementation->DepthStencil) { Initialize(); } - m_device->impl->_context->OMSetDepthStencilState(impl->dxDepthStencil.Get(), 0); + m_device->impl->_context->OMSetDepthStencilState(Implementation->DepthStencil.Get(), 0); return true; } uptr DepthStencilState::None() { auto stencil = unew(); - stencil->impl->dxDescription.DepthEnable = false; - stencil->impl->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; + stencil->Implementation->Description.DepthEnable = false; + stencil->Implementation->Description.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; return stencil; } uptr DepthStencilState::Default() { auto stencil = unew(); - stencil->impl->dxDescription.DepthEnable = true; - stencil->impl->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; + stencil->Implementation->Description.DepthEnable = true; + stencil->Implementation->Description.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; return stencil; } uptr DepthStencilState::DepthRead() { auto stencil = unew(); - stencil->impl->dxDescription.DepthEnable = true; - stencil->impl->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; + stencil->Implementation->Description.DepthEnable = true; + stencil->Implementation->Description.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; return stencil; } void DepthStencilState::DepthBufferEnable(bool value) { - impl->dxDescription.DepthEnable = value; + Implementation->Description.DepthEnable = value; } void DepthStencilState::DepthBufferWriteEnable(bool value) { - impl->dxDescription.DepthWriteMask = static_cast(value); + Implementation->Description.DepthWriteMask = static_cast(value); } void DepthStencilState::DepthBufferFunction(ComparisonFunction value) { const auto _value = static_cast(value) + 1; - impl->dxDescription.DepthFunc = static_cast(_value); + Implementation->Description.DepthFunc = static_cast(_value); } void DepthStencilState::StencilEnable(bool value) { - impl->dxDescription.StencilEnable = value; + Implementation->Description.StencilEnable = value; } void DepthStencilState::StencilMask(int value) { - impl->dxDescription.StencilReadMask = static_cast(value); + Implementation->Description.StencilReadMask = static_cast(value); } void DepthStencilState::StencilWriteMask(Int value) { - impl->dxDescription.StencilWriteMask = static_cast(value); + Implementation->Description.StencilWriteMask = static_cast(value); } void DepthStencilState::StencilPass(StencilOperation value) { const auto _value = static_cast(value) + 1; - impl->dxDescription.FrontFace.StencilPassOp = static_cast(_value); + Implementation->Description.FrontFace.StencilPassOp = static_cast(_value); } void DepthStencilState::StencilFail(StencilOperation value) { const auto _value = static_cast(value) + 1; - impl->dxDescription.FrontFace.StencilFailOp = static_cast(_value); + Implementation->Description.FrontFace.StencilFailOp = static_cast(_value); } void DepthStencilState::StencilDepthBufferFail(StencilOperation value) { const auto _value = static_cast(value) + 1; - impl->dxDescription.FrontFace.StencilDepthFailOp = static_cast(_value); + Implementation->Description.FrontFace.StencilDepthFailOp = static_cast(_value); } void DepthStencilState::StencilFunction(ComparisonFunction value) { const auto _value = static_cast(value) + 1; - impl->dxDescription.FrontFace.StencilFunc = static_cast(_value); + Implementation->Description.FrontFace.StencilFunc = static_cast(_value); } void DepthStencilState::CounterClockwiseStencilPass(StencilOperation value) { const auto _value = static_cast(value) + 1; - impl->dxDescription.BackFace.StencilPassOp = static_cast(_value); + Implementation->Description.BackFace.StencilPassOp = static_cast(_value); } void DepthStencilState::CounterClockwiseStencilFail(StencilOperation value) { const auto _value = static_cast(value) + 1; - impl->dxDescription.BackFace.StencilFailOp = static_cast(_value); + Implementation->Description.BackFace.StencilFailOp = static_cast(_value); } void DepthStencilState::CounterClockwiseStencilDepthBufferFail(StencilOperation value) { const auto _value = static_cast(value) + 1; - impl->dxDescription.BackFace.StencilDepthFailOp = static_cast(_value); + Implementation->Description.BackFace.StencilDepthFailOp = static_cast(_value); } void DepthStencilState::CounterClockwiseStencilFunction(ComparisonFunction value) { const auto _value = static_cast(value) + 1; - impl->dxDescription.BackFace.StencilFunc = static_cast(_value); + Implementation->Description.BackFace.StencilFunc = static_cast(_value); } bool DepthStencilState::DepthBufferEnable() const { - return impl->dxDescription.DepthEnable; + return Implementation->Description.DepthEnable; } bool DepthStencilState::DepthBufferWriteEnable() const { - return static_cast(impl->dxDescription.DepthWriteMask); + return static_cast(Implementation->Description.DepthWriteMask); } ComparisonFunction DepthStencilState::DepthBufferFunction() const { - const auto _value = static_cast(impl->dxDescription.DepthFunc) - 1; + const auto _value = static_cast(Implementation->Description.DepthFunc) - 1; return static_cast(_value); } bool DepthStencilState::StencilEnable() const { - return impl->dxDescription.StencilEnable; + return Implementation->Description.StencilEnable; } Int DepthStencilState::StencilMask() const { - return static_cast(impl->dxDescription.StencilReadMask); + return static_cast(Implementation->Description.StencilReadMask); } Int DepthStencilState::StencilWriteMask() const { - return static_cast(impl->dxDescription.StencilWriteMask); + return static_cast(Implementation->Description.StencilWriteMask); } StencilOperation DepthStencilState::StencilPass() const { - const auto _value = static_cast(impl->dxDescription.FrontFace.StencilPassOp) - 1; + const auto _value = static_cast(Implementation->Description.FrontFace.StencilPassOp) - 1; return static_cast(_value); } StencilOperation DepthStencilState::StencilFail() const { - const auto _value = static_cast(impl->dxDescription.FrontFace.StencilFailOp) - 1; + const auto _value = static_cast(Implementation->Description.FrontFace.StencilFailOp) - 1; return static_cast(_value); } StencilOperation DepthStencilState::StencilDepthBufferFail() const { - const auto _value = static_cast(impl->dxDescription.FrontFace.StencilDepthFailOp) - 1; + const auto _value = static_cast(Implementation->Description.FrontFace.StencilDepthFailOp) - 1; return static_cast(_value); } ComparisonFunction DepthStencilState::StencilFunction() const { - const auto _value = static_cast(impl->dxDescription.FrontFace.StencilFunc) - 1; + const auto _value = static_cast(Implementation->Description.FrontFace.StencilFunc) - 1; return static_cast(_value); } StencilOperation DepthStencilState::CounterClockwiseStencilPass() const { - const auto _value = static_cast(impl->dxDescription.BackFace.StencilPassOp) - 1; + const auto _value = static_cast(Implementation->Description.BackFace.StencilPassOp) - 1; return static_cast(_value); } StencilOperation DepthStencilState::CounterClockwiseStencilFail() const { - const auto _value = static_cast(impl->dxDescription.BackFace.StencilFailOp) - 1; + const auto _value = static_cast(Implementation->Description.BackFace.StencilFailOp) - 1; return static_cast(_value); } StencilOperation DepthStencilState::CounterClockwiseStencilDepthBufferFail() const { - const auto _value = static_cast(impl->dxDescription.BackFace.StencilDepthFailOp) - 1; + const auto _value = static_cast(Implementation->Description.BackFace.StencilDepthFailOp) - 1; return static_cast(_value); } ComparisonFunction DepthStencilState::CounterClockwiseStencilFunction() const { - const auto _value = static_cast(impl->dxDescription.BackFace.StencilFunc) - 1; + const auto _value = static_cast(Implementation->Description.BackFace.StencilFunc) - 1; return static_cast(_value); } } \ No newline at end of file diff --git a/sources/framework-dx/sprite.cpp b/sources/framework-dx/sprite.cpp index 6639941..3e31d56 100644 --- a/sources/framework-dx/sprite.cpp +++ b/sources/framework-dx/sprite.cpp @@ -161,7 +161,7 @@ namespace xna { _sortMode, blendState ? blendState->Implementation->BlendState.Get() : nullptr, samplerState ? samplerState->impl->_samplerState.Get() : nullptr, - depthStencil ? depthStencil->impl->dxDepthStencil.Get() : nullptr, + depthStencil ? depthStencil->Implementation->DepthStencil.Get() : nullptr, rasterizerState ? rasterizerState->impl->dxRasterizerState.Get() : nullptr, effectFunc, _transformMatrix