Jump to content
  • Advertisement
Sign in to follow this  
CuppoJava

Tiling a non-power-of-2 texture.

This topic is 4527 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, Does anyone if it's possible to tile a texture that doesn't have power-of-2 dimensions? Normally, I just set the texture coordinates to be greater than 1 and it tiles nicely, but when the dimensions aren't power of 2 then I can't use that technique. Is it necessary to just draw quads one-by-one? Thanks for replying. -Cuppo

Share this post


Link to post
Share on other sites
Advertisement
Thanks for the reply,
I don't know what NPOT means. Can you explain a bit more?
Also, I forgot to mention that I'm using OpenGL.
-Cuppo

Share this post


Link to post
Share on other sites
Are you actually asking how you can tile a partial texture image? For example: you have a 32 by 32 texture with a 25 by 25 image inside of it.

If so, there is no automatic method of doing this. What I would do is check if the implementation supports non-power-of-two textures and (going back to my little example), if so, just create a 25 by 25 sized texture. If the implementation does not support non-power-of-two textures I would just stretch the image up to the next power-of-two dimensions so that it does fill the texture (32 by 32 in this case).

At large image sizes this does become a memory burden (e.g., 600 by 300 gets stretched up to 1024 by 512). Also, if you're trying to create pixel-perfect output you have to handle the stretching and later texture filtering very carefully. But, if you're targetting modern implementations non-power-of-two texture support is nearly a given. Just provide a (possibly lower quality, such as the image stretching) fallback routine for non-supporting hardware.

Share this post


Link to post
Share on other sites
Thanks for that in-depth explanation null and void. That was exactly what I'm asking.
I am planning for my game to be run on PC's, so I think I'll use the texture resizing approach as I can't depend on my end user's always having the latest hardware.
-Thanks, Cuppo

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!