Sign in to follow this  

handling square textures

This topic is 4841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I've recently started writing a GUI using Direct3D rather than DirectDraw. I've heard that it's best to use only square textures using square numbers, i.e 4x4 32x32 128x128, etc. This is causing me a lot of problems when I want to draw non square images to the screen. I've been loading the images which aren't square into a square texture with a colour key value so that when I render the texture to the back buffer the images appear correctly. The problems I'm having a to do with managing it all. I end up having loads of overlapped textured quads when I'm doing things like rendering the parts of a window frame, and managing all this is becoming a real headache. Especially when I need to place things on the screen related to the image size and not the size of the texture it's contained in. Here's an example: Say I've got a 20x10 PNG file that I want to repeat along the screen. I'd load it into a 32x32 texture and render it onto a 32x32 quad, with transparency wherever the image isn't. Looks fine. Then the next quad would overlap the last and so on. Has anyone got any experience with this that they can share? I'd really appreciate it. Many thanks, Daniel

Share this post


Link to post
Share on other sites
Modern video cards support non power of two textures, so you could use that. However that restricts use of your GUI to people who have the requisite video card. Another solution is to upsize all image you load to the nearest power of two dimensions. Then when drawing a textured quad using that image make the quad the same size as the original image and use nearest-neighbor texture filtering. This may not give you a pixel perfect repoduction of the image you loaded in though.

Share this post


Link to post
Share on other sites
Try putting all you GUI assets on one (or two) big 256x256 textures. Then when drawing your widgets, you can just feed in the texture coordinates that widget takes up on the texture... if that makes sense (probably doesn't). You'll also save a bit of texture memory and some state changes :)

Share this post


Link to post
Share on other sites

This topic is 4841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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