如何获取纹理的实际大小?

chriscross 2008-03-10 03:04:29
想写一个类来画一个纹理的一部分,函数原型 Draw(IDirect3DTexture9* pDevice, RECT* pSrcRect, RECT* pDestRect);
类似于Id3dxsprite 的Draw方法里的srcRect,

我的想法是如何有图像原始尺寸的话可以改变顶点的UV来实现
但是用IDirect3DTexture9 里的GetLevelDesc()不能得到原尺寸

ID3dxsprite里的Draw方法也没要求提供原尺寸

有没有办法可以获得图像原尺寸或用其他方法来实现这个功能?
...全文
486 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
cdbanty 2010-06-07
  • 打赏
  • 举报
回复
冒个泡!!!
btx2397 2010-06-04
  • 打赏
  • 举报
回复
HRESULT LoadTextureFromFile(IDirect3DDevice9*in_pDevice,LPCSTR in_strPath,LPDIRECT3DTEXTURE9 *in_texture,int *io_Weight,int *io_Heigth)
{
HRESULT hr=S_FALSE;
LPDIRECT3DTEXTURE9 texture;
D3DXIMAGE_INFO info;
hr=D3DXCreateTextureFromFileEx(in_pDevice,in_strPath,D3DX_DEFAULT,D3DX_DEFAULT,D3DX_DEFAULT,0,D3DFMT_UNKNOWN,D3DPOOL_MANAGED,D3DX_FILTER_TRIANGLE ,D3DX_FILTER_TRIANGLE ,0 ,
&info,NULL,&texture);
if (FAILED(hr))
{
return S_FALSE;
}
*in_texture=texture;
*io_Weight=info.Width;
*io_Heigth=info.Height;
return S_OK;
}
应该够用了。
gameice 2010-06-04
  • 打赏
  • 举报
回复
.........OMG 08年的
gameice 2010-06-04
  • 打赏
  • 举报
回复



typedef struct D3DSURFACE_DESC {
D3DFORMAT Format;
D3DRESOURCETYPE Type;
DWORD Usage;
D3DPOOL Pool;
D3DMULTISAMPLE_TYPE MultiSampleType;
DWORD MultiSampleQuality;
UINT Width;
UINT Height;
} D3DSURFACE_DESC, *LPD3DSURFACE_DESC;
Members
Format
Member of the D3DFORMAT enumerated type, describing the surface format.
Type
Member of the D3DRESOURCETYPE enumerated type, identifying this resource as a surface.
Usage
Either the D3DUSAGE_DEPTHSTENCIL or D3DUSAGE_RENDERTARGET values. For more information, see D3DUSAGE.
Pool
Member of the D3DPOOL enumerated type, specifying the class of memory allocated for this surface.
MultiSampleType
Member of the D3DMULTISAMPLE_TYPE enumerated type, specifying the levels of full-scene multisampling supported by the surface.
MultiSampleQuality
Quality level. The valid range is between zero and one less than the level returned by pQualityLevels used by IDirect3D9::CheckDeviceMultiSampleType. Passing a larger value returns the error, D3DERR_INVALIDCALL. The MultisampleQuality values of paired render targets, depth stencil surfaces and the MultiSample type must all match.
Width
Width of the surface, in pixels.
Height
Height of the surface, in pixels.


gameice 2010-06-04
  • 打赏
  • 举报
回复
何必呢..........

D3DSURFACE_DESC 是做什么用的
budweiser 2010-06-01
  • 打赏
  • 举报
回复
楼上的好像都不行吧
meiZiNick 2008-05-01
  • 打赏
  • 举报
回复
lz要干嘛?
火云洞红孩儿 2008-03-11
  • 打赏
  • 举报
回复
D3DXIMAGE_INFO t_Info;
D3DXGetImageInfoFromFile( addr->m_szFileName ,&t_Info);
火云洞红孩儿 2008-03-11
  • 打赏
  • 举报
回复
// 获得将要创建纹理的实际大小
UINT tmpW = pSurface->wWidth, tmpH = pSurface->wHeight;
D3DXCheckTextureRequirements( m_lpd3dDevice, &tmpW, &tmpH, NULL, 0, NULL, D3DPOOL_MANAGED );
chriscross 2008-03-10
  • 打赏
  • 举报
回复
上面写错了.pTex不是pDevice

8,304

社区成员

发帖
与我相关
我的任务
社区描述
游戏开发相关内容讨论专区
社区管理员
  • 游戏开发
  • 呆呆敲代码的小Y
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧