Jump to content

  • Log In with Google      Sign In   
  • Create Account


DirectX sprite size units?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 george7378   Members   -  Reputation: 1132

Like
0Likes
Like

Posted 14 March 2013 - 03:01 PM

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!



Sponsor:

#2 MJP   Moderators   -  Reputation: 10071

Like
1Likes
Like

Posted 14 March 2013 - 03:17 PM

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.


Edited by MJP, 14 March 2013 - 06:16 PM.


#3 george7378   Members   -  Reputation: 1132

Like
0Likes
Like

Posted 14 March 2013 - 03:50 PM

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS