Search code examples
androidtexturesopengl-es-2.0nexus-7

Non Power of Two texture on the Google Nexus 7 (and possibly other devices)


I refer you to this question:

GLSurfaceView displaying black on Nexus 7 with Android 4.2

It turns out that the asker's problem was resolved when he changed his textures from NPOT to POT textures.

My confusion arises from the official OpenGL ES 2.0 Spec which states that OpenGL ES 2.0 supports NPOT textures (just not with mipmaps and only with CLAMP_TO_EDGE wrap mode)

The Nexus 7 supports OpenGL ES 2.0, so is it therfore not bound to the rules of the spec? What makes the Nexus 7 so different? What stops it supporting NPOT textures? I'm currently not aware of any other OpenGL ES 2.0 Devices that have this limitations (Maybe I'm wrong).

I am aware that the Nexus 7 has a somewhat limited texture size limit of 2048 x 2048, but still not sure of this NPOT limitation.

Be grateful if someone could clear this up for me once and for all.


Solution

  • As you already mention in your question, the OpenGL ES 2.0 spec defines that only GL_CLAMP_TO_EDGE is supported as wrap mode for NPOT textures.

    The code you link uses GL_REPEAT:

    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
            GLES20.GL_REPEAT);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
            GLES20.GL_REPEAT);
    

    So this is not required to be supported by the spec. Many devices support the OES_texture_npot extension, which adds support for additional wrap modes and mipmapping for NPOT textures.