Question

I have an OpenGL ES2.0 app that is working on devices running various Android versions from 2.2 up to 4.1. However I have been told that when running it on a Nexus 7 with Android 4.2 the 3D graphics in the App are all black. The Action Bar and dialogs work fine though. I have tried it on an emulated Nexus 7 with Intel Atom processor, HAX and GPU enabled running 4.2.2 and that works OK. I would have preferred to run the ARM image but that doesn't seem to include Open GL ES2.0

Does anyone have any insight into what might be causing this problem on the Nexus 7 and how to work around it?

One possibility is that the current App version has the target API level set to 15 whereas 4.2.2 is level 17. Could that be an issue? It works OK on the emulator though.

Below is the code that I use to set the textures in the renderer onSurfaceCreated() in case that 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();

    }
}
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top