🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

DX7::D3DX Sprite question

Started by
14 comments, last by Evil 24 years, 7 months ago
Anyone have any ideas? It's blatant omissions like these in the Microsoft examples that drive me bonkers.
------------------------
E.N.D. - http://listen.to/evil
Advertisement
I haven't tried working with what you're working with, but in the past I've seen a lot of people leave out one of these steps:

DDCOLORKEY ddck;
ddck.dwColorSpaceHighValue = RGB(0, 0, 0);
ddck.dwColorSpaceLowValue = RGB(0, 0, 0);
lpDDSurface->SetColorKey (DDCKEY_SRCBLT, &ddck);

If you already have transparency working forgive me, I haven't seen your code to know what you have or haven't tried. Once I get the damn DX 7 SDK from MS I'll take a look at it myself.

Yes, in my modification I did properly set the color key as you demonstrate in your post. However, it still doesn't work. I appreciate the attempt to help though.

Any other guru's have a suggestion I can try?

------------------------
E.N.D. - http://listen.to/evil
I'm not very familiar with DirectDraw, but I looked in the Index for Color Keys. There is an article there with instructions. Do you have to specify some options when you blit? BltFast supports a color key value, and Blt has several flags about color keying.

Let me know if this helps! I am planning to learn DirectDraw soon...

D3DRENDERSTATE_COLORKEYENABLE
TRUE to enable color-keyed transparency. The default value is FALSE. Use this render state with D3DRENDERSTATE_ALPHABLENDENABLE to implement fine blending control.
Applications should check the D3DDEVCAPS_DRAWPRIMTLVERTEX flag in the D3DDEVICEDESC7 structure to find out whether this render state is supported.
When color-keyed transparency is enabled, only texture surfaces that were created with the DDSD_CKSRCBLT flag are affected. Surfaces that were created without the DDSD_CKSRCBLT flag exhibit color-keyed transparency effects.

Try looking in the docs next time.

Josh

I *DID* read that in the docs. And if you READ my original message, I said I DID use SetRenderState. It STILL doesn't work.
------------------------
E.N.D. - http://listen.to/evil
Null_Pointer: When using the D3DX library, you don't use BLT or BLTFAST. There are new sprite drawing functions in the library. I can achieve the effect fine with blits, I just cant get any of the new DrawSprite functions to do it.
------------------------
E.N.D. - http://listen.to/evil
Sorry!

Hard to read documentation is one of the reasons I don't use DirectX yet!

The renderstate you want is D3DRENDERSTATE_COLORKEYBLENDENABLE. That's what you get from actually looking in the docs. I'll admit though, you have to be familiar with the DirectX documentation to even know where to look.
I did also set COLORKEYBLENDENABLE (and the ALPHATESTENABLE) render states when trying to make it work, but they had no apparent effect either. I've played with every render state that I thought could possibly affect the output, but still no dice.

It's kind of ironic that the operation I want to use is called D3DXDrawSpriteSIMPLE when something as easy as what I want to do is convoluted with half a dozen renderstate flags.

I probably should have just posted the code I added in the first place, but I never seem to be at either of the systems where I made the modifications at the times I get a chance to visit this board. The code I tried looks like this:

DDCOLORKEY m_CK; //= {0x00000000, 0x00000000};
m_CK.dwColorSpaceHighValue = RGB(0,0,0);
m_CK.dwColorSpaceLowValue = RGB(0,0,0);
m_ptex->SetColorKey(DDCKEY_SRCBLT, &m_CK);
m_pd3dDevice->SetRenderState
(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
m_pd3dDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE, TRUE);
m_pd3dDevice->SetRenderState(D3DRENDERSTATE_COLORKEYBLENDENABLE, TRUE);
m_pd3dDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, TRUE);

------------------------
E.N.D. - http://listen.to/evil

This topic is closed to new replies.

Advertisement