Tuesday, February 21, 2006

DirectX: LoadTexture

LPDIRECT3DTEXTURE9 LoadTexture(LPCWSTR filename, LPDIRECT3DDEVICE9 pd3dDevice){
LPDIRECT3DTEXTURE9 texture = NULL;
D3DXIMAGE_INFO info;
HRESULT hr;
//get width and height
V(D3DXGetImageInfoFromFile(filename, &info));
//create a new texture
V(D3DXCreateTextureFromFileEx(
pd3dDevice, // LPDIRECT3DDEVICE9 pDevice,
filename, //LPCTSTR pSrcFile,
info.Width, //Width,
info.Height, //Height,
1, //mipmap
D3DPOOL_DEFAULT, //DWORD Usage,
D3DFMT_UNKNOWN, //surface Format,
D3DPOOL_DEFAULT, //memory Pool,
D3DX_DEFAULT, //IMAGE Filter,
D3DX_DEFAULT, //MipFilter,
0, //ColorKey for transparency,
&info, //bitmap file info,
NULL, //color Palette,
&texture //destination Texture
));
return texture;
}

No comments: