Thiago Assis
unread,Jul 23, 2009, 1:24:45 AM7/23/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Android Developers
Texture appears white in the real device but not in the emulator
Hello fellows,
I’ve already tried to find the solution in other POSTS but none of
the solutions worked.
The problem that I have is that the loaded texture not displayed in
the real device (G1, firmware 1.5). If I turn of the texture and put a
color in the geometry, it works fine.
Details: the file that I’m loading has width and height power of 2.
And I tried with .bmp and .png files, for both I had the same
problem.
My code:
METHOD used to load texture:
private int loadTexture (GL10 gl, Bitmap bmp)
{
int[] tmp_tex= new int[1];
gl.glGenTextures(1, tmp_tex, 0);
gl.glBindTexture(GL10.GL_TEXTURE_2D, tmp_tex[0]);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);
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_CLAMP_TO_EDGE);
return tmp_tex[0];
}
The FOLLOWING code is inside DRAW method.
>>>>>>>>>>>> DRAW METHOD..
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
GLU.gluOrtho2D(gl, 0.0f,1.2f,0.0f,1.0f);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
gl.glDisable(GL10.GL_BLEND);
//texture...
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
bmp=BitmapFactory.decodeResource(c.getResources(), R.drawable.capa);
texBuff=makeFloatBuffer(texture);
gl.glTexCoordPointer(2,GL10.GL_FLOAT,0,texBuff);
tex= loadTexture(gl, bmp);
//small Box...
bb2 =ByteBuffer.allocateDirect(square2.length*4);
bb2.order(ByteOrder.nativeOrder());
squareBuff2 = bb2.asFloatBuffer();
squareBuff2.put(square2);
squareBuff2.position(0);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, squareBuff2);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
//back box
bb =ByteBuffer.allocateDirect(square.length*4);
bb.order(ByteOrder.nativeOrder());
squareBuff = bb.asFloatBuffer();
squareBuff.put(square);
squareBuff.position(0);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, squareBuff);
gl.glColor4f(0,0,1,1);
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
>>>>>>>>>>>> DRAW METHOD END..
Let me know if you know what is going wrong and what I should do.
My code works fine in the emulator but not in the real device. (This
is a simple code that I’ve done months ago, so I’m using this is a
reference to find the problem.)
Thanks a lot for your attention.
Best regards,
Assis