Would I be a jerk if I required all my game users to support non-power of two textures?
How do you tell easily if this feature is supported?
|
|
0
|
|
|
|
Reply
|
bob3904 (234)
|
7/29/2012 7:23:56 PM |
|
"bob smith" <bob@coolfone.comze.com> wrote in message
news:77498dbf-cda5-468d-884d-b7dd72b15915@googlegroups.com...
> Would I be a jerk if I required all my game users to support non-power of
> two textures?
>
> How do you tell easily if this feature is supported?
Depends on what other minimum features you need, and your target platforms.
Cell phones? Tablets?
Query for the extension.
jbw
|
|
0
|
|
|
|
Reply
|
jbwest6104 (60)
|
7/30/2012 2:10:51 AM
|
|
On Sunday, July 29, 2012 9:23:56 PM UTC+2, bob smith wrote:
> Would I be a jerk if I required all my game users to support non-power of two textures?
>
Yes.
>
>
> How do you tell easily if this feature is supported?
Unless you're programming for a specific
system it's best to program as if it isn't
supported.
Supporting npo2 should be a bonus feature
added if you have time left over to do it,
not the other way around.
Images which are used in 3D or tiled can be
resized to power-of-two without any real
visual difference (they get filtered and
interpolated anyway as part of mipmapping).
For 2D images that need exact 1:1 pixel
correspondence you can allocate a texture
which is too big and put your image in the
corner. You might be able to use the unused
area for smaller images. If you want to
step up a level you can make textures as
big as the hardware supports and pack several
images into them, optimizing for best fit.
As programmer it's your job to make it work,
even if it looks different on different hardware.
|
|
0
|
|
|
|
Reply
|
tooby (65)
|
7/30/2012 9:36:38 AM
|
|
On Sun, 29 Jul 2012 12:23:56 -0700, bob smith wrote:
> Would I be a jerk if I required all my game users to support non-power
> of two textures?
If you're going to be requiring a reasonably modern card for other
reasons, requiring non-2^n textures isn't going to affect the set of
supported platforms.
> How do you tell easily if this feature is supported?
if (strstr(glGetString(GL_EXTENSIONS),
"GL_ARB_texture_non_power_of_two"))
...
|
|
0
|
|
|
|
Reply
|
nobody (4805)
|
7/30/2012 10:41:46 AM
|
|
On Monday, July 30, 2012 5:41:47 AM UTC-5, Nobody wrote:
> On Sun, 29 Jul 2012 12:23:56 -0700, bob smith wrote:
>
>
>
> > Would I be a jerk if I required all my game users to support non-power
>
> > of two textures?
>
>
>
> If you're going to be requiring a reasonably modern card for other
>
> reasons, requiring non-2^n textures isn't going to affect the set of
>
> supported platforms.
>
>
>
> > How do you tell easily if this feature is supported?
>
>
>
> if (strstr(glGetString(GL_EXTENSIONS),
>
> "GL_ARB_texture_non_power_of_two"))
>
> ...
For some reason, it doesn't like this:
glGetString(GL_EXTENSIONS);
It returns 0.
|
|
0
|
|
|
|
Reply
|
bob3904 (234)
|
7/30/2012 7:57:28 PM
|
|
On 7/30/2012 5:41 AM, Nobody wrote:
> On Sun, 29 Jul 2012 12:23:56 -0700, bob smith wrote:
>
>> Would I be a jerk if I required all my game users to support non-power
>> of two textures?
>
> If you're going to be requiring a reasonably modern card for other
> reasons, requiring non-2^n textures isn't going to affect the set of
> supported platforms.
>
possibly, but it may still be a good idea to not require it.
it isn't too hard to have fallback logic for this case:
odd texture size?
have NPOT support?
use NPOT;
else
resample;
use resampled texture.
I generally prefer power-of-2 textures, unless there is good reason to
do otherwise.
>> How do you tell easily if this feature is supported?
>
> if (strstr(glGetString(GL_EXTENSIONS),
> "GL_ARB_texture_non_power_of_two"))
> ...
>
yep.
|
|
0
|
|
|
|
Reply
|
cr88192355 (1754)
|
7/31/2012 2:19:03 AM
|
|
On Mon, 30 Jul 2012 12:57:28 -0700, bob smith wrote:
>> if (strstr(glGetString(GL_EXTENSIONS),
>> "GL_ARB_texture_non_power_of_two"))
>> ...
>
> For some reason, it doesn't like this:
>
> glGetString(GL_EXTENSIONS);
>
> It returns 0.
Have you created and bound a context at the point that you call it?
Also, in 3.x and later "core profile", glGetString(GL_EXTENSIONS) is no
longer valid (it will fail with GL_INVALID_ENUM). Instead, you need to
use glGetStringi(), e.g.:
GLint count;
GLuint i;
glGetIntegerv(GL_NUM_EXTENSIONS, &count);
for (i = 0; i < count; i++)
if (strcmp(glGetStringi(GL_EXTENSIONS, i),
"GL_ARB_texture_non_power_of_two") == 0)
...
|
|
0
|
|
|
|
Reply
|
nobody (4805)
|
7/31/2012 1:43:11 PM
|
|
On Tuesday, July 31, 2012 8:43:16 AM UTC-5, Nobody wrote:
> On Mon, 30 Jul 2012 12:57:28 -0700, bob smith wrote:
>
>
>
> >> if (strstr(glGetString(GL_EXTENSIONS),
>
> >> "GL_ARB_texture_non_power_of_two"))
>
> >> ...
>
> >
>
> > For some reason, it doesn't like this:
>
> >
>
> > glGetString(GL_EXTENSIONS);
>
> >
>
> > It returns 0.
>
>
>
> Have you created and bound a context at the point that you call it?
>
>
>
> Also, in 3.x and later "core profile", glGetString(GL_EXTENSIONS) is no
>
> longer valid (it will fail with GL_INVALID_ENUM). Instead, you need to
>
> use glGetStringi(), e.g.:
>
>
>
> GLint count;
>
> GLuint i;
>
> glGetIntegerv(GL_NUM_EXTENSIONS, &count);
>
> for (i = 0; i < count; i++)
>
> if (strcmp(glGetStringi(GL_EXTENSIONS, i),
>
> "GL_ARB_texture_non_power_of_two") == 0)
>
> ...
Yes, glGetString(GL_EXTENSIONS) did fail with GL_INVALID_ENUM.
Here's a list of the extensions on my Macbook Pro:
GL_ARB_instanced_arrays...
GL_ARB_occlusion_query2...
GL_ARB_shader_bit_encoding...
GL_ARB_timer_query...
GL_EXT_texture_compression_s3tc...
GL_EXT_texture_filter_anisotropic...
GL_EXT_texture_sRGB_decode...
GL_APPLE_client_storage...
GL_APPLE_container_object_shareable...
GL_APPLE_object_purgeable...
GL_APPLE_rgb_422...
GL_APPLE_row_bytes...
GL_APPLE_texture_range...
I guess my textures have to be power of two?
Seems weird cause I just bought this thing.
|
|
0
|
|
|
|
Reply
|
bob3904 (234)
|
7/31/2012 2:02:29 PM
|
|
On Monday, July 30, 2012 9:57:28 PM UTC+2, bob smith wrote:
> For some reason, it doesn't like this:
>
> glGetString(GL_EXTENSIONS);
>
> It returns 0.
Do you have an active OpenGL context?
|
|
0
|
|
|
|
Reply
|
tooby (65)
|
7/31/2012 5:37:06 PM
|
|
On Tuesday, July 31, 2012 4:02:30 PM UTC+2, bob smith wrote:
>
> I guess my textures have to be power of two?
>
> Seems weird cause I just bought this thing.
Not at all. OpenGL development is moving
towards OpenGL ES as the standard (becuase
the main OpenGL platform in the future will
be mobile devices - iPhone and Android).
OpenGL ES doesn't support non-power-of-two
textures.
|
|
0
|
|
|
|
Reply
|
tooby (65)
|
7/31/2012 5:42:42 PM
|
|
On Tuesday, July 31, 2012 12:42:43 PM UTC-5, fungus wrote:
> On Tuesday, July 31, 2012 4:02:30 PM UTC+2, bob smith wrote:
>=20
> >=20
>=20
> > I guess my textures have to be power of two?
>=20
> >=20
>=20
> > Seems weird cause I just bought this thing.
>=20
>=20
>=20
> Not at all. OpenGL development is moving
>=20
> towards OpenGL ES as the standard (becuase
>=20
> the main OpenGL platform in the future will
>=20
> be mobile devices - iPhone and Android).
>=20
>=20
>=20
> OpenGL ES doesn't support non-power-of-two
>=20
> textures.
Hmmm=85 I know I have used non-power-of-two textures in the Android emulato=
r.
|
|
0
|
|
|
|
Reply
|
bob3904 (234)
|
8/1/2012 3:32:20 PM
|
|
On Tue, 31 Jul 2012 07:02:30 -0700, bob smith wrote:
> Yes, glGetString(GL_EXTENSIONS) did fail with GL_INVALID_ENUM.
>
> Here's a list of the extensions on my Macbook Pro:
[snip]
> I guess my textures have to be power of two?
Have you tried?
It's possible (and quite likely) that it's just not listed as an
extension. The OpenGL 2.0 specification says:
I.3 Non-Power-Of-Two Textures
The restriction of textures to power-of-two dimensions has been relaxed
for all texture targets, so that non-power-of-two textures may be
specified without generating errors. Non-power-of-two textures was
promoted from the ARB texture non power of two extension.
So in theory, anything reporting an API version of 2.0 or greater should
support non-2^n textures regardless of any extension.
In theory, you should check whether the functionality is available via the
core OpenGL API (via glGetIntegerv() with GL_MAJOR_VERSION and
GL_MINOR_VERSION), and check whether it's available as an extension as a
fallback. For extensions which add new functions, the function will have a
vendor or ARB suffix if it's an extension, but not if it's part of the
core API.
Most of the implementations I've encountered retain extensions even after
the extension has been incorporated into the core API[1], in order to
maintain compatibility with legacy code. E.g. my (fairly recent) ATI card
reports an API version of 4.2 yet lists 281 extensions, the majority of
which have long since been promoted to the API.
[1] With modern cards, this can result in glGetString(GL_EXTENSIONS) being
long enough to cause problems with older programs (either a buffer overrun
or truncating the string and missing some extensions), which probably
explains the introduction of glGetStringi().
Apparently, Apple's implementation doesn't do this (all of your extensions
are either GL_APPLE_* or are fairly new features). If you're getting
GL_INVALID_ENUM for glGetString(GL_EXTENSIONS), you appear to be getting a
3.x "core profile" context, so backwards compatibility isn't applicable
(lack of support for extensions will probably be less of an issue than the
lack of support for most of the 1.x API).
However: the glTexImage2D manual page for both 3.3 and 4.2 still says:
GL_INVALID_VALUE is generated if non-power-of-two textures are not
supported and the width or height cannot be represented as 2^k+2(border)
for some integer value of k.
In my experience, the manual pages can contain outdated information,
sometimes for long periods. It's likely that the 3.x and 4.x manual pages
were based upon the 2.x manual pages, with new details added and old
details not necessarily removed.
|
|
0
|
|
|
|
Reply
|
nobody (4805)
|
8/1/2012 4:52:30 PM
|
|
On Wednesday, August 1, 2012 11:52:35 AM UTC-5, Nobody wrote:
> On Tue, 31 Jul 2012 07:02:30 -0700, bob smith wrote:
>
>
>
> > Yes, glGetString(GL_EXTENSIONS) did fail with GL_INVALID_ENUM.
>
> >
>
> > Here's a list of the extensions on my Macbook Pro:
>
>
>
> [snip]
>
>
>
> > I guess my textures have to be power of two?
>
>
>
> Have you tried?
>
>
>
> It's possible (and quite likely) that it's just not listed as an
>
> extension. The OpenGL 2.0 specification says:
>
>
>
> I.3 Non-Power-Of-Two Textures
>
>
>
> The restriction of textures to power-of-two dimensions has been relaxed
>
> for all texture targets, so that non-power-of-two textures may be
>
> specified without generating errors. Non-power-of-two textures was
>
> promoted from the ARB texture non power of two extension.
>
>
>
> So in theory, anything reporting an API version of 2.0 or greater should
>
> support non-2^n textures regardless of any extension.
>
>
>
> In theory, you should check whether the functionality is available via the
>
> core OpenGL API (via glGetIntegerv() with GL_MAJOR_VERSION and
>
> GL_MINOR_VERSION), and check whether it's available as an extension as a
>
> fallback. For extensions which add new functions, the function will have a
>
> vendor or ARB suffix if it's an extension, but not if it's part of the
>
> core API.
>
>
>
> Most of the implementations I've encountered retain extensions even after
>
> the extension has been incorporated into the core API[1], in order to
>
> maintain compatibility with legacy code. E.g. my (fairly recent) ATI card
>
> reports an API version of 4.2 yet lists 281 extensions, the majority of
>
> which have long since been promoted to the API.
>
>
>
> [1] With modern cards, this can result in glGetString(GL_EXTENSIONS) being
>
> long enough to cause problems with older programs (either a buffer overrun
>
> or truncating the string and missing some extensions), which probably
>
> explains the introduction of glGetStringi().
>
>
>
> Apparently, Apple's implementation doesn't do this (all of your extensions
>
> are either GL_APPLE_* or are fairly new features). If you're getting
>
> GL_INVALID_ENUM for glGetString(GL_EXTENSIONS), you appear to be getting a
>
> 3.x "core profile" context, so backwards compatibility isn't applicable
>
> (lack of support for extensions will probably be less of an issue than the
>
> lack of support for most of the 1.x API).
>
>
>
> However: the glTexImage2D manual page for both 3.3 and 4.2 still says:
>
>
>
> GL_INVALID_VALUE is generated if non-power-of-two textures are not
>
> supported and the width or height cannot be represented as 2^k+2(border)
>
> for some integer value of k.
>
>
>
> In my experience, the manual pages can contain outdated information,
>
> sometimes for long periods. It's likely that the 3.x and 4.x manual pages
>
> were based upon the 2.x manual pages, with new details added and old
>
> details not necessarily removed.
I just tried it with a 1280x800 texture, and it seems to have worked.
Thanks.
|
|
0
|
|
|
|
Reply
|
bob3904 (234)
|
8/2/2012 11:17:25 PM
|
|
On Friday, August 3, 2012 1:17:25 AM UTC+2, bob smith wrote:
>
> I just tried it with a 1280x800 texture, and it seems to have worked.
>
So...it works on your particular brand/version
of hardware, even if the extensions list says
it doesn't.
Does that seem to you like a good thing to
rely on when you publish your program? What
does your program do if it fails?
|
|
0
|
|
|
|
Reply
|
tooby (65)
|
8/4/2012 10:51:42 AM
|
|
On Sat, 4 Aug 2012 03:51:45 -0700 (PDT), fungus <tooby@artlum.com>
wrote:
>On Friday, August 3, 2012 1:17:25 AM UTC+2, bob smith wrote:
>>
>> I just tried it with a 1280x800 texture, and it seems to have worked.
>>
>
>So...it works on your particular brand/version
>of hardware, even if the extensions list says
>it doesn't.
>
>Does that seem to you like a good thing to
>rely on when you publish your program? What
>does your program do if it fails?
In this case, I think the suggestion Nobody wrote out would already
allow a check to make sure - failing an extension return, check the
OpenGL version and variant, and should it be appropriate, it's worth a
shot.
Though really, the unwieldiness of putting together different texture
sizes for theoretical situations - not confirmed situations like if
you knew you were porting to an embedded environment - ultimately
means you either pack a PO2 texture or an NPO2 texture.
~Temia
--
Invective! Verb your expletive nouns!
|
|
0
|
|
|
|
Reply
|
lamialily (18)
|
8/4/2012 6:32:43 PM
|
|
On Saturday, August 4, 2012 8:33:17 PM UTC+2, Temia Eszteri wrote:
>
> In this case, I think the suggestion Nobody wrote out would already
> allow a check to make sure - failing an extension return, check the
> OpenGL version and variant, and should it be appropriate, it's worth a
>
I think the best/simplest check is to try
and create a non-power-of-2 texture and
see if it fails. This is similar to using
a proxy texture in OpenGL to check the
hardware capabilities.
OTOH you have to decide what to do when it
fails. Will you just abort? Will you have
a load of angry customers?
I say it's better to regard non-PO2 as
a luxury. Write your program as if it's
not available. Use it to improve image
quality and/or memory usage when it is.
Resizing images as you load them from
disk is no big deal. It should add no
more than a couple of hours development
time. Not doing it seems like incredible
laziness to me.
|
|
0
|
|
|
|
Reply
|
tooby (65)
|
8/5/2012 3:29:10 PM
|
|
On Friday, August 3, 2012 1:17:25 AM UTC+2, bob smith wrote:
>
> I just tried it with a 1280x800 texture, and it seems to have worked.
>
That seems suspiciously screen-resolution sized.
Do you use a 2048x1024 texture if it fails?
|
|
0
|
|
|
|
Reply
|
tooby (65)
|
8/5/2012 3:31:15 PM
|
|
On 8/5/2012 10:29 AM, fungus wrote:
> On Saturday, August 4, 2012 8:33:17 PM UTC+2, Temia Eszteri wrote:
>>
>> In this case, I think the suggestion Nobody wrote out would already
>> allow a check to make sure - failing an extension return, check the
>> OpenGL version and variant, and should it be appropriate, it's worth a
>>
>
> I think the best/simplest check is to try
> and create a non-power-of-2 texture and
> see if it fails. This is similar to using
> a proxy texture in OpenGL to check the
> hardware capabilities.
>
> OTOH you have to decide what to do when it
> fails. Will you just abort? Will you have
> a load of angry customers?
>
> I say it's better to regard non-PO2 as
> a luxury. Write your program as if it's
> not available. Use it to improve image
> quality and/or memory usage when it is.
>
> Resizing images as you load them from
> disk is no big deal. It should add no
> more than a couple of hours development
> time. Not doing it seems like incredible
> laziness to me.
>
pretty much, and also if the resampling code uses bicubic interpolation
or similar, the visible impact of resampling may be, in-fact, fairly
small (granted, it is a little more expensive, both in time and
implementation effort, than using bilinear interpolation).
|
|
0
|
|
|
|
Reply
|
cr88192355 (1754)
|
8/5/2012 4:15:31 PM
|
|
On Sun, 05 Aug 2012 08:29:10 -0700, fungus wrote:
> I say it's better to regard non-PO2 as
> a luxury. Write your program as if it's
> not available. Use it to improve image
> quality and/or memory usage when it is.
>
> Resizing images as you load them from
> disk is no big deal. It should add no
> more than a couple of hours development
> time. Not doing it seems like incredible
> laziness to me.
Moving up to the next power of two can require almost four times as much
memory.
Resampling introduces artifacts; blurring if you filter (which isn't an
option for integer textures), aliasing if you don't. Padding won't work if
you need textures to wrap.
If you're going to be requiring a lot of OpenGL 3.x features anyhow,
supporting an implementation which doesn't even provide 2.0 is pointless.
Dealing with the theoretical (but almost certainly non-existent) case of
an implementation which provides 1.x plus extensions for every required
3.x feature *except* non-2^n textures would be sheer pedantry.
|
|
0
|
|
|
|
Reply
|
nobody (4805)
|
8/6/2012 3:39:31 AM
|
|
On Sat, 04 Aug 2012 03:51:45 -0700, fungus wrote:
> On Friday, August 3, 2012 1:17:25 AM UTC+2, bob smith wrote:
>>
>> I just tried it with a 1280x800 texture, and it seems to have worked.
>>
>
> So...it works on your particular brand/version
> of hardware, even if the extensions list says
> it doesn't.
The extension list is irrelevant; given that he's getting a "core profile"
context, the OpenGL version will be at least 3.0, and non-2^n textures are
part of the 2.0 API.
|
|
0
|
|
|
|
Reply
|
nobody (4805)
|
8/6/2012 4:24:59 AM
|
|
On Monday, August 6, 2012 5:39:31 AM UTC+2, Nobody wrote:
>
> Moving up to the next power of two can require almost four times as much
>
> memory.
>
That's only for really bad image sizes and
where you can't make atlases.
> Resampling introduces artifacts; blurring if you
> filter aliasing if you don't.
>
This only matters if your textures are used
in 2D with no zooming.
> If you're going to be requiring a lot of
> OpenGL 3.x features anyhow,
>
> supporting an implementation which doesn't even provide 2.0 is pointless.
>
> Dealing with the theoretical (but almost certainly non-existent) case of
>
> an implementation which provides 1.x plus extensions for every required
>
> 3.x feature *except* non-2^n textures would be sheer pedantry.
If you're *sure* it will be supported then
whatever.
But ... thread "White texture on Galaxy Tab 10.1"
for what happens to people who make assumptions.
Plus ... there can be performance penalties
for using it.
|
|
0
|
|
|
|
Reply
|
tooby (65)
|
8/6/2012 5:27:37 AM
|
|
|
20 Replies
111 Views
(page loaded in 0.293 seconds)
Similiar Articles: Offscreen Rendering demo released - comp.graphics.api.opengl ...I've been trying to figure out GL_EXT_framebuffer_multisample, GL_EXT_framebuffer_blit, GL_ARB_texture_non_power_of_two, and GL_ARB_texture_rectangle ... glDrawPixel - what is missing here? - comp.graphics.api.opengl ...So this pattern is > the perfect example of how to pixel exactly place a texture. > > > GL_ARB_texture_non_power_of_two and our camera image is 640 x > > 480. > > Then ... renderbuffer objects - comp.graphics.api.opengl... GL_TEXTURE_2D, depthTex, 0); (*REMARK* this->height() and width() are likely to be non-power of two although my card doesn't support this. using power-of-two-textures ... non-repeating, random, textures ... - comp.graphics.api.opengl ...Would someone be able to tell me if it's possible (preferably with some sample code showing how) to create a two dimensional, non-repeating texture a... Scrolling Background Texture - comp.graphics.api.openglRepeat mode only works for power-of-two sized textures in 'standard' OpenGL. It may work for the extensions, I don't know. It sounds like you will need to render two ... Creating matrix of 1's and 0's based on a comparison of values in ...renderbuffer objects - comp.graphics.api.opengl... and width() are likely to be non-power of two ... I never had a chance to test this on any other system ... the code ... 3D Texture Constraints - comp.graphics.api.openglI understand that 3D textures must have dimensions that are powers of 2, and no extension exists to work ... fit this bill, so I'm padding them out to the nearest power of 2 ... Frame synchronization - comp.dspThe bandwidth and power are VERY limited so every single bit and +1dB gain is ... :-) Yea, the non-power of 2 thing with variable constellation is in the plans. Blending useing glColor4f(....) - comp.graphics.api.opengl ...glBegin(GL_QUADS) ..... glEnd(); Drawing of the two textures work fine.. ... I think the incoming texture alpha needs to be non-zero -- I think modulate is texture alpha ... Optimizing glCopyPixels or glDrawPixels - comp.graphics.api.opengl ...And is there a way to make it faster like if I used power of 2 dimensions of ... glReadBuffer(GL_BACK); //width and height might need to be 2^n glBindTexture(GL_TEXTURE_2D, m ... GL_ARB_texture_non_power_of_twoName ARB_texture_non_power_of_two Name Strings GL_ARB_texture_non_power_of_two Contributors Pat Brown Cass Everitt Walt Donovan Ken Dyke Evan Hart Bimal Poddar Choosing a Texture Size - Panda3D ManualIf you open a window that supports non-power-of-two textures, panda will switch into textures-power-2 none mode. If you then open a second window using a different video ... 7/30/2012 9:13:36 AM
|