What is the best way to detect if a graphics card and compiled openGL binary supports textures which are not a power of 2 at run time?
+5
A:
You can check with glGet
for ARB_texture_non_power_of_two or use GLEW.
Edit to reflect the comments: As of OpenGL 2.0 this feature is required and ARB_texture_non_power_of_two need not be defined. How to find the current version is described here. As Jerry points out: Depending on the GPU the feature might be implemented in software and the performance wont be great if you use textures with a non-power-of-two size.
pmr
2010-06-15 15:30:40
You also need to check for OpenGL 2.0+, as it has <code>ARB_texture_non_power_of_two</code> implicitly (I *think* GLEW does this automatically)
wump
2010-06-15 15:32:54
@wump Do you have any documentation on this? My google-fu seems useless here and there is no such mentioning anywhere in the documentation. `glewinfo` listed it fine.
pmr
2010-06-15 15:44:15
GL_ARB_texture_non_power_of_two is core in OpenGL 2.0 and beyond.Notice that some old cards expose this extension, but have some limitations for NPOT textures, such as limited wrap modes.
Matias Valdenegro
2010-06-15 15:45:45
So an OpenGL 1.x implementation would never support non Po2 textures?
Nick
2010-06-15 16:44:34
@Nick: an OpenGL 1.x implementation can support it via ARB_texture_non_power_of_two. From OpenGL 2.0 onwards, it's required rather than an extension -- but also be aware that in some cases, it's supported, but in software so performance is really poor.
Jerry Coffin
2010-06-15 16:50:42
Sadly, most modern ATI boards do not support hardware NPOT2, so I'd definitely continue treating the flag as conditional, rather than assuming it and eating the performance hit.
Nick Gebbie
2010-06-16 00:42:10
pmr: When a OpenGL implementation advertises a certain version of the API, it is not required to list the extensions that are a requirement for that version anymore. This means that OGL 2.0 implementations can either list or not list ARB_texture_non_power_of_two, but in both cases it will be present.AFAIK there is no way to check whether it is supported in HW or emulated. That's the way OGL works.
wump
2010-06-16 10:00:26