View Full Version : Textures: To the Power of 2 or Not to the ...

05-04-2003, 03:47 PM
To the Power of 2 or Not to the power of two, *that* is the question.

Are there any GL functions that will let me make textures out of images with dimensions that are not to the power of 2 or do I need to scale them myself? If so, howso? (hehehe)

05-04-2003, 03:56 PM
Look into the GL_NV_texture_rectangle extension.

05-04-2003, 03:57 PM
From my experience, if you care for performance, use power-of-two textures.

05-04-2003, 04:11 PM
Unless you use extensions, the hardware must create textures that are power of two in size. You can sub-image a smaller portion of that, but then you have to re-scale your texture coordinates (and tiling won't work right).

05-04-2003, 04:38 PM
The glu texture functions can accept images of arbitrary dimensions, but they don't know about extensions (most notably ARB_texture_compression_s3tc and EXT_packed_pixels).

05-04-2003, 07:08 PM
as in gluBuild2DMipmaps? I've heard the opposite from others...

05-04-2003, 07:20 PM
The GLU functions "accept" images of arbitrary size. They then re-sample to a power of two, as described in the specification. The filter they use isn't even all that good (it's a box filter, implemented in a really slow way).

05-05-2003, 12:14 AM
There's gluScale() I think that gluBuildMipmaps() uses to scale to power of two before making the mip chain.

05-05-2003, 03:54 AM
Texture rectangle is for NV I think + it's slower, why bother, use good paint programs and rescale your image (professionaly http://www.opengl.org/discussion_boards/ubb/biggrin.gif ) and then use them, they are faster and runs everywhere! Even DX documentation says USE power of 2 textures for performance!

05-05-2003, 03:59 AM
As a engine programmer i won't suggest neither gluScaleImage nor gluBuild2DMipmaps.Usually the result from this two functions is unpredictable and it's about 100 times faster and better if you add your own routines for mipmap building and image scaling.

05-05-2003, 04:09 AM
Quick question. I saw some discussion on a mailing list recently about gamma correct mip-mapping.

I probably already know the answer to this, but I assume gluBuildMipMaps, and the SGIS_Auto_mipmap_thingymajig dont do gamma correct mip-mapping. Am I right?


05-05-2003, 04:53 AM
I'd guess gluBuild2DMimaps() probably doesn't. However, looking at the spec, SGIS_generate_mipmaps doesn't actually say what algorithm is used to do the mipmapping (although it suggests a basic 2x2 box), also you can set hints (fastest, nicest) that might change the operation.


05-06-2003, 09:35 PM
2 ideas:

1) scale your image to the closest/larger power of 2 size (you can use gluScaleImage for this)
2) create a texture with the closest/larger power of 2 and keep your image as part of this texture, and adjust the texture coordinates appropriately (ie. the right/bottom coords will not be (1, 1) anymore)

There are some other things to consider:
- if you need to repeat your texture you'll have to go with 1).
- if you can use the second idea, you can combine multiple images inside a single, bigger texture (nice perf gain!)

Hope this helps,