diff --git a/framework/graphics/samplerstate.hpp b/framework/graphics/samplerstate.hpp index 339cc18..38875da 100644 --- a/framework/graphics/samplerstate.hpp +++ b/framework/graphics/samplerstate.hpp @@ -7,6 +7,7 @@ namespace xna { class ISamplerState { public: virtual ~ISamplerState(){} + virtual bool Initialize(GraphicsDevice& device, xna_error_nullarg) = 0; virtual void Filter(TextureFilter value) = 0; virtual void AddressU(TextureAddressMode value) = 0; virtual void AddressV(TextureAddressMode value) = 0; diff --git a/framework/platform/samplerstate-dx.cpp b/framework/platform/samplerstate-dx.cpp index d3f8891..b223000 100644 --- a/framework/platform/samplerstate-dx.cpp +++ b/framework/platform/samplerstate-dx.cpp @@ -1,4 +1,5 @@ #include "samplerstate-dx.hpp" +#include "device-dx.hpp" namespace xna { PSamplerState ISamplerState::PoinWrap() { @@ -54,4 +55,26 @@ namespace xna { state->_description.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; return state; } + + bool SamplerState::Initialize(GraphicsDevice& device, xna_error_ptr_arg) + { + if (!device._device) { + xna_error_apply(err, XnaErrorCode::ARGUMENT_IS_NULL); + return false; + } + + if (_samplerState) { + _samplerState->Release(); + _samplerState = nullptr; + } + + const auto hr = device._device->CreateSamplerState(&_description, &_samplerState); + + if (FAILED(hr)) { + xna_error_apply(err, XnaErrorCode::FAILED_OPERATION); + return false; + } + + return true; + } } \ No newline at end of file diff --git a/framework/platform/samplerstate-dx.hpp b/framework/platform/samplerstate-dx.hpp index 711674d..c045877 100644 --- a/framework/platform/samplerstate-dx.hpp +++ b/framework/platform/samplerstate-dx.hpp @@ -18,6 +18,8 @@ namespace xna { } } + virtual bool Initialize(GraphicsDevice& device, xna_error_nullarg) override; + virtual constexpr void Filter(TextureFilter value) override { switch (value) {