OpenGL 2.0 or later alone is enough, you don't need to check the extension if the version is OK. If the version is pre-2.0, then you need to check the extension. But note that 2.0 does not mean that the extension will be listed so you cannot rely on the extension alone. You have to check both if you want to cover for earlier versions, but passing one of the tests is enough.

Beware that OpenGL makes no promise to hardware-accelerate non-power-of-two textures. And you can't check for that.

In general if your GL_VERSION is 3.0 or better you're absolutely guaranteed to have them, and to have them be hardware accelerated. In the rare event that you encounter a really really really old card with a lower version, you may or may not have them be accelerated (GeForce FX was an offender here, despite claiming 2.0). You might be aware to get away with GL_ARB_texture_rectangle instead, if your usage meets it's restrictions: http://www.opengl.org/registry/specs/ARB/texture_rectangle.txt

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

I use glDrawPixels for 2D stuff, that are my requirements. Because it's slow I rewrote it to standard textured quads (ortho perspective, etc). But since power of two textures are sometimes not supported I need to fallback to glDrawPixels in some cases (that's why I need the detection part). I can do it any other way of course, as long as compatibility and performance is OK since this is my goal. Again, I don't need anything fancy here, it's just a replacement for glDrawPixels.

Is the GL_ARB_texture_rectangle extension significantly more supported? Or other extensions/tricks?

How to do it best? How you would do it?

Working on an Emperor focused, no micromanagement, asymmetric, 4X, space empire builder:

Just because you're using textures doesn't mean you have to draw the whole texture. Another option is to use a texture the size of the next larger power of two and then stick your image in a part of the larger texture. You can even pack multiple images in in the same texture if you want.

I use glDrawPixels for 2D stuff, that are my requirements. Because it's slow I rewrote it to standard textured quads (ortho perspective, etc). But since power of two textures are sometimes not supported I need to fallback to glDrawPixels in some cases (that's why I need the detection part). I can do it any other way of course, as long as compatibility and performance is OK since this is my goal. Again, I don't need anything fancy here, it's just a replacement for glDrawPixels.

glDrawPixels can be fast if you use the right params. Since you've observed slowness I'm guessing that you're using dear old GL_RGB/GL_UNSIGNED_BYTE, which is a slow path nearly everywhere; you need these parameters to match the native format of your backbuffer otherwise GL is going to send the data through intermediate conversion steps, so try it with GL_BGRA/GL_UNSIGNED_INT_8_8_8_8_REV for starters and you should see a very noticeable performance increase (at the cost of an extra byte per pixel - fair tradeoff) - that just requires GL1.2 support. Also be sure, if you're using glDrawPixels, to switch off texturing and lighting, as OpenGL will texture and light individual pixels otherwise.

Is the GL_ARB_texture_rectangle extension significantly more supported? Or other extensions/tricks?

The definition of "significant" nowadays is that you can rely on full general non-power-of-two support being available absolutely everywhere, aside from some 6-year-old laptops or business-class PCs with integrated Intels. But since you're aiming for an extremely downlevel minimum GL_VERSION it's fair to say that GL_ARB_texture_rectangle is more likely to be supported on that class of lower paleolithic hardware.

Edited by mhagain, 24 October 2012 - 11:14 AM.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

glDrawPixels can be fast if you use the right params. Since you've observed slowness I'm guessing that you're using dear old GL_RGB/GL_UNSIGNED_BYTE, which is a slow path nearly everywhere; you need these parameters to match the native format of your backbuffer otherwise GL is going to send the data through intermediate conversion steps, so try it with GL_BGRA/GL_UNSIGNED_INT_8_8_8_8_REV for starters and you should see a very noticeable performance increase (at the cost of an extra byte per pixel - fair tradeoff) - that just requires GL1.2 support.

Can I use GL_RGBA,GL_UNSIGNED_INT_8_8_8_8_REV instead? Or it must be BGRA?

Working on an Emperor focused, no micromanagement, asymmetric, 4X, space empire builder:

glDrawPixels can be fast if you use the right params. Since you've observed slowness I'm guessing that you're using dear old GL_RGB/GL_UNSIGNED_BYTE, which is a slow path nearly everywhere; you need these parameters to match the native format of your backbuffer otherwise GL is going to send the data through intermediate conversion steps, so try it with GL_BGRA/GL_UNSIGNED_INT_8_8_8_8_REV for starters and you should see a very noticeable performance increase (at the cost of an extra byte per pixel - fair tradeoff) - that just requires GL1.2 support.

Can I use GL_RGBA,GL_UNSIGNED_INT_8_8_8_8_REV instead? Or it must be BGRA?

It depends on the layout of your underlying framebuffer, and that's going to be decided by your hardware. If your hardware likes data in BGRA order, then BGRA order is what you must use to get the fast path.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.