Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Textures only showing on some devices

I am currently writing an Android application that works with OpenGL ES 1.1. It worked fine on my HTC Desire (Android 2.3.7) where I developed it on. Now I wanted to test it on a Nexus 7 but it only shows a black screen. I found out that all textures are simply rendered black. On parts where no object and no texture is rendered, I get the (almost) black background color.

So my question is why are the textures rendered fine on some devices and not on others?

The textures are all quadratic with a size power of 2 (i.e. 512x512, 1024x1024). These are the settings used when the textures are created:

gl.glBindTexture(GL10.GL_TEXTURE_2D, getTextureId());   

// Create Nearest Filtered Texture
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,
        GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER,
        GL10.GL_LINEAR);

// Different possible texture parameters, e.g. GL10.GL_CLAMP_TO_EDGE
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,
        GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,
        GL10.GL_REPEAT);

gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, /*GL10.GL_REPLACE*/ GL10.GL_MODULATE);

// Use the Android GLUtils to specify a two-dimensional texture image
// from our bitmap
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);

What can I try to get the textures rendered on both devices?

like image 754
florianbaethge Avatar asked Sep 07 '12 20:09

florianbaethge


1 Answers

If you're getting your bitmaps from drawables, make sure they are all in drawable-nodpi folder.

Otherwise your power of two image might not be power of two after it gets scaled up on different android densities (a 1024x1024 image in the drawable folder becomes 1536x1536 on HDPI devices).

like image 96
Tim Avatar answered Oct 26 '22 23:10

Tim