Using a whole image in a sprite?

Started by
3 comments, last by george7378 11 years, 1 month ago

I'm trying to create rectangular buttons for my GUI using sprites (I figure that this is the easiest way to display a textured rectangle on screen) but I have a little problem - the sprite drawing interface only lets me select an area of a texture to use as my sprite - there doesn't seem to be an option to compress a whole texture to the correct size so that it fits into an arbitrary rectangle. Does anyone know how I can make a sprite resize the texture so that it fits into my specified rectangle?

Thanks!

Advertisement

Assuming you use this function to draw, read carefully what it says about the pSrcRect.

I did see that, but I think it just uses the image in its native size rather than fitting it to the rectangle I specified. i.e. if the image is 100x200, it won't resize it to fit into my desired rectangle with dimensions of 50x100 for example. That's what I'm trying to do.

use NULL as pSrcRect (to get the full image) and apply a transform to scale it down.

Thanks, that seems to be the only way. I decided that it's probably a better idea to create my buttons as offscreen textures and then load them in as individual sprites rather than trying to force text on top of a blank sprite.

This topic is closed to new replies.

Advertisement