Jump to content
  • Advertisement
Sign in to follow this  
Anri

Changing from DDraw to D3DXSprite...

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've recently changed from DDraw7 to D3D9's Sprite API, but despite getting the interface working, I find very little documentation on how to do the small things in 2D life... My main headache is that in DirectDraw7 I could do colour-keying( not blitting all the black/green pixels in a surface ), but in D3D9...I can only assume its something to do with the textures and their alpha channels...or something like that. Any handy tips? ^_^

Share this post


Link to post
Share on other sites
Advertisement
If you load the texture using D3DXCreateTextureFromFileEx(), you can specify your colorkey there. It will convert the image so that pixels with the specified color will be transparent. The ID3DXSprite interface will then draw the image with that transparency.

Share this post


Link to post
Share on other sites
2d was sure easier in direct draw. IF you get it working maybe you can
share the code because I haven't been able to do it yet.

Share this post


Link to post
Share on other sites
here is how you can load a png file and display it using ID3DXSprite
I use the alpha channel and not the color key but I imagine it would work the same way


// load
D3DXCreateSprite(pd3dDevice, &pd3dxSprite);

D3DXCreateTextureFromFileEx(pd3dDevice, "image.png", D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_FILTER_NONE, D3DX_FILTER_NONE, 0, NULL, NULL, &pTexture);

// loop
pd3dxSprite->Begin(D3DXSPRITE_ALPHABLEND);

pd3dxSprite->Draw(pTexture, NULL, &D3DXVECTOR3(0,0,0), &D3DXVECTOR3(0,0,0), D3DCOLOR_RGBA(255,255,255,255));

pd3dxSprite->End();

// unload
pTexture->Release();

pd3dxSprite->Release();

Share this post


Link to post
Share on other sites
Re: eFoDay.

By simply replacing the "image.png", you can use bmps etc. I have to say that this is definitely one welcome change from DDraw...^_^

Re: Susan_GT.

Apart from not being able to muck about with the video buffer( plotting individual pixels was just damn cool! ), the DX9 Sprite interface is actually less hassle than DDraw7. Rotation, Alpha-blending, scaling...wow! ^_^

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!