mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementações em Sampler e RasterizerState
This commit is contained in:
parent
5ff4991c30
commit
5d46b4246f
@ -4,11 +4,7 @@
|
||||
namespace xna {
|
||||
DisplayMode::DisplayMode() {
|
||||
impl = unew<PlatformImplementation>();
|
||||
}
|
||||
|
||||
DisplayMode::~DisplayMode() {
|
||||
impl = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
size_t DisplayModeCollection::SurfaceCount(SurfaceFormat format) const
|
||||
{
|
||||
|
@ -3,18 +3,18 @@
|
||||
|
||||
namespace xna {
|
||||
|
||||
RasterizerState::RasterizerState() : GraphicsResource(nullptr){
|
||||
impl = unew<PlatformImplementation>();
|
||||
}
|
||||
RasterizerState::RasterizerState() : RasterizerState(nullptr){}
|
||||
|
||||
RasterizerState::RasterizerState(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
||||
impl = unew<PlatformImplementation>();
|
||||
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> RasterizerState::CullNone()
|
||||
{
|
||||
auto raster = unew<RasterizerState>();
|
||||
|
@ -3,18 +3,12 @@
|
||||
#include "xna/platform-dx/dx.hpp"
|
||||
|
||||
namespace xna {
|
||||
SamplerState::SamplerState() : GraphicsResource(nullptr) {
|
||||
impl = unew<PlatformImplementation>();
|
||||
}
|
||||
SamplerState::SamplerState() : SamplerState(nullptr){}
|
||||
|
||||
SamplerState::SamplerState(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
||||
impl = unew<PlatformImplementation>();
|
||||
}
|
||||
|
||||
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<D3D11_COMPARISON_FUNC>(static_cast<int>(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<ComparisonFunction>(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;
|
||||
}
|
||||
|
||||
|
@ -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<PlatformImplementation> impl;
|
||||
};
|
||||
|
||||
//Manipulates a collection of DisplayMode structures.
|
||||
class DisplayModeCollection {
|
||||
public:
|
||||
constexpr DisplayModeCollection() = default;
|
||||
|
@ -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<GraphicsDevice> 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<RasterizerState> CullNone();
|
||||
//A built-in state object with settings for culling primitives with clockwise winding order.
|
||||
static uptr<RasterizerState> CullClockwise();
|
||||
//A built-in state object with settings for culling primitives with counter-clockwise winding order.
|
||||
static uptr<RasterizerState> CullCounterClockwise();
|
||||
|
||||
bool Initialize();
|
||||
bool Apply();
|
||||
|
||||
public:
|
||||
struct PlatformImplementation;
|
||||
uptr<PlatformImplementation> impl = nullptr;
|
||||
|
@ -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<GraphicsDevice> 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<SamplerState> PoinWrap();
|
||||
//Contains default state for point filtering and texture coordinate clamping.
|
||||
static uptr<SamplerState> PointClamp();
|
||||
//Contains default state for linear filtering and texture coordinate wrapping.
|
||||
static uptr<SamplerState> LinearWrap();
|
||||
//Contains default state for linear filtering and texture coordinate clamping.
|
||||
static uptr<SamplerState> LinearClamp();
|
||||
//Contains default state for anisotropic filtering and texture coordinate wrapping.
|
||||
static uptr<SamplerState> AnisotropicWrap();
|
||||
//Contains default state for anisotropic filtering and texture coordinate clamping.
|
||||
static uptr<SamplerState> 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<SamplerState> PoinWrap();
|
||||
static uptr<SamplerState> PointClamp();
|
||||
static uptr<SamplerState> LinearWrap();
|
||||
static uptr<SamplerState> LinearClamp();
|
||||
static uptr<SamplerState> AnisotropicWrap();
|
||||
static uptr<SamplerState> AnisotropicClamp();
|
||||
|
||||
public:
|
||||
struct PlatformImplementation;
|
||||
|
Loading…
x
Reference in New Issue
Block a user