Original Post
[I use DirectX 7!]
Hi all,
I''m kinda lost with the DirectX ALPHAOP render state. I''m used to OpenGL, where you can simply call functions like this:
//for alpha blending: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //for alpha testing: glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_EQUAL, reference_value);With Direct3D I''ve found the following functions, which are pretty equal:
//for alpha blending: m_d3ddevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, TRUE ); m_d3ddevice->SetRenderState( D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA ); m_d3ddevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA ); //for alpha testing: m_d3ddevice->SetRenderState( D3DRENDERSTATE_ALPHATESTENABLE, TRUE ); m_d3ddevice->SetRenderState( D3DRENDERSTATE_ALPHAREF, reference_value); m_d3ddevice->SetRenderState( D3DRENDERSTATE_ALPHAFUNC, D3DCMP_EQUAL );What I don''t understand though is that ALPHAOP stuff... how do I configure the ALPHAOP renderstate so that it works like OpenGL? In other words, is it possible to setup the ALPHAOP renderstate once, after which I can simply use the functions above to enable alpha testing/blending? I ask this, because I''ve found out that the following piece of code sets up the the ALPHAOP stuff for proper alpha blending:
m_d3ddevice->SetTextureStageState(i, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); m_d3ddevice->SetTextureStageState(i, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);But the code for proper alpha testing is:
m_d3ddevice->SetTextureStageState(i, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); m_d3ddevice->SetTextureStageState(i, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); m_d3ddevice->SetTextureStageState(i, D3DTSS_ALPHAARG2, D3DTA_CURRENT );Can this be combined? I want to be able to alpha test and alpha blend at the same time! I''m completely flabbergasted by the DX7 Help, which is not quite clear about all the different possibilities. Any help would be greatly appreciated! Marc