开发者

D3DXSprite and showing textures and rotating them in different ways

i have many textures to show on the screen, some of these textures may have rotation or other transformation. All transformation indepen开发者_运维技巧dent. Do i need to create D3DXSprite for every independent texture? Because, if i create only one sprite and apply transformation it have an affect for every texture in the sprite. Thanks.


No, as the documentation to ID3DXSprite::Draw() states:

To scale, rotate, or translate a sprite, call ID3DXSprite::SetTransform with a matrix that contains the scale, rotate, and translate (SRT) values, before calling ID3DXSprite::Draw. For information about setting SRT values in a matrix, see Matrix Transforms.

So it would look something like this:

d3dxSpriteObject.Begin([...]);
for(int i=0; i<numTextures; i++) 
{
    d3dxSpriteObject.SetTransform(matrix);
    d3dxSpriteObject.Draw(texture[i], NULL, textureCenter[i], texturePos[i], 0xffffffff);
}
d3dxSpriteObject.End();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜