|
The changes from the Colour Key lesson are VERY minor. The file name for the texture is
different, and this time we set our colour key to 0. This disables the colour key processing
completely. Since our image comes with an alpha channel in it, we don't need D3DX to create one
for us.
//D3DXCreateTextureFromFileEx takes a lot of paramters.
//We pass it our device and the file name of our texture.
//We set Width & Height to D3DX_DEFAULT so it uses the values in the file.
//We want an alpha channel so we tell it to use D3DFMT_A8R8G8B8 because it's a
// very common texture format, it should work on just about everything.
//Since our image has an alpha channel in it, we set our colour key to 0
// which disables it.
hr=D3DXCreateTextureFromFileEx(g_d3d_device, //Our D3D Device
"test.png", //Filename of our texture
D3DX_DEFAULT, //Width:D3DX_DEFAULT = Take from file
D3DX_DEFAULT, //Height:D3DX_DEFAULT = Take from file
1, //MipLevels
0, //Usage, Is this to be used as a Render Target? 0 == No
D3DFMT_A8R8G8B8, //32-bit with Alpha, everything should support this
D3DPOOL_MANAGED,//Pool, let D3D Manage our memory
D3DX_DEFAULT, //Filter:Default filtering
D3DX_DEFAULT, //MipFilter, used for filtering mipmaps
0, //Disable ColourKey
NULL, //SourceInfo, returns extra info if we want it (we don't)
NULL, //Palette:We're not using one
&g_texture); // Our texture goes here.
|