diff --git a/framework/platform-dx/samplerstate.cpp b/framework/platform-dx/samplerstate.cpp index 2a8e8d1..fa2af6d 100644 --- a/framework/platform-dx/samplerstate.cpp +++ b/framework/platform-dx/samplerstate.cpp @@ -45,6 +45,35 @@ namespace xna { return true; } + + void SamplerStateCollection::Apply(GraphicsDevice const& device) { + if (samplers.empty()) + return; + + if (!device.impl || !device.impl->_device || !device.impl->_context) { + Exception::Throw(ExMessage::InvalidOperation); + } + + std::vector states(samplers.size()); + + for (size_t i = 0; i < samplers.size(); ++i) { + const auto& current = samplers[0]; + + if (!current || !current->impl || !current->impl->_samplerState) + Exception::Throw(ExMessage::InvalidOperation); + + states[i] = current->impl->_samplerState; + states[i]->AddRef(); + } + + device.impl->_context->PSSetSamplers(0, states.size(), states.data()); + + for (size_t i = 0; i < samplers.size(); ++i) { + states[i]->Release(); + states[i] = nullptr; + } + } + uptr SamplerState::PoinWrap() { auto state = unew(); state->impl->_description.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; diff --git a/inc/xna/graphics/samplerstate.hpp b/inc/xna/graphics/samplerstate.hpp index 7a4aed6..51c6a1f 100644 --- a/inc/xna/graphics/samplerstate.hpp +++ b/inc/xna/graphics/samplerstate.hpp @@ -91,6 +91,8 @@ namespace xna { return samplers[index]; } + void Apply(GraphicsDevice const& device); + public: std::vector samplers; }; diff --git a/inc/xna/platform-dx/dx.hpp b/inc/xna/platform-dx/dx.hpp index ce86e07..fba5fad 100644 --- a/inc/xna/platform-dx/dx.hpp +++ b/inc/xna/platform-dx/dx.hpp @@ -966,6 +966,8 @@ namespace xna { _depthStencilState->Bind(device); _depthStencilState->Initialize(); _depthStencilState->Apply(); + + _samplerStates->Apply(*device); } public: