Drawing a sprite in a rect.

Started by
5 comments, last by VanillaSnake21 14 years, 10 months ago
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

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

Advertisement
Edit - unhelpful stuff deleted

[Edited by - Alatar on June 4, 2009 1:08:29 AM]
"All you have to decide is what to do with the time that is given to you." - Gandalf
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.

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

Edit - unhelpful stuff deleted

[Edited by - Alatar on June 4, 2009 1:32:39 AM]
"All you have to decide is what to do with the time that is given to you." - Gandalf
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.

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

Right, sorry I missed that. Good luck finding a solution!
"All you have to decide is what to do with the time that is given to you." - Gandalf
[bump] So is there no other way?

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

This topic is closed to new replies.

Advertisement