---------------------------------------------------------------------
| 1642 | } |
| 1643 | //--------------------------------------------------------------------- |
| 1644 | void D3D9RenderSystem::_setTexture( size_t stage, bool enabled, const TexturePtr& tex ) |
| 1645 | { |
| 1646 | HRESULT hr; |
| 1647 | D3D9TexturePtr dt = static_pointer_cast<D3D9Texture>(tex); |
| 1648 | auto hasVTF = mCurrentCapabilities->hasCapability(RSC_VERTEX_TEXTURE_FETCH); |
| 1649 | if (enabled && dt) |
| 1650 | { |
| 1651 | // note used |
| 1652 | dt->touch(); |
| 1653 | |
| 1654 | IDirect3DBaseTexture9 *pTex = dt->getTexture(); |
| 1655 | if (mTexStageDesc[stage].pTex != pTex) |
| 1656 | { |
| 1657 | hr = getActiveD3D9Device()->SetTexture(static_cast<DWORD>(stage), pTex); |
| 1658 | if( hr != S_OK ) |
| 1659 | { |
| 1660 | String str = "Unable to set texture '" + tex->getName() + "' in D3D9"; |
| 1661 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, str, "D3D9RenderSystem::_setTexture" ); |
| 1662 | } |
| 1663 | |
| 1664 | // set stage desc. |
| 1665 | mTexStageDesc[stage].pTex = pTex; |
| 1666 | mTexStageDesc[stage].texType = D3D9Mappings::get(dt->getTextureType()); |
| 1667 | |
| 1668 | // Set gamma now too |
| 1669 | if (dt->isHardwareGammaReadToBeUsed()) |
| 1670 | { |
| 1671 | __SetSamplerState(getSamplerId(stage), D3DSAMP_SRGBTEXTURE, TRUE); |
| 1672 | } |
| 1673 | else |
| 1674 | { |
| 1675 | __SetSamplerState(getSamplerId(stage), D3DSAMP_SRGBTEXTURE, FALSE); |
| 1676 | } |
| 1677 | |
| 1678 | if (hasVTF && stage < 4) |
| 1679 | { |
| 1680 | HRESULT hr = getActiveD3D9Device()->SetTexture(D3DVERTEXTEXTURESAMPLER0 + static_cast<DWORD>(stage), pTex); |
| 1681 | if( hr != S_OK ) |
| 1682 | { |
| 1683 | String str = "Unable to set vertex texture '" + tex->getName() + "' in D3D9"; |
| 1684 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, str); |
| 1685 | } |
| 1686 | } |
| 1687 | |
| 1688 | } |
| 1689 | } |
| 1690 | else |
| 1691 | { |
| 1692 | if (mTexStageDesc[stage].pTex != 0) |
| 1693 | { |
| 1694 | hr = getActiveD3D9Device()->SetTexture(static_cast<DWORD>(stage), 0); |
| 1695 | if( hr != S_OK ) |
| 1696 | { |
| 1697 | String str = "Unable to disable texture '" + StringConverter::toString(stage) + "' in D3D9"; |
| 1698 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, str, "D3D9RenderSystem::_setTexture" ); |
| 1699 | } |
| 1700 | |
| 1701 | if (hasVTF && stage < 4) |
nothing calls this directly
no test coverage detected