void EffectSystemD3D11::ApplySampler(int effectID, const char *samplerName, int samplerID, int slot) { ASSERT_EFFECT(effectID); ID3DX11EffectSamplerVariable *variable = mEffects[effectID]->GetVariableByName(samplerName)->AsSampler(); ID3D11SamplerState *sampler = mSamplers[samplerID]; variable->SetSampler(slot, sampler); }
void EndOfDirectX11::Render() { if( d3dContext_ == 0 ) { return; } float clearColor[] = { 0.0f, 0.0f, 0.25f, 1.0f }; d3dContext_->ClearRenderTargetView( backBufferTarget_, clearColor ); d3dContext_->ClearDepthStencilView( depthStencilView_, D3D11_CLEAR_DEPTH, 1.0f, 0 ); unsigned int stride = sizeof( VertexPos ); unsigned int offset = 0; d3dContext_->IASetInputLayout( inputLayout_ ); d3dContext_->IASetVertexBuffers( 0, 1, &vertexBuffer_, &stride, &offset ); d3dContext_->IASetIndexBuffer( indexBuffer_, DXGI_FORMAT_R16_UINT, 0 ); d3dContext_->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ); ID3DX11EffectShaderResourceVariable * colorMap = 0; colorMap = effect_->GetVariableByName( "colorMap" )->AsShaderResource(); colorMap->SetResource( colorMap_ ); ID3DX11EffectShaderResourceVariable* colorMap2; colorMap2 = effect_->GetVariableByName( "secondMap" )->AsShaderResource( ); colorMap2->SetResource( secondMap_ ); ID3DX11EffectSamplerVariable * samplerState = 0; samplerState = effect_->GetVariableByName( "colorSampler" )->AsSampler(); samplerState->SetSampler( 0, samplerState_ ); ID3DX11EffectMatrixVariable * worldMatrix = 0; worldMatrix = effect_->GetVariableByName( "worldMatrix" )->AsMatrix(); worldMatrix->SetMatrix( ( float * )&worldMat_ ); ID3DX11EffectMatrixVariable * viewMatrix = 0; viewMatrix = effect_->GetVariableByName( "viewMatrix" )->AsMatrix(); viewMatrix->SetMatrix( ( float * )&viewMatrix_ ); ID3DX11EffectMatrixVariable * projMatrix = 0; projMatrix = effect_->GetVariableByName( "projMatrix" )->AsMatrix(); projMatrix->SetMatrix( ( float * )&projMatrix_ ); ID3DX11EffectTechnique * colorInvTechnique = 0; colorInvTechnique = effect_->GetTechniqueByName( "MultiTexture" ); D3DX11_TECHNIQUE_DESC techDesc; colorInvTechnique->GetDesc( &techDesc ); for( unsigned int p = 0; p < techDesc.Passes; ++p ) { ID3DX11EffectPass * pass = colorInvTechnique->GetPassByIndex( p ); if( pass != 0 ) { pass->Apply( 0, d3dContext_ ); d3dContext_->DrawIndexed( 36, 0, 0 ); } } swapChain_->Present( 0, 0 ); }