NPOT textures are supported on PowerVR SGX hardware, but have restrictions. NPOT textures cannot use mipmaps, must be 2D (no cube-maps or 3D textures) and must use the GL_CLAMP_TO_EDGE
for texture wrapping in both dimensions; this is supported by default in OpenGL ES 2.0 and under ES 1.1 by the extension GL_APPLE_texture_2D_limited_npot
For ES 1.1, you can check at runtime to see if this extension is present with this code:
const char* extensions = (char*) glGetString(GL_EXTENSIONS);
bool npot = strstr(extensions, "GL_APPLE_texture_2D_limited_npot") != 0;
Since this is only present on the SGX and not the MBX, be aware that relying on NPOT texture support will limit you to the newer SGX devices. Of course, relying on ES 2.0 will do the same, so if that's your intended target, NPOT support is a moot point and you can go ahead with NPOT textures.
Here's an alternate solution that lets you keep using ES 1.1 and retain full device support. Put the 320x480 texture inside a 512x512, fill the whitespace with other background tiles, glyphs, or other textures that will be drawn at the same time (to avoid multiple glBindTexture
calls) and then use one of my favourite ES 1.1 extensions, GL_OES_draw_texture
, to quickly copy the 320x480 section onto the viewport:
int rect[4] = {0, 0, 480, 320};
glBindTexture(GL_TEXTURE_2D, texBackground);
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, rect);
glDrawTexiOES(0, 0, z, 480, 320);
Sidebar: The OpenGL ES 2.0 spec itself doesn't specify any restrictions on NPOT textures; unless I'm mistaken, Apple is imposing the limitations - of course, in the ES 1.1 world, NPOT support doesn't exist at all, so it's an addition there.