#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2013 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_GRAPHICS_RASTERIZATION_DEPTHSTENCILOPTIONS_H #define NUCLEX_GRAPHICS_RASTERIZATION_DEPTHSTENCILOPTIONS_H #include "../Config.h" #include "Options.h" #include "ComparisonFunction.h" #include #include namespace Nuclex { namespace Graphics { namespace Rasterization { // ------------------------------------------------------------------------------------------- // /// /// Various options that influence how the depth and stencil buffers are used /// /// /// These options can be represented by hardware-accelerated rasterizer as state blocks, /// meaning that changing one option requires the rasterizer to create a completely new /// state block. Thus, it's most efficient if you can pinpoint a handful of option /// combinations that your game uses, create one of these structures for each and keep /// reusing them. /// class DepthStencilOptions : public Options { /// Initializes a new depth and stencil buffer option set public: NUCLEX_GRAPHICS_API DepthStencilOptions(); /// Frees all resources owned by the instance public: NUCLEX_GRAPHICS_API ~DepthStencilOptions(); /// Whether the depth buffer should be used /// True if the depth buffer should be used public: NUCLEX_GRAPHICS_API bool IsDepthBufferEnabled() const { return this->isDepthBufferEnabled; } /// Enables or disables the depth buffer /// True to use the depth buffer, false to ignore it public: NUCLEX_GRAPHICS_API void EnableDepthBuffer(bool enable = true) { this->isDepthBufferEnabled = enable; OnChanged(); } /// Whether the depth buffer should be written to /// True if the depth buffer should be written to public: NUCLEX_GRAPHICS_API bool IsDepthWriteEnabled() const { return this->isDepthWriteEnabled; } /// Enables or disables writing to the depth buffer /// /// True to enable writing to the depth buffer, false to disable /// public: NUCLEX_GRAPHICS_API void EnableDepthWrite(bool enable = true) { this->isDepthWriteEnabled = enable; OnChanged(); } /// Retrieves the current depth comparison function /// The depth comparison function to use against the depth buffer public: NUCLEX_GRAPHICS_API ComparisonFunction::Enum GetDepthComparisonFunction() const { return this->depthComparisonFunction; } /// Selects the current depth comparison function /// /// Comparison function that will be used against the depth buffer /// public: NUCLEX_GRAPHICS_API void SetDepthComparisonFunction( ComparisonFunction::Enum comparisonFunction ) { this->depthComparisonFunction = comparisonFunction; OnChanged(); } /// Whether the stencil buffer should be used /// True if the stencil buffer should be used public: NUCLEX_GRAPHICS_API bool IsStencilBufferEnabled() const { return this->isStencilBufferEnabled; } /// Enables or disables the stencil buffer /// True to use the stencil buffer, false to ignore it public: NUCLEX_GRAPHICS_API void EnableStencilBuffer(bool enable = true) { this->isStencilBufferEnabled = enable; OnChanged(); } /// Retrieves the bit mask for stencil buffer reads /// The mask to use for stencil buffer reads public: NUCLEX_GRAPHICS_API std::uint8_t GetStencilReadMask() const { return this->stencilReadMask; } /// Selects the bit mask for stencil buffer reads /// Mask to apply to stencil buffer reads public: NUCLEX_GRAPHICS_API void SetStencilReadMask(std::uint8_t mask) { this->stencilReadMask = mask; OnChanged(); } /// Retrieves the bit mask for stencil buffer writes /// The mask to use for stencil buffer writes public: NUCLEX_GRAPHICS_API std::uint8_t GetStencilWriteMask() const { return this->stencilWriteMask; } /// Selects the bit mask for stencil buffer writes /// Mask to apply to stencil buffer writes public: NUCLEX_GRAPHICS_API void SetStencilWriteMask(std::uint8_t mask) { this->stencilWriteMask = mask; OnChanged(); } // TODO: stencil operations for front face // TODO: stencil operation for back face /// Whether depth buffer checks are enabled private: bool isDepthBufferEnabled; /// Whether depth writes are enabled private: bool isDepthWriteEnabled; /// Comparison function that is performed against the depth buffer private: ComparisonFunction::Enum depthComparisonFunction; /// Whether stencil buffer interaction is enabled private: bool isStencilBufferEnabled; /// Bit mask for stencil buffer reads private: std::uint8_t stencilReadMask; /// Bit mask for stencil buffer writes private: std::uint8_t stencilWriteMask; }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Graphics::Rasterization #endif // NUCLEX_GRAPHICS_RASTERIZATION_DEPTHSTENCILOPTIONS_H