Sign in to follow this  
VanillaSnake21

Drawing a sprite in a rect.

Recommended Posts

Hi, I've recently switched from using textured quads for my 2d game to using sprites, surprisingly though I did not find a place for Destination Rect in the sprite's Draw call, and I happen to need that feature. Basically is there any way to draw a sprite in a specified rect. P.S I know that you can probably use some sort of an equation to figure out the scaling and the translate factors that would make it the size of a given rect, but is there a more elegant solution? Thanks

Share this post


Link to post
Share on other sites
I think it worked because you used the same size image. What I'm guessing is that the scale matrix will scale the image from the center outwards, meaning that it would scale in the + and - x directions. So even if I put the pos as the top coordinates of the rect, the scaling will offset it. The only way I think this might work is if I set the center to the top left corner of image, set the position as the top left corner of the dest rect, then come up with an equation that would give me a scale factor depending how far the right edge of the image is from the right edge of the dest rect. But this seems a little too much, all this work just to draw a sprite in one spot, and I plan to have lots (of animated) sprites all over the place, I might as well stick with textured quads... Anyways is this the only way? I can't believe DX guys left out such an obvious function.

Share this post


Link to post
Share on other sites
How would I downscale a sprite without a destination rect? What I'm basically saying is lets say I have an image that's like 1024x800 and I want to disply it as a small 306x200 model on screen, without a dest rect I would have to basically do all the things I said in the last post.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this