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

Implementações em DepethStencilState

This commit is contained in:
Danilo 2024-06-23 23:14:06 -03:00
parent 6bd15e797b
commit 5ff4991c30
4 changed files with 109 additions and 71 deletions

View File

@ -18,9 +18,9 @@ namespace xna {
_description.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
_description.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
_description.StencilReadMask = 0;
_description.StencilWriteMask = 0;
_description.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
_description.StencilReadMask = IntMaxValue;
_description.StencilWriteMask = IntMaxValue;
_description.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
return _description;
}
@ -33,11 +33,7 @@ namespace xna {
DepthStencilState::DepthStencilState(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
impl = unew<PlatformImplementation>();
impl->dxDescription = defaultDesc();
}
DepthStencilState::~DepthStencilState() {
impl = nullptr;
}
}
bool DepthStencilState::Initialize()
{
@ -100,24 +96,24 @@ namespace xna {
return stencil;
}
void DepthStencilState::DepthEnabled(bool value) {
void DepthStencilState::DepthBufferEnable(bool value) {
impl->dxDescription.DepthEnable = value;
}
void DepthStencilState::DepthWriteEnabled(bool value) {
void DepthStencilState::DepthBufferWriteEnable(bool value) {
impl->dxDescription.DepthWriteMask = static_cast<D3D11_DEPTH_WRITE_MASK>(value);
}
void DepthStencilState::DepthCompareFunction(ComparisonFunction value) {
void DepthStencilState::DepthBufferFunction(ComparisonFunction value) {
const auto _value = static_cast<int>(value) + 1;
impl->dxDescription.DepthFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
}
void DepthStencilState::StencilEnabled(bool value) {
void DepthStencilState::StencilEnable(bool value) {
impl->dxDescription.StencilEnable = value;
}
void DepthStencilState::StencilReadMask(int value) {
void DepthStencilState::StencilMask(int value) {
impl->dxDescription.StencilReadMask = static_cast<UINT8>(value);
}
@ -125,64 +121,64 @@ namespace xna {
impl->dxDescription.StencilWriteMask = static_cast<UINT8>(value);
}
void DepthStencilState::StencilFrontFacePass(StencilOperation value) {
void DepthStencilState::StencilPass(StencilOperation value) {
const auto _value = static_cast<int>(value) + 1;
impl->dxDescription.FrontFace.StencilPassOp = static_cast<D3D11_STENCIL_OP>(_value);
}
void DepthStencilState::StencilFrontFaceFail(StencilOperation value) {
void DepthStencilState::StencilFail(StencilOperation value) {
const auto _value = static_cast<int>(value) + 1;
impl->dxDescription.FrontFace.StencilFailOp = static_cast<D3D11_STENCIL_OP>(_value);
}
void DepthStencilState::StencilFrontFaceDepthFail(StencilOperation value) {
void DepthStencilState::StencilDepthBufferFail(StencilOperation value) {
const auto _value = static_cast<int>(value) + 1;
impl->dxDescription.FrontFace.StencilDepthFailOp = static_cast<D3D11_STENCIL_OP>(_value);
}
void DepthStencilState::StencilFrontFaceCompare(ComparisonFunction value) {
void DepthStencilState::StencilFunction(ComparisonFunction value) {
const auto _value = static_cast<int>(value) + 1;
impl->dxDescription.FrontFace.StencilFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
}
void DepthStencilState::StencilBackFacePass(StencilOperation value) {
void DepthStencilState::CounterClockwiseStencilPass(StencilOperation value) {
const auto _value = static_cast<int>(value) + 1;
impl->dxDescription.BackFace.StencilPassOp = static_cast<D3D11_STENCIL_OP>(_value);
}
void DepthStencilState::StencilBackFaceFail(StencilOperation value) {
void DepthStencilState::CounterClockwiseStencilFail(StencilOperation value) {
const auto _value = static_cast<int>(value) + 1;
impl->dxDescription.BackFace.StencilFailOp = static_cast<D3D11_STENCIL_OP>(_value);
}
void DepthStencilState::StencilBackFaceDepthFail(StencilOperation value) {
void DepthStencilState::CounterClockwiseStencilDepthBufferFail(StencilOperation value) {
const auto _value = static_cast<int>(value) + 1;
impl->dxDescription.BackFace.StencilDepthFailOp = static_cast<D3D11_STENCIL_OP>(_value);
}
void DepthStencilState::StencilBackFaceCompare(ComparisonFunction value) {
void DepthStencilState::CounterClockwiseStencilFunction(ComparisonFunction value) {
const auto _value = static_cast<int>(value) + 1;
impl->dxDescription.BackFace.StencilFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
}
bool DepthStencilState::DepthEnabled() const {
bool DepthStencilState::DepthBufferEnable() const {
return impl->dxDescription.DepthEnable;
}
bool DepthStencilState::DepthWriteEnabled() const {
bool DepthStencilState::DepthBufferWriteEnable() const {
return static_cast<bool>(impl->dxDescription.DepthWriteMask);
}
ComparisonFunction DepthStencilState::DepthCompareFunction() const {
ComparisonFunction DepthStencilState::DepthBufferFunction() const {
const auto _value = static_cast<int>(impl->dxDescription.DepthFunc) - 1;
return static_cast<ComparisonFunction>(_value);
}
bool DepthStencilState::StencilEnabled() const {
bool DepthStencilState::StencilEnable() const {
return impl->dxDescription.StencilEnable;
}
Int DepthStencilState::StencilReadMask() const {
Int DepthStencilState::StencilMask() const {
return static_cast<int>(impl->dxDescription.StencilReadMask);
}
@ -190,42 +186,42 @@ namespace xna {
return static_cast<int>(impl->dxDescription.StencilWriteMask);
}
StencilOperation DepthStencilState::StencilFrontFacePass() const {
StencilOperation DepthStencilState::StencilPass() const {
const auto _value = static_cast<int>(impl->dxDescription.FrontFace.StencilPassOp) - 1;
return static_cast<StencilOperation>(_value);
}
StencilOperation DepthStencilState::StencilFrontFaceFail() const {
StencilOperation DepthStencilState::StencilFail() const {
const auto _value = static_cast<int>(impl->dxDescription.FrontFace.StencilFailOp) - 1;
return static_cast<StencilOperation>(_value);
}
StencilOperation DepthStencilState::StencilFrontFaceDepthFail() const {
StencilOperation DepthStencilState::StencilDepthBufferFail() const {
const auto _value = static_cast<int>(impl->dxDescription.FrontFace.StencilDepthFailOp) - 1;
return static_cast<StencilOperation>(_value);
}
ComparisonFunction DepthStencilState::StencilFrontFaceCompare() const {
ComparisonFunction DepthStencilState::StencilFunction() const {
const auto _value = static_cast<int>(impl->dxDescription.FrontFace.StencilFunc) - 1;
return static_cast<ComparisonFunction>(_value);
}
StencilOperation DepthStencilState::StencilBackFacePass() const {
StencilOperation DepthStencilState::CounterClockwiseStencilPass() const {
const auto _value = static_cast<int>(impl->dxDescription.BackFace.StencilPassOp) - 1;
return static_cast<StencilOperation>(_value);
}
StencilOperation DepthStencilState::StencilBackFaceFail() const {
StencilOperation DepthStencilState::CounterClockwiseStencilFail() const {
const auto _value = static_cast<int>(impl->dxDescription.BackFace.StencilFailOp) - 1;
return static_cast<StencilOperation>(_value);
}
StencilOperation DepthStencilState::StencilBackFaceDepthFail() const {
StencilOperation DepthStencilState::CounterClockwiseStencilDepthBufferFail() const {
const auto _value = static_cast<int>(impl->dxDescription.BackFace.StencilDepthFailOp) - 1;
return static_cast<StencilOperation>(_value);
}
ComparisonFunction DepthStencilState::StencilBackFaceCompare() const {
ComparisonFunction DepthStencilState::CounterClockwiseStencilFunction() const {
const auto _value = static_cast<int>(impl->dxDescription.BackFace.StencilFunc) - 1;
return static_cast<ComparisonFunction>(_value);
}

View File

@ -139,6 +139,8 @@ namespace xna {
GreaterEqual,
Always
};
using CompareFunction = ComparisonFunction;
enum class CurveContinuity {
Smooth,

View File

@ -26,12 +26,13 @@ namespace xna {
//Retrieves a value used to identify the manufacturer.
Uint VendorId() const;
//Returns a collection of supported display modes for the current adapter.
uptr<DisplayModeCollection> SupportedDisplayModes() const;
//Returns a collection of supported display modes for the current adapter.
uptr<DisplayModeCollection> SupportedDisplayModes(SurfaceFormat surfaceFormat) const;
//Gets the current display mode.
sptr<DisplayMode> CurrentDisplayMode();
//Gets the current display mode.
void CurrentDisplayMode(SurfaceFormat surfaceFormat, Uint width, Uint height);

View File

@ -5,49 +5,88 @@
#include "gresource.hpp"
namespace xna {
//Contains depth-stencil state for the device.
class DepthStencilState : public GraphicsResource {
public:
DepthStencilState();
DepthStencilState(sptr<GraphicsDevice> const& device);
//Gets or sets the stencil operation to perform if the stencil test passes and the depth-buffer test fails for a counterclockwise triangle.
//The default is StencilOperation.Keep.
void CounterClockwiseStencilDepthBufferFail(StencilOperation value);
//Gets or sets the stencil operation to perform if the stencil test passes and the depth-buffer test fails for a counterclockwise triangle.
//The default is StencilOperation.Keep.
StencilOperation CounterClockwiseStencilDepthBufferFail() const;
//Gets or sets the stencil operation to perform if the stencil test fails for a counterclockwise triangle.
//The default is StencilOperation.Keep.
void CounterClockwiseStencilFail(StencilOperation value);
//Gets or sets the stencil operation to perform if the stencil test fails for a counterclockwise triangle.
//The default is StencilOperation.Keep.
StencilOperation CounterClockwiseStencilFail() const;
//Gets or sets the comparison function to use for counterclockwise stencil tests. The default is CompareFunction.Always.
void CounterClockwiseStencilFunction(CompareFunction value);
//Gets or sets the comparison function to use for counterclockwise stencil tests. The default is CompareFunction.Always.
CompareFunction CounterClockwiseStencilFunction() const;
//Gets or sets the stencil operation to perform if the stencil and depth-tests pass for a counterclockwise triangle.
//The default is StencilOperation.Keep.
void CounterClockwiseStencilPass(StencilOperation value);
//Gets or sets the stencil operation to perform if the stencil and depth-tests pass for a counterclockwise triangle.
//The default is StencilOperation.Keep.
StencilOperation CounterClockwiseStencilPass() const;
//Enables or disables depth buffering. The default is true.
void DepthBufferEnable(bool value);
//Enables or disables depth buffering. The default is true.
bool DepthBufferEnable() const;
//Enables or disables writing to the depth buffer. The default is true.
void DepthBufferWriteEnable(bool value);
//Enables or disables writing to the depth buffer. The default is true.
bool DepthBufferWriteEnable() const;
//Gets or sets the comparison function for the depth-buffer test. The default is CompareFunction.LessEqual
void DepthBufferFunction(CompareFunction value);
//Gets or sets the comparison function for the depth-buffer test. The default is CompareFunction.LessEqual
CompareFunction DepthBufferFunction() const;
//Gets or sets stencil enabling. The default is false.
void StencilEnable(bool value);
//Gets or sets stencil enabling. The default is false.
bool StencilEnable() const;
//Gets or sets the stencil operation to perform if the stencil test fails. The default is StencilOperation.Keep.
void StencilFail(StencilOperation value);
//Gets or sets the stencil operation to perform if the stencil test fails. The default is StencilOperation.Keep.
StencilOperation StencilFail() const;
//Gets or sets the comparison function for the stencil test.The default is CompareFunction.Always.
void StencilFunction(CompareFunction value);
//Gets or sets the comparison function for the stencil test. The default is CompareFunction.Always.
CompareFunction StencilFunction() const;
//Gets or sets the mask applied to the reference value and each stencil buffer entry to determine the significant bits for the stencil test.
//The default mask is Int32.MaxValue.
void StencilMask(Int value);
//Gets or sets the mask applied to the reference value and each stencil buffer entry to determine the significant bits for the stencil test.
//The default mask is Int32.MaxValue.
Int StencilMask() const;
//Gets or sets the write mask applied to values written into the stencil buffer. The default mask is Int32.MaxValue.
void StencilWriteMask(Int value);
//Gets or sets the write mask applied to values written into the stencil buffer. The default mask is Int32.MaxValue.
Int StencilWriteMask() const;
//Gets or sets the stencil operation to perform if the stencil test passes. The default is StencilOperation.Keep.
void StencilPass(StencilOperation value);
//Gets or sets the stencil operation to perform if the stencil test passes. The default is StencilOperation.Keep.
StencilOperation StencilPass() const;
//Gets or sets the stencil operation to perform if the stencil test passes and the depth-test fails. The default is StencilOperation.Keep.
void StencilDepthBufferFail(StencilOperation value);
//Gets or sets the stencil operation to perform if the stencil test passes and the depth-test fails. The default is StencilOperation.Keep.
StencilOperation StencilDepthBufferFail() const;
//A built-in state object with settings for not using a depth stencil buffer.
static uptr<DepthStencilState> None();
//A built-in state object with default settings for using a depth stencil buffer.
static uptr<DepthStencilState> Default();
//A built-in state object with settings for enabling a read-only depth stencil buffer.
static uptr<DepthStencilState> DepthRead();
~DepthStencilState() override;
bool Initialize();
bool Apply();
void DepthEnabled(bool value);
void DepthWriteEnabled(bool value);
void DepthCompareFunction(ComparisonFunction value);
void StencilEnabled(bool value);
void StencilReadMask(Int value);
void StencilWriteMask(Int value);
void StencilFrontFacePass(StencilOperation value);
void StencilFrontFaceFail(StencilOperation value);
void StencilFrontFaceDepthFail(StencilOperation value);
void StencilFrontFaceCompare(ComparisonFunction value);
void StencilBackFacePass(StencilOperation value);
void StencilBackFaceFail(StencilOperation value);
void StencilBackFaceDepthFail(StencilOperation value);
void StencilBackFaceCompare(ComparisonFunction value);
bool DepthEnabled() const;
bool DepthWriteEnabled() const;
ComparisonFunction DepthCompareFunction() const;
bool StencilEnabled() const;
Int StencilReadMask() const;
Int StencilWriteMask() const;
StencilOperation StencilFrontFacePass() const;
StencilOperation StencilFrontFaceFail() const;
StencilOperation StencilFrontFaceDepthFail() const;
ComparisonFunction StencilFrontFaceCompare() const;
StencilOperation StencilBackFacePass() const;
StencilOperation StencilBackFaceFail() const;
StencilOperation StencilBackFaceDepthFail() const;
ComparisonFunction StencilBackFaceCompare() const;
static uptr<DepthStencilState> None();
static uptr<DepthStencilState> Default();
static uptr<DepthStencilState> DepthRead();
public:
struct PlatformImplementation;