mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Adiciona PlatformImplementation em DepthStencilState
This commit is contained in:
parent
9fac00699d
commit
fd9709f530
@ -5,15 +5,11 @@
|
||||
|
||||
namespace xna {
|
||||
struct GraphicsAdapterImplementation {
|
||||
friend class GraphicsAdapter;
|
||||
|
||||
comptr<IDXGIAdapter1> Adapter;
|
||||
comptr<IDXGIFactory1> 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<ID3D11DepthStencilState> DepthStencil;
|
||||
D3D11_DEPTH_STENCIL_DESC Description{};
|
||||
};
|
||||
|
||||
struct SpriteFont::PlatformImplementation {
|
||||
uptr<DirectX::SpriteFont> dxSpriteFont{ nullptr };
|
||||
};
|
||||
@ -30,12 +31,7 @@ namespace xna {
|
||||
sptr<DirectX::SpriteBatch> dxSpriteBatch = nullptr;
|
||||
comptr<ID3D11InputLayout> dxInputLayout = nullptr;
|
||||
sptr<DirectX::DX11::IEffect> dxEffectBuffer = nullptr;
|
||||
};
|
||||
|
||||
struct DepthStencilState::PlatformImplementation {
|
||||
comptr<ID3D11DepthStencilState> dxDepthStencil = nullptr;
|
||||
D3D11_DEPTH_STENCIL_DESC dxDescription{};
|
||||
};
|
||||
};
|
||||
|
||||
struct GamePad::PlatformImplementation {
|
||||
uptr<DirectX::GamePad> _dxGamePad = unew<DirectX::GamePad>();
|
||||
|
@ -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<DepthStencilStateImplementation> {
|
||||
public:
|
||||
DepthStencilState();
|
||||
DepthStencilState(sptr<GraphicsDevice> const& device);
|
||||
@ -86,14 +90,8 @@ namespace xna {
|
||||
static uptr<DepthStencilState> DepthRead();
|
||||
|
||||
bool Initialize();
|
||||
bool Apply();
|
||||
|
||||
public:
|
||||
struct PlatformImplementation;
|
||||
uptr<PlatformImplementation> impl = nullptr;
|
||||
bool Apply();
|
||||
};
|
||||
|
||||
using PDepthStencilState = sptr<DepthStencilState>;
|
||||
}
|
||||
|
||||
#endif
|
@ -26,13 +26,13 @@ namespace xna {
|
||||
}
|
||||
|
||||
DepthStencilState::DepthStencilState() : GraphicsResource(nullptr) {
|
||||
impl = unew<PlatformImplementation>();
|
||||
impl->dxDescription = defaultDesc();
|
||||
Implementation = unew<DepthStencilStateImplementation>();
|
||||
Implementation->Description = defaultDesc();
|
||||
}
|
||||
|
||||
DepthStencilState::DepthStencilState(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
||||
impl = unew<PlatformImplementation>();
|
||||
impl->dxDescription = defaultDesc();
|
||||
Implementation = unew<DepthStencilStateImplementation>();
|
||||
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> DepthStencilState::None() {
|
||||
auto stencil = unew<DepthStencilState>();
|
||||
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> DepthStencilState::Default() {
|
||||
auto stencil = unew<DepthStencilState>();
|
||||
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> DepthStencilState::DepthRead() {
|
||||
auto stencil = unew<DepthStencilState>();
|
||||
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<D3D11_DEPTH_WRITE_MASK>(value);
|
||||
Implementation->Description.DepthWriteMask = static_cast<D3D11_DEPTH_WRITE_MASK>(value);
|
||||
}
|
||||
|
||||
void DepthStencilState::DepthBufferFunction(ComparisonFunction value) {
|
||||
const auto _value = static_cast<int>(value) + 1;
|
||||
impl->dxDescription.DepthFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
||||
Implementation->Description.DepthFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
||||
}
|
||||
|
||||
void DepthStencilState::StencilEnable(bool value) {
|
||||
impl->dxDescription.StencilEnable = value;
|
||||
Implementation->Description.StencilEnable = value;
|
||||
}
|
||||
|
||||
void DepthStencilState::StencilMask(int value) {
|
||||
impl->dxDescription.StencilReadMask = static_cast<UINT8>(value);
|
||||
Implementation->Description.StencilReadMask = static_cast<UINT8>(value);
|
||||
}
|
||||
|
||||
void DepthStencilState::StencilWriteMask(Int value) {
|
||||
impl->dxDescription.StencilWriteMask = static_cast<UINT8>(value);
|
||||
Implementation->Description.StencilWriteMask = static_cast<UINT8>(value);
|
||||
}
|
||||
|
||||
void DepthStencilState::StencilPass(StencilOperation value) {
|
||||
const auto _value = static_cast<int>(value) + 1;
|
||||
impl->dxDescription.FrontFace.StencilPassOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||
Implementation->Description.FrontFace.StencilPassOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||
}
|
||||
|
||||
void DepthStencilState::StencilFail(StencilOperation value) {
|
||||
const auto _value = static_cast<int>(value) + 1;
|
||||
impl->dxDescription.FrontFace.StencilFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||
Implementation->Description.FrontFace.StencilFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||
}
|
||||
|
||||
void DepthStencilState::StencilDepthBufferFail(StencilOperation value) {
|
||||
const auto _value = static_cast<int>(value) + 1;
|
||||
impl->dxDescription.FrontFace.StencilDepthFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||
Implementation->Description.FrontFace.StencilDepthFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||
}
|
||||
|
||||
void DepthStencilState::StencilFunction(ComparisonFunction value) {
|
||||
const auto _value = static_cast<int>(value) + 1;
|
||||
impl->dxDescription.FrontFace.StencilFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
||||
Implementation->Description.FrontFace.StencilFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
||||
}
|
||||
|
||||
void DepthStencilState::CounterClockwiseStencilPass(StencilOperation value) {
|
||||
const auto _value = static_cast<int>(value) + 1;
|
||||
impl->dxDescription.BackFace.StencilPassOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||
Implementation->Description.BackFace.StencilPassOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||
}
|
||||
|
||||
void DepthStencilState::CounterClockwiseStencilFail(StencilOperation value) {
|
||||
const auto _value = static_cast<int>(value) + 1;
|
||||
impl->dxDescription.BackFace.StencilFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||
Implementation->Description.BackFace.StencilFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||
}
|
||||
|
||||
void DepthStencilState::CounterClockwiseStencilDepthBufferFail(StencilOperation value) {
|
||||
const auto _value = static_cast<int>(value) + 1;
|
||||
impl->dxDescription.BackFace.StencilDepthFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||
Implementation->Description.BackFace.StencilDepthFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||
}
|
||||
|
||||
void DepthStencilState::CounterClockwiseStencilFunction(ComparisonFunction value) {
|
||||
const auto _value = static_cast<int>(value) + 1;
|
||||
impl->dxDescription.BackFace.StencilFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
||||
Implementation->Description.BackFace.StencilFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
||||
}
|
||||
|
||||
bool DepthStencilState::DepthBufferEnable() const {
|
||||
return impl->dxDescription.DepthEnable;
|
||||
return Implementation->Description.DepthEnable;
|
||||
}
|
||||
|
||||
bool DepthStencilState::DepthBufferWriteEnable() const {
|
||||
return static_cast<bool>(impl->dxDescription.DepthWriteMask);
|
||||
return static_cast<bool>(Implementation->Description.DepthWriteMask);
|
||||
}
|
||||
|
||||
ComparisonFunction DepthStencilState::DepthBufferFunction() const {
|
||||
const auto _value = static_cast<int>(impl->dxDescription.DepthFunc) - 1;
|
||||
const auto _value = static_cast<int>(Implementation->Description.DepthFunc) - 1;
|
||||
return static_cast<ComparisonFunction>(_value);
|
||||
}
|
||||
|
||||
bool DepthStencilState::StencilEnable() const {
|
||||
return impl->dxDescription.StencilEnable;
|
||||
return Implementation->Description.StencilEnable;
|
||||
}
|
||||
|
||||
Int DepthStencilState::StencilMask() const {
|
||||
return static_cast<int>(impl->dxDescription.StencilReadMask);
|
||||
return static_cast<int>(Implementation->Description.StencilReadMask);
|
||||
}
|
||||
|
||||
Int DepthStencilState::StencilWriteMask() const {
|
||||
return static_cast<int>(impl->dxDescription.StencilWriteMask);
|
||||
return static_cast<int>(Implementation->Description.StencilWriteMask);
|
||||
}
|
||||
|
||||
StencilOperation DepthStencilState::StencilPass() const {
|
||||
const auto _value = static_cast<int>(impl->dxDescription.FrontFace.StencilPassOp) - 1;
|
||||
const auto _value = static_cast<int>(Implementation->Description.FrontFace.StencilPassOp) - 1;
|
||||
return static_cast<StencilOperation>(_value);
|
||||
}
|
||||
|
||||
StencilOperation DepthStencilState::StencilFail() const {
|
||||
const auto _value = static_cast<int>(impl->dxDescription.FrontFace.StencilFailOp) - 1;
|
||||
const auto _value = static_cast<int>(Implementation->Description.FrontFace.StencilFailOp) - 1;
|
||||
return static_cast<StencilOperation>(_value);
|
||||
}
|
||||
|
||||
StencilOperation DepthStencilState::StencilDepthBufferFail() const {
|
||||
const auto _value = static_cast<int>(impl->dxDescription.FrontFace.StencilDepthFailOp) - 1;
|
||||
const auto _value = static_cast<int>(Implementation->Description.FrontFace.StencilDepthFailOp) - 1;
|
||||
return static_cast<StencilOperation>(_value);
|
||||
}
|
||||
|
||||
ComparisonFunction DepthStencilState::StencilFunction() const {
|
||||
const auto _value = static_cast<int>(impl->dxDescription.FrontFace.StencilFunc) - 1;
|
||||
const auto _value = static_cast<int>(Implementation->Description.FrontFace.StencilFunc) - 1;
|
||||
return static_cast<ComparisonFunction>(_value);
|
||||
}
|
||||
|
||||
StencilOperation DepthStencilState::CounterClockwiseStencilPass() const {
|
||||
const auto _value = static_cast<int>(impl->dxDescription.BackFace.StencilPassOp) - 1;
|
||||
const auto _value = static_cast<int>(Implementation->Description.BackFace.StencilPassOp) - 1;
|
||||
return static_cast<StencilOperation>(_value);
|
||||
}
|
||||
|
||||
StencilOperation DepthStencilState::CounterClockwiseStencilFail() const {
|
||||
const auto _value = static_cast<int>(impl->dxDescription.BackFace.StencilFailOp) - 1;
|
||||
const auto _value = static_cast<int>(Implementation->Description.BackFace.StencilFailOp) - 1;
|
||||
return static_cast<StencilOperation>(_value);
|
||||
}
|
||||
|
||||
StencilOperation DepthStencilState::CounterClockwiseStencilDepthBufferFail() const {
|
||||
const auto _value = static_cast<int>(impl->dxDescription.BackFace.StencilDepthFailOp) - 1;
|
||||
const auto _value = static_cast<int>(Implementation->Description.BackFace.StencilDepthFailOp) - 1;
|
||||
return static_cast<StencilOperation>(_value);
|
||||
}
|
||||
|
||||
ComparisonFunction DepthStencilState::CounterClockwiseStencilFunction() const {
|
||||
const auto _value = static_cast<int>(impl->dxDescription.BackFace.StencilFunc) - 1;
|
||||
const auto _value = static_cast<int>(Implementation->Description.BackFace.StencilFunc) - 1;
|
||||
return static_cast<ComparisonFunction>(_value);
|
||||
}
|
||||
}
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user