GLES20.glActiveTexture(GLES20.GL_TEXTURE0)返回1280

时间:2014-06-19 09:56:16

标签: android opengl-es opengl-es-2.0

我在少数设备上测试我的Android应用程序。它适用于三星Galaxy Note3,但在HTC One X上没有显示任何内容。

GLES20.glActiveTexture(GLES20.GL_TEXTURE0)返回1280

AFAIK OpenGL实现应该支持至少2个纹理,那么它为什么会失败以及如何绕过它呢?

完整绑定代码:

/**
 * Load the texture for the square.
 *
 */
public void setGLTexture(Bitmap bitmap) {
    GLES20.glDisable(GLES20.GL_TEXTURE_2D);

    activeTextureIndex = (activeTextureIndex + 1) % TEXTURES_COUNT;

    Log.d("OPENGL_TEXTURE", "setting new bitmap " + bitmap + " for " + activeTextureIndex );

    GLES20.glActiveTexture(textureIds[activeTextureIndex]);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures[activeTextureIndex]);

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

    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);

    GLES20.glEnable(GLES20.GL_TEXTURE_2D);
}

/** The texture pointer. */
private int activeTextureIndex = -1; // will be incremented before usage
private static final int TEXTURES_COUNT = 2;

private static final int[] textureIds = new int[] {
    GLES20.GL_TEXTURE0,
    GLES20.GL_TEXTURE1,
    GLES20.GL_TEXTURE2,
    GLES20.GL_TEXTURE3,
    GLES20.GL_TEXTURE4,
    GLES20.GL_TEXTURE5,
    GLES20.GL_TEXTURE6,
    GLES20.GL_TEXTURE7,
    GLES20.GL_TEXTURE8,
    GLES20.GL_TEXTURE9,
    GLES20.GL_TEXTURE10
};

0 个答案:

没有答案