How to test if OpenGL support textures of non power of 2?
#1 Members - Reputation: 889
Posted 23 October 2012 - 03:27 PM
Or maybe I should just check if OpenGL 2.0 is present and older versions would never be able to support it anyway?
#4 Moderators - Reputation: 4654
Posted 23 October 2012 - 04:45 PM
#6 Members - Reputation: 3828
Posted 23 October 2012 - 07:09 PM
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.
#7 Senior Moderators - Reputation: 4749
Posted 23 October 2012 - 08:49 PM
[source lang="cpp"]#include <GL/glew.h>glewInit();if (GLEW_VERSION_2_0 || GLEW_ARB_texture_non_power_of_two){ /* I can haz teh supportz? */}[/source]
Tristam MacDonald - SDE @ Amazon - swiftcoding [Need to sync your files via the cloud? | Need affordable web hosting?]
#8 Members - Reputation: 889
Posted 24 October 2012 - 01:27 AM
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?
#9 Moderators - Reputation: 4654
Posted 24 October 2012 - 03:30 AM
#10 Members - Reputation: 3828
Posted 24 October 2012 - 04:57 AM
OK, maybe I will explain in details.
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.
#11 Members - Reputation: 889
Posted 12 November 2012 - 05:31 AM
Can I use GL_RGBA,GL_UNSIGNED_INT_8_8_8_8_REV instead? Or it must be BGRA?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.
#12 Members - Reputation: 3828
Posted 12 November 2012 - 06:01 AM
Can I use GL_RGBA,GL_UNSIGNED_INT_8_8_8_8_REV instead? Or it must be BGRA?
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.
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.






