Sign in to follow this  

Changing from DDraw to D3DXSprite...

This topic is 4693 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
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
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

This topic is 4693 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this