DirectX sprite size units?

Started by
1 comment, last by george7378 11 years, 1 month ago

Hi everyone,

I'm a bit confused about the units used to define sprite sizes and things in D3D9. I have a 205x340 image which I'm trying to use as a sprite, and the ID3DXSprite::Draw method takes a sprite rectangle to define the area of the image to be drawn. I want to draw the top half of the image, so I put in the following rect:


RECT spriteRect = {0, 0, 205, 170};

However, this doesn't take the top half of the sprite. So my question is, what units are used by the ID3DXSprite::Draw method to cut out the image to be used? It doesn't appear to be the size of the source image itself - I can't think what else it is.

Thanks!

Advertisement

ID3DXSprite works in pixel coordinates, with (0, 0) being the top left of the screen. Your issue is probably that your texture is being scaled up to the next power-of-2 dimension (256x512 in your case). This is the default behavior of D3DXCreateTextureFromFile, and it's done in order to accommodate older harder that has no or limited support for non-power-of-2 dimensions. If you don't care about that, you can call D3DXCreateTextureFromFileEx with parameters that indicate that you don't want it upscaled.

That seems to be the problem. I thought it might be something to do with resolution or something!

This topic is closed to new replies.

Advertisement