Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

DirectX sprite size units?

4: Adsense

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   

1419
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!



#2 MJP   Moderators   

19482
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   

1419
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.