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

Implementa método Apply em SamplerStateCollection

This commit is contained in:
Danilo 2024-06-24 20:49:06 -03:00
parent 587960d0f2
commit 513292aae7
3 changed files with 33 additions and 0 deletions

View File

@ -45,6 +45,35 @@ namespace xna {
return true; 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<ID3D11SamplerState*> 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> SamplerState::PoinWrap() { uptr<SamplerState> SamplerState::PoinWrap() {
auto state = unew<SamplerState>(); auto state = unew<SamplerState>();
state->impl->_description.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; state->impl->_description.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;

View File

@ -91,6 +91,8 @@ namespace xna {
return samplers[index]; return samplers[index];
} }
void Apply(GraphicsDevice const& device);
public: public:
std::vector<PSamplerState> samplers; std::vector<PSamplerState> samplers;
}; };

View File

@ -966,6 +966,8 @@ namespace xna {
_depthStencilState->Bind(device); _depthStencilState->Bind(device);
_depthStencilState->Initialize(); _depthStencilState->Initialize();
_depthStencilState->Apply(); _depthStencilState->Apply();
_samplerStates->Apply(*device);
} }
public: public: