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

Implementa Initialize em SamplerState

This commit is contained in:
Danilo 2024-04-13 11:49:03 -03:00
parent c5696273ec
commit 3e026233a0
3 changed files with 26 additions and 0 deletions

View File

@ -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;

View File

@ -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;
}
}

View File

@ -18,6 +18,8 @@ namespace xna {
}
}
virtual bool Initialize(GraphicsDevice& device, xna_error_nullarg) override;
virtual constexpr void Filter(TextureFilter value) override {
switch (value)
{