0

I made a small function that iterates over a string and puts new texture coordinates in a buffer according to the coordinates of each character in the 256x256 font texture, so I can render the text with OpenGL vertex arrays.

private void updateTexCoords() { float unit = 0.0625f; byte[] arr = string.getBytes(); for(int i = 0; i < string.length()*8; i += 8) { float x = (float)(((int)arr[i/8] & 0xff)%16)*unit; float y = (float)(((int)arr[i/8] & 0xff)/16)*unit; //axis center is at (0,1) pointing right, down texture[0+i] = x; texture[1+i] = y+unit; //bottom left texture[2+i] = x; texture[3+i] = y; //top left texture[4+i] = x+unit; texture[5+i] = y+unit; //bottom right texture[6+i] = x+unit; texture[7+i] = y; //top right } ByteBuffer byteBuffer = ByteBuffer.allocateDirect(texture.length * 4); byteBuffer.order(ByteOrder.nativeOrder()); textureBuffer = byteBuffer.asFloatBuffer(); textureBuffer.put(texture); textureBuffer.position(0); } 

It works excellent for all of the devices tested on except one old phone, HTC nexus one, where it shows messed up symbols although there is a pattern and you see that basically the texture coordinates given to it are somehow wrong. What could cause such a problem on one specific device, especially when working in Java and not messing with the native hardware-related things?

1 Answer 1

1

Some Android devices simply have buggy OpenGL ES drivers. HTC might have updated drivers available. Which GPU type is it? If it works correctly on the AVD emulation, then your code is probably fine.

If you are using backface culling, I would also try reversing the winding direction that is culled.

Sign up to request clarification or add additional context in comments.

1 Comment

All of the images except text are shown correctly. Even those that have custom texture coordinates (not the standard 0f and 1f).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.