GLSurfaceView displaying black on Nexus 7 with Android 4.2

I have an OpenGL ES2.0 application that runs on devices with different versions of Android from 2.2 to 4.1. However, they told me that when running on Nexus 7 with Android 4.2, the 3D graphics in the application are all black. However, the action bar and dialogs work fine. I tried it on an emulated Nexus 7 with an Intel Atom processor, HAX and GPU with 4.2.2 enabled, and this works fine. I would prefer to run the ARM image, but does not seem to include Open GL ES2.0

Does anyone have an idea of ​​what might cause this problem on Nexus 7 and how to get around it?

One possibility is that the current version of the application has a target API level of 15, and 4.2.2 has a level of 17. Could this be a problem? However, it works fine on the emulator.

Below is the code that I use to set the textures in the onSurfaceCreated () renderer in case this is any help.

/**
 * Sets up texturing for the object
 */
private void setupTextures(String[] texFiles) {
    // create new texture ids if object has them
    // number of textures
    mTextureIDs = new int[texFiles.length];

    GLES20.glGenTextures(texFiles.length, mTextureIDs, 0);

    for(int i = 0; i < texFiles.length; i++) {
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureIDs[i]);

        // parameters
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,
                GLES20.GL_NEAREST);
        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
                GLES20.GL_TEXTURE_MAG_FILTER,
                GLES20.GL_LINEAR);

        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);

        int ID = mContext.getResources().getIdentifier( texFiles[i], "raw", "com.antonymsoft.slidixcube" );
        InputStream is = mContext.getResources().openRawResource(ID);
        Bitmap bitmap;
        try {
            bitmap = BitmapFactory.decodeStream(is);
        } finally {
            try {
                is.close();
            } catch(IOException e) {
                // Ignore.
            }
        }

        // create it 
        GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
        bitmap.recycle();

    }
}
+5
source share
1 answer

What is the size of your textures? It should be a power of two, for example 16x32 512x512 1024x512 and so on.

+4
source

All Articles