diff --git a/framework/platform-dx/displaymode.cpp b/framework/platform-dx/displaymode.cpp index f959848..d749fc6 100644 --- a/framework/platform-dx/displaymode.cpp +++ b/framework/platform-dx/displaymode.cpp @@ -4,11 +4,7 @@ namespace xna { DisplayMode::DisplayMode() { impl = unew(); - } - - DisplayMode::~DisplayMode() { - impl = nullptr; - } + } size_t DisplayModeCollection::SurfaceCount(SurfaceFormat format) const { diff --git a/framework/platform-dx/rasterizerstate.cpp b/framework/platform-dx/rasterizerstate.cpp index 3e400c0..c9634a8 100644 --- a/framework/platform-dx/rasterizerstate.cpp +++ b/framework/platform-dx/rasterizerstate.cpp @@ -3,18 +3,18 @@ namespace xna { - RasterizerState::RasterizerState() : GraphicsResource(nullptr){ - impl = unew(); - } + RasterizerState::RasterizerState() : RasterizerState(nullptr){} RasterizerState::RasterizerState(sptr const& device) : GraphicsResource(device) { impl = unew(); + impl->dxDescription.CullMode = D3D11_CULL_MODE::D3D11_CULL_BACK; + impl->dxDescription.FillMode = D3D11_FILL_MODE::D3D11_FILL_SOLID; + impl->dxDescription.MultisampleEnable = true; + impl->dxDescription.DepthBias = 0; + impl->dxDescription.SlopeScaledDepthBias = 0; + impl->dxDescription.ScissorEnable = false; } - - RasterizerState::~RasterizerState() { - impl = nullptr; - } - + bool RasterizerState::Initialize() { if (!impl || !m_device || !m_device->impl->_device) { @@ -52,6 +52,38 @@ namespace xna { return true; } + bool RasterizerState::ScissorTestEnable() const { + return impl->dxDescription.ScissorEnable; + } + + void RasterizerState::ScissorTestEnable(bool value) { + impl->dxDescription.ScissorEnable = value; + } + + bool RasterizerState::MultiSampleAntiAlias() const { + return impl->dxDescription.MultisampleEnable; + } + + void RasterizerState::MultiSampleAntiAlias(bool value) { + impl->dxDescription.MultisampleEnable = value; + } + + float RasterizerState::DepthBias() const { + return impl->dxDescription.DepthBias; + } + + void RasterizerState::DepthBias(float value) { + impl->dxDescription.DepthBias = value; + } + + float RasterizerState::SlopeScaleDepthBias() const { + return impl->dxDescription.SlopeScaledDepthBias; + } + + void RasterizerState::SlopeScaleDepthBias(float value) { + impl->dxDescription.SlopeScaledDepthBias = value; + } + uptr RasterizerState::CullNone() { auto raster = unew(); diff --git a/framework/platform-dx/samplerstate.cpp b/framework/platform-dx/samplerstate.cpp index 1d0cd43..2a8e8d1 100644 --- a/framework/platform-dx/samplerstate.cpp +++ b/framework/platform-dx/samplerstate.cpp @@ -3,18 +3,12 @@ #include "xna/platform-dx/dx.hpp" namespace xna { - SamplerState::SamplerState() : GraphicsResource(nullptr) { - impl = unew(); - } + SamplerState::SamplerState() : SamplerState(nullptr){} SamplerState::SamplerState(sptr const& device) : GraphicsResource(device) { impl = unew(); } - SamplerState::~SamplerState() { - impl = nullptr; - } - bool SamplerState::Initialize() { if (!impl || !m_device || !m_device->impl->_device) { @@ -156,15 +150,15 @@ namespace xna { impl->_description.ComparisonFunc = static_cast(static_cast(value) + 1); } - void SamplerState::MipLODBias(float value) { + void SamplerState::MipMapLevelOfDetailBias(float value) { impl->_description.MipLODBias = value; } - void SamplerState::MinLOD(float value) { + void SamplerState::MinMipLevel(float value) { impl->_description.MinLOD = value; } - void SamplerState::MaxLOD(float value) { + void SamplerState::MaxMipLevel (float value) { impl->_description.MaxLOD = value; } @@ -220,15 +214,15 @@ namespace xna { return static_cast(impl->_description.ComparisonFunc - 1); } - float SamplerState::MipLODBias() const { + float SamplerState::MipMapLevelOfDetailBias() const { return impl->_description.MipLODBias; } - float SamplerState::MinLOD() const { + float SamplerState::MinMipLevel() const { return impl->_description.MinLOD; } - float SamplerState::MaxLOD() const { + float SamplerState::MaxMipLevel() const { return impl->_description.MaxLOD; } diff --git a/inc/xna/graphics/displaymode.hpp b/inc/xna/graphics/displaymode.hpp index 38540de..8861a7f 100644 --- a/inc/xna/graphics/displaymode.hpp +++ b/inc/xna/graphics/displaymode.hpp @@ -6,11 +6,12 @@ namespace xna { struct DisplayModeDescription; + //Describes the display mode. class DisplayMode { public: - DisplayMode(); - ~DisplayMode(); + DisplayMode(); + //Gets the aspect ratio used by the graphics device. constexpr float AspectRatio() const { if (Height == 0 || Width == 0) return 0; @@ -25,8 +26,11 @@ namespace xna { } public: + //Gets a value indicating the screen width, in pixels. Int Width{ 0 }; + //Gets a value indicating the screen height, in pixels. Int Height{ 0 }; + //Gets a value indicating the surface format of the display mode. SurfaceFormat Format{ SurfaceFormat::Color }; public: @@ -34,6 +38,7 @@ namespace xna { uptr impl; }; + //Manipulates a collection of DisplayMode structures. class DisplayModeCollection { public: constexpr DisplayModeCollection() = default; diff --git a/inc/xna/graphics/rasterizerstate.hpp b/inc/xna/graphics/rasterizerstate.hpp index 3c8ff40..bbf79e4 100644 --- a/inc/xna/graphics/rasterizerstate.hpp +++ b/inc/xna/graphics/rasterizerstate.hpp @@ -5,22 +5,55 @@ #include "gresource.hpp" namespace xna { + //Contains rasterizer state, which determines how to convert vector data (shapes) into raster data (pixels). class RasterizerState : GraphicsResource { public: RasterizerState(); RasterizerState(sptr const& device); - ~RasterizerState() override; - bool Initialize(); - bool Apply(); + + //Specifies the conditions for culling or removing triangles. The default value is CullMode.CounterClockwise. xna::CullMode CullMode() const; + //Specifies the conditions for culling or removing triangles. The default value is CullMode.CounterClockwise. void CullMode(xna::CullMode value); + //The fill mode, which defines how a triangle is filled during rendering. The default is FillMode.Solid. xna::FillMode FillMode() const; + //The fill mode, which defines how a triangle is filled during rendering. The default is FillMode.Solid. void FillMode(xna::FillMode value); + //Enables or disables multisample antialiasing. The default is true. + bool MultiSampleAntiAlias() const; + //Enables or disables multisample antialiasing. The default is true. + void MultiSampleAntiAlias(bool value); + + //Sets or retrieves the depth bias for polygons, which is the amount of bias to apply to the depth of a primitive + //to alleviate depth testing problems for primitives of similar depth. The default value is 0. + float DepthBias() const; + //Sets or retrieves the depth bias for polygons, which is the amount of bias to apply to the depth of a primitive + //to alleviate depth testing problems for primitives of similar depth. The default value is 0. + void DepthBias(float value); + + //Gets or sets a bias value that takes into account the slope of a polygon. This bias value is applied to coplanar primitives + // to reduce aliasing and other rendering artifacts caused by z-fighting. The default is 0. + float SlopeScaleDepthBias() const; + //Gets or sets a bias value that takes into account the slope of a polygon. This bias value is applied to coplanar primitives + // to reduce aliasing and other rendering artifacts caused by z-fighting. The default is 0. + void SlopeScaleDepthBias(float value); + + //Enables or disables scissor testing. The default is false. + bool ScissorTestEnable() const; + //Enables or disables scissor testing. The default is false. + void ScissorTestEnable(bool value); + + //A built-in state object with settings for not culling any primitives. static uptr CullNone(); + //A built-in state object with settings for culling primitives with clockwise winding order. static uptr CullClockwise(); + //A built-in state object with settings for culling primitives with counter-clockwise winding order. static uptr CullCounterClockwise(); + bool Initialize(); + bool Apply(); + public: struct PlatformImplementation; uptr impl = nullptr; diff --git a/inc/xna/graphics/samplerstate.hpp b/inc/xna/graphics/samplerstate.hpp index 59ae1a4..75f1303 100644 --- a/inc/xna/graphics/samplerstate.hpp +++ b/inc/xna/graphics/samplerstate.hpp @@ -5,38 +5,66 @@ #include "gresource.hpp" namespace xna { + //Contains sampler state, which determines how to sample texture data. class SamplerState : GraphicsResource { public: SamplerState(); SamplerState(sptr const& device); - ~SamplerState() override; + + //Gets or sets the maximum anisotropy. The default value is 0. + void MaxAnisotropy(Uint value); + //Gets or sets the maximum anisotropy. The default value is 0. + Uint MaxAnisotropy() const; + //Gets or sets the type of filtering during sampling. + void Filter(TextureFilter value); + //Gets or sets the type of filtering during sampling. + TextureFilter Filter() const; + ////Gets or sets the texture-address mode for the u-coordinate. + void AddressU(TextureAddressMode value); + //Gets or sets the texture-address mode for the u-coordinate. + TextureAddressMode AddressU() const; + //Gets or sets the texture-address mode for the v-coordinate. + TextureAddressMode AddressV() const; + //Gets or sets the texture-address mode for the v-coordinate. + void AddressV(TextureAddressMode value); + //Gets or sets the texture-address mode for the w-coordinate. + TextureAddressMode AddressW() const; + ////Gets or sets the texture-address mode for the w-coordinate. + void AddressW(TextureAddressMode value); + + //Gets or sets the mipmap LOD bias. The default value is 0. + void MipMapLevelOfDetailBias(float value); + //Gets or sets the mipmap LOD bias. The default value is 0. + float MipMapLevelOfDetailBias() const; + + //Gets or sets the level of detail (LOD) index of the largest map to use. + float MaxMipLevel() const; + //Gets or sets the level of detail (LOD) index of the largest map to use. + void MaxMipLevel(float value); + + //Gets or sets the level of detail (LOD) index of the smaller map to use. + void MinMipLevel(float value); + //Gets or sets the level of detail (LOD) index of the smaller map to use. + float MinMipLevel() const; + + //Contains default state for point filtering and texture coordinate wrapping. + static uptr PoinWrap(); + //Contains default state for point filtering and texture coordinate clamping. + static uptr PointClamp(); + //Contains default state for linear filtering and texture coordinate wrapping. + static uptr LinearWrap(); + //Contains default state for linear filtering and texture coordinate clamping. + static uptr LinearClamp(); + //Contains default state for anisotropic filtering and texture coordinate wrapping. + static uptr AnisotropicWrap(); + //Contains default state for anisotropic filtering and texture coordinate clamping. + static uptr AnisotropicClamp(); + + ComparisonFunction Comparison() const; + void Comparison(ComparisonFunction value); + bool Initialize(); bool Apply(); - void Filter(TextureFilter value); - void AddressU(TextureAddressMode value); - void AddressV(TextureAddressMode value); - void AddressW(TextureAddressMode value); - void Comparison(ComparisonFunction value); - void MipLODBias(float value); - void MinLOD(float value); - void MaxLOD(float value); - void MaxAnisotropy(Uint value); - TextureFilter Filter() const; - TextureAddressMode AddressU() const; - TextureAddressMode AddressV() const; - TextureAddressMode AddressW() const; - ComparisonFunction Comparison() const; - float MipLODBias() const; - float MinLOD() const; - float MaxLOD() const; - Uint MaxAnisotropy() const; - - static uptr PoinWrap(); - static uptr PointClamp(); - static uptr LinearWrap(); - static uptr LinearClamp(); - static uptr AnisotropicWrap(); - static uptr AnisotropicClamp(); public: struct PlatformImplementation;