Using GL_ARB_texture_rectangle with POT textures.

Started by
4 comments, last by LordOrion 15 years, 12 months ago
Hi to everyone, my OpenGL application need to load and display both Power-of-Two (POT) and Non-power-of-two (NPOT) sized textures. To do this, I'm using GL_ARB_texture_non_power_of_two extension or GL_ARB_texture_rectangle extension (when the first one is not available). For a pure matter of simplicity, I'm not checking if the loaded texture is POT or NPOT sized, I'm just picking the best available method and using it. This means that is it possible that I use GL_ARB_texture_rectangle even with POT sized textures (when GL_ARB_texture_non_power_of_two/OpenGL 2.0 is not available). I'm wandering if this could add any loss of performances... Anyone knows something about that?
Bye and Thanks!SiS.Professional Software Developer.
Advertisement
Yes, NPOT and texture_rectangle perform a little worst than pow2. Also, in one of nVidia documents it was stated that they pad the texture to make it pow2.
IMO, you should only use these 2 when doing a full quad scene effect, where you don't need a mipmap.
Actually, you can even use pow2 texture in that case as well. That's what I do.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Historically, using Non Power of two textures caused a huge performance drop. More recent video cards and (presumably) better drivers results in much better performance. The best performance and clean code paths - I would always recommend sticking to using standard power of two based textures.

If you really, really can't then use RECTANGLE in preference to Non-PowerOfTwo

Really? Using RECTANGLE is better than using OpenGL 2.0 NPOT?

Bye and Thanks!SiS.Professional Software Developer.
Main trouble is what is faster on one platform may not be on another. E.g. ATI Vs NVidia - let alone 6800 Vs 7800 etc...

Guess, the only way to tell is benchmark it - on your target platform. Best bet is to avoid the whole issue and stick to regular TEXTURE_2D textures. Yep - re author the source images.
I agree with you. But unfortunately I can't. Textures are loaded by application users: mine is a sort of submarine GIS application and texture images are generated by and echo-sounder device. Moreover specifications states that images can have "any" size so I'm forced to use the extensions... I also cannot think to pad the image to POT due it is not uncommon to have images of 10k - 20k pixels...
I obviously cut them in smaller ones, but the memory overhead to pad each one is/could be really huge.
Ok, so I guess I will keep my current strategy... but maybe I can check if the texture / texture slice to be loaded is POT or NPOT before load it and choose hhe proper texture target (GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_ARB)...
However now I have another question... Time to open another thread!

Thank you very much to everyone.
Bye and Thanks!SiS.Professional Software Developer.

This topic is closed to new replies.

Advertisement