Tiling a non-power-of-2 texture.

Started by
4 comments, last by CuppoJava 17 years, 10 months ago
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
Advertisement
Couldn't you just set the texture coordinates to be multiples of the NPOT width/height?
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
NPOT = Non-Power Of Two.
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.
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

This topic is closed to new replies.

Advertisement