|
|
发表于 2005-2-22 21:37:00
|
显示全部楼层
Re:关于D3DXSPRITE的问题
这个问题也困扰了我半天,我是这样解决的:
//这个是DX9用图片生成TEXTURE的一个函数,用它后图片就不能在屏幕上保持原样
HRESULT D3DUtil_CreateTexture( LPDIRECT3DDEVICE9 pd3dDevice, TCHAR* strTexture,
LPDIRECT3DTEXTURE9* ppTexture, D3DFORMAT d3dFormat )
{
HRESULT hr;
TCHAR strPath[MAX_PATH];
// Get the path to the texture
if( FAILED( hr = DXUtil_FindMediaFileCb( strPath, sizeof(strPath), strTexture ) ) )
return hr;
// Create the texture using D3DX
return D3DXCreateTextureFromFileEx( pd3dDevice, strPath,
D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, d3dFormat,
D3DPOOL_MANAGED, D3DX_FILTER_TRIANGLE|D3DX_FILTER_MIRROR,
D3DX_FILTER_TRIANGLE|D3DX_FILTER_MIRROR, 0, NULL, NULL, ppTexture );
}
//注意第三四五个参数,用这个函数,图片可以在屏幕上保持原样
D3DXCreateTextureFromFileEx( g_pd3dDevice,
"donut.bmp",
320, // I had to set width manually. D3DPOOL_DEFAULT works for textures but causes problems for D3DXSPRITE.
384, // I had to set height manually. D3DPOOL_DEFAULT works for textures but causes problems for D3DXSPRITE.
1, // Don't create mip-maps when you plan on using D3DXSPRITE. It throws off the pixel math for sprite animation.
D3DPOOL_DEFAULT,
D3DFMT_UNKNOWN,
D3DPOOL_DEFAULT,
D3DX_DEFAULT,
D3DX_DEFAULT,
D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f),
&d3dxImageInfo,
NULL,
&g_pDonutTexture );
|
|