OpenGL ES black texture on Nexus S

OpenGL code that runs on Nexus One will not work properly on Nexus S. Textures do not seem to render, and I stay only black where the textures should be.

Does anyone have any idea?

+6
android opengl-es nexus-s
source share
2 answers

The accepted answer given here fixes this problem a little deeper than I do, but while this black screen problem arises from Nexus S (and some other devices) strictly speaking about the strength of two textures, this does not mean that the textures should have dimensions that are Po2 .

The following lines may appear in the texture loading code:

GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); 

and if this code is changed to add two more lines for fixing, then it will support nPo2 textures, provided that everything is in order with fixing. Here is the code with the clips added:

  GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE); 
+2
source share

Nexus S is more strict about the size of images that are used as textures in OpenGL ES.

Textures should be 2 ^ n in size (e.g. 256, 512, 1024, etc.)

0
source share

All Articles