Changing from DDraw to D3DXSprite...
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? ^_^
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.
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 the code because I haven't been able to do it yet.
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
I use the alpha channel and not the color key but I imagine it would work the same way
// loadD3DXCreateSprite(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); // looppd3dxSprite->Begin(D3DXSPRITE_ALPHABLEND); pd3dxSprite->Draw(pTexture, NULL, &D3DXVECTOR3(0,0,0), &D3DXVECTOR3(0,0,0), D3DCOLOR_RGBA(255,255,255,255)); pd3dxSprite->End(); // unloadpTexture->Release(); pd3dxSprite->Release();
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! ^_^
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! ^_^
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement