# Odd D3D9 bug

This topic is 2495 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey guys, so I have a very strange bug that is driving me nuts.

Check out this shot rendered with D3D10. This is what it should look like:

Okay, now here it is in D3D9

Now, ignoring the text difference (that's a different issue), notice in D3D9 the alpha blending is not working properly. So, okay, I figured I'd track it down in Pix. But when I ran it in Pix, it looked like the D3D10 version! Which is to say, the blending worked fine. However, when I run it in the MSVC IDE or straight from the exe file, it looks like the screenshot. So Pix isn't helping me (which is what is very strange about this).

So without Pix to help me, I'm not sure where to look. Do you guys have any idea?

This is my code for blending in D3D9 (minus error checking):

 //we don't have blend states in D3D9, so set render state to include an alpha blend static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_BLENDOPALPHA, D3DBLENDOP_ADD); static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_ALPHABLENDENABLE, true); static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA); static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA); static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE,true); static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_SRCBLENDALPHA,D3DBLEND_ONE); static_cast<IDirect3DDevice9*>(Device)->SetRenderState(D3DRS_DESTBLENDALPHA,D3DBLEND_ZERO); 

compared to what I do for D3D10:
 BlendDesc.AlphaToCoverageEnable = false; for (unsigned int i=0; i<8; i++) { BlendDesc.BlendEnable = false; BlendDesc.RenderTargetWriteMask = D3D10_COLOR_WRITE_ENABLE_ALL; } BlendDesc.BlendEnable[0] = true; BlendDesc.BlendOp = D3D10_BLEND_OP_ADD; BlendDesc.BlendOpAlpha = D3D10_BLEND_OP_ADD; BlendDesc.DestBlend = D3D10_BLEND_INV_SRC_ALPHA; BlendDesc.DestBlendAlpha = D3D10_BLEND_ZERO; BlendDesc.SrcBlend = D3D10_BLEND_SRC_ALPHA; BlendDesc.SrcBlendAlpha = D3D10_BLEND_ONE; static_cast<ID3D10Device1*>(Device)->CreateBlendState(&BlendDesc, reinterpret_cast<ID3D10BlendState**>(BlendState)); 

So, what do you think? What else should I look at here?

##### Share on other sites
Ack, never mind. I got it. Had to turn off the depth test. My bad.

• 9
• 23
• 10
• 19
×

## Important Information

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!