| 1725 | } |
| 1726 | } |
| 1727 | void D3D9RenderSystem::_setSampler(size_t unit, Sampler& sampler) |
| 1728 | { |
| 1729 | const Sampler::UVWAddressingMode& uvw = sampler.getAddressingMode(); |
| 1730 | HRESULT hr; |
| 1731 | DWORD samplerId = getSamplerId(unit); |
| 1732 | const D3DCAPS9& caps = mDeviceManager->getActiveDevice()->getD3D9DeviceCaps(); |
| 1733 | if( FAILED( hr = __SetSamplerState( samplerId, D3DSAMP_ADDRESSU, D3D9Mappings::get(uvw.u, caps) ) ) ) |
| 1734 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set texture addressing mode for U", "D3D9RenderSystem::_setSampler" ); |
| 1735 | if( FAILED( hr = __SetSamplerState( samplerId, D3DSAMP_ADDRESSV, D3D9Mappings::get(uvw.v, caps) ) ) ) |
| 1736 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set texture addressing mode for V", "D3D9RenderSystem::_setSampler" ); |
| 1737 | if( FAILED( hr = __SetSamplerState( samplerId, D3DSAMP_ADDRESSW, D3D9Mappings::get(uvw.w, caps) ) ) ) |
| 1738 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set texture addressing mode for W", "D3D9RenderSystem::_setSampler" ); |
| 1739 | if( FAILED( hr = __SetSamplerState( samplerId, D3DSAMP_BORDERCOLOR, sampler.getBorderColour().getAsARGB()) ) ) |
| 1740 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set texture border colour", "D3D9RenderSystem::_setSampler" ); |
| 1741 | |
| 1742 | __SetSamplerState( samplerId, D3DSAMP_MAXANISOTROPY, std::min<uint>(caps.MaxAnisotropy, sampler.getAnisotropy()) ); |
| 1743 | |
| 1744 | if (mCurrentCapabilities->hasCapability(RSC_MIPMAP_LOD_BIAS)) |
| 1745 | { |
| 1746 | // ugh - have to pass float data through DWORD with no conversion |
| 1747 | float mipBias = sampler.getMipmapBias(); |
| 1748 | hr = __SetSamplerState(samplerId, D3DSAMP_MIPMAPLODBIAS, *(DWORD*)&mipBias); |
| 1749 | if (FAILED(hr)) |
| 1750 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to set texture mipmap bias", |
| 1751 | "D3D9RenderSystem::_setSampler"); |
| 1752 | } |
| 1753 | |
| 1754 | D3D9Mappings::eD3DTexType texType = mTexStageDesc[unit].texType; |
| 1755 | hr = __SetSamplerState(samplerId, D3D9Mappings::get(FT_MIN), |
| 1756 | D3D9Mappings::get(FT_MIN, sampler.getFiltering(FT_MIN), caps, texType)); |
| 1757 | if (FAILED(hr)) |
| 1758 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set texture filter ", "D3D9RenderSystem::_setSampler"); |
| 1759 | hr = __SetSamplerState(samplerId, D3D9Mappings::get(FT_MAG), |
| 1760 | D3D9Mappings::get(FT_MAG, sampler.getFiltering(FT_MAG), caps, texType)); |
| 1761 | if (FAILED(hr)) |
| 1762 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set texture filter ", "D3D9RenderSystem::_setSampler"); |
| 1763 | hr = __SetSamplerState(samplerId, D3D9Mappings::get(FT_MIP), |
| 1764 | D3D9Mappings::get(FT_MIP, sampler.getFiltering(FT_MIP), caps, texType)); |
| 1765 | if (FAILED(hr)) |
| 1766 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set texture filter ", "D3D9RenderSystem::_setSampler"); |
| 1767 | } |
| 1768 | //--------------------------------------------------------------------- |
| 1769 | void D3D9RenderSystem::_setTextureCoordSet( size_t stage, size_t index ) |
| 1770 | { |
nothing calls this directly
no test coverage detected