---------------------------------------------------------------------
| 2129 | } |
| 2130 | //--------------------------------------------------------------------- |
| 2131 | void D3D9RenderSystem::_setAlphaRejectSettings( CompareFunction func, unsigned char value, bool alphaToCoverage ) |
| 2132 | { |
| 2133 | HRESULT hr; |
| 2134 | bool a2c = false; |
| 2135 | static bool lasta2c = false; |
| 2136 | |
| 2137 | if (func != CMPF_ALWAYS_PASS) |
| 2138 | { |
| 2139 | if( FAILED( hr = __SetRenderState( D3DRS_ALPHATESTENABLE, TRUE ) ) ) |
| 2140 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to enable alpha testing", |
| 2141 | "D3D9RenderSystem::_setAlphaRejectSettings" ); |
| 2142 | |
| 2143 | a2c = alphaToCoverage; |
| 2144 | } |
| 2145 | else |
| 2146 | { |
| 2147 | if( FAILED( hr = __SetRenderState( D3DRS_ALPHATESTENABLE, FALSE ) ) ) |
| 2148 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to disable alpha testing", |
| 2149 | "D3D9RenderSystem::_setAlphaRejectSettings" ); |
| 2150 | } |
| 2151 | // Set always just be sure |
| 2152 | if( FAILED( hr = __SetRenderState( D3DRS_ALPHAFUNC, D3D9Mappings::get(func) ) ) ) |
| 2153 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha reject function", "D3D9RenderSystem::_setAlphaRejectSettings" ); |
| 2154 | if( FAILED( hr = __SetRenderState( D3DRS_ALPHAREF, value ) ) ) |
| 2155 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set render state D3DRS_ALPHAREF", "D3D9RenderSystem::_setAlphaRejectSettings" ); |
| 2156 | |
| 2157 | // Alpha to coverage |
| 2158 | if (getCapabilities()->hasCapability(RSC_ALPHA_TO_COVERAGE)) |
| 2159 | { |
| 2160 | // Vendor-specific hacks on renderstate, gotta love 'em |
| 2161 | if (getCapabilities()->getVendor() == GPU_NVIDIA) |
| 2162 | { |
| 2163 | if (a2c) |
| 2164 | { |
| 2165 | if( FAILED( hr = __SetRenderState( D3DRS_ADAPTIVETESS_Y, (D3DFORMAT)MAKEFOURCC('A', 'T', 'O', 'C') ) ) ) |
| 2166 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha to coverage option", "D3D9RenderSystem::_setAlphaRejectSettings" ); |
| 2167 | } |
| 2168 | else |
| 2169 | { |
| 2170 | if( FAILED( hr = __SetRenderState( D3DRS_ADAPTIVETESS_Y, D3DFMT_UNKNOWN ) ) ) |
| 2171 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha to coverage option", "D3D9RenderSystem::_setAlphaRejectSettings" ); |
| 2172 | } |
| 2173 | |
| 2174 | } |
| 2175 | else if ((getCapabilities()->getVendor() == GPU_AMD)) |
| 2176 | { |
| 2177 | if (a2c) |
| 2178 | { |
| 2179 | if( FAILED( hr = __SetRenderState( D3DRS_POINTSIZE, MAKEFOURCC('A','2','M','1') ) ) ) |
| 2180 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha to coverage option", "D3D9RenderSystem::_setAlphaRejectSettings" ); |
| 2181 | } |
| 2182 | else |
| 2183 | { |
| 2184 | // discovered this through trial and error, seems to work |
| 2185 | if( FAILED( hr = __SetRenderState( D3DRS_POINTSIZE, MAKEFOURCC('A','2','M','0') ) ) ) |
| 2186 | OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set alpha to coverage option", "D3D9RenderSystem::_setAlphaRejectSettings" ); |
| 2187 | } |
| 2188 | } |
nothing calls this directly
no test coverage detected