Skip to content Skip to sidebar Skip to footer

GlDrawTexfOES Draws Black Texture On Phone, And Correct In Emulator

I'm writing a 2D game using OpenGL, using png images (64x64 pixels, with transparency) stored in my resources. My code looks like this : import javax.microedition.khronos.egl.EGL

Solution 1:

I am not sure is it same reason than you but try it.

I loaded textures before (and same problem like you):

gl.glBindTexture(GL10.GL_TEXTURE_2D, textureIDs[i]);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmaps[i], 0); 

Thats works fine in emulator but you can set more parameters to texture how its will calculate. My guess is that phone can't set these by default and thats why it not work (but that just guess). So to the solution:

gl.glBindTexture(GL10.GL_TEXTURE_2D, textureIDs[i]); //Same

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

gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_REPEAT);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT);

GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmaps[i], 0); //Same

That's it. You can google more information from those parameters (GL_LINEAR and GL_REPEAT) if you don't know.

I hope this will help =)


Post a Comment for "GlDrawTexfOES Draws Black Texture On Phone, And Correct In Emulator"