I'm currently writing a game that uses 2D OpenGL output under sdl, and I'm trying to load text using SDL_ttf. However I have to pad the text with blank pixels as it appears that plain OpenGL doesn't support non-power of two textures. I've heard that there is an OpenGL extension called GL_ARB_texture_non_power_of_two
that enables non power of two textures. How many cards are incompatible with this extension as of today and how do I load it?

- 42,413
- 44
- 197
- 320

- 1,235
- 2
- 16
- 25
-
2I would recommend sticking with POT textures and just padding. I'm sure someone will provide a list of good reasons to do so. – Matt Razza Jun 15 '11 at 07:59
-
1The answer is that the support is great, unless you are on an ATI card. – Mikola Jun 15 '11 at 23:42
2 Answers
Any OpenGL version 2.0 or greater supports non-power-of-two textures. That means pretty much any card made after around 2005. This includes GeForce FX's and 6xxx and above. It also includes Radeon 9500's and above (though until the Radeon HD series, Radeons do not allow NPOTs to have mipmaps).
BTW, I hope that you aren't trying to put each character into a separate texture. Because that would be terrible from a performance standpoint. Put all of the characters you want to use in a single texture and pick out the ones you need. You don't even need an NPOT for that.
As for mrazza's comment about just using POTs, there's nothing to be afraid of with NPOT textures (as long as your hardware can support it). It shouldn't be something you go to as a first resort, because there may be a minor performance penalty with them, but for obvious cases where padding or rescaling would be inappropriate (render targets, etc), there's nothing to fear from using them.

- 42,413
- 44
- 197
- 320

- 449,505
- 63
- 781
- 982
-
there may be a *minor* performance penalty with them: Do you mean that there will be a performance penalty even though fewer pixels are copied when no padding is done? – Sudarshan S Jun 15 '11 at 08:43
-
But keep in mind that ATI drivers always seem to have problems with them (though I don't know the current state), as with many other things. I remember they worked on a X1650 I once had (whith a 2.0/2.1 driver), but not in GLSL. – Christian Rau Jun 15 '11 at 08:59
-
@Sudarshan S: I emphasized the word "minor" for a reason. It's not something you need to worry about in general, but in the interest of full disclosure, it is possible for accesses from an NPOT texture to be slower than accesses to a POT texture. Again, **minor**. – Nicol Bolas Jun 15 '11 at 09:14
-
Old ATI driver versions (particulary those for older hardware such as X1600 which are not updated anymore) have bugs in NPOT implementation so even though they claim it is supported it usually doesn't work properly and produces garbled textures. – Igor Levicki Mar 08 '15 at 13:58
-
In practice, drivers may have poor/buggy support for some OpenGL features, so you may have to resort to blacklisting certain card/driver/os combinations, eg: https://developer.blender.org/rB9d3a17922cad62f1f73ba60eef669a091a2b8687 – ideasman42 Sep 14 '15 at 15:51
In general, those questions are answered in the opengl specification.
However, the NPOT textures were integrated in OpenGL long ago enough that you need to look at an older version to even find a reference to this. In the 3.0 spec, e.g. you'll see in the L.3 appendix that the NPOT extension was integrated into the GL core starting with GL 2.0. So any implementation that supports GL 2.0 (that's pretty much all PC GPUs since end of 2004) supports the feature.
As to how to "load" it: there's nothing to do. Just pass non-power-of-two sizes to glTexImage.

- 17,760
- 43
- 62