1

I'm playing around with OpenGL ES 2 and FloatBuffers. Actually i try to save the FloatBuffer handling the Vertices Data to a binary file. It seems to work but after reading in the floats and puting them back togehter to a FloatBuffer the object is messed up.

For saving the float data from my Buffer i use the following code:

for(int i = 0; i < bufferSize; i++)
 outStream.writeFloat(floatBuffer.get(i));

For reading:

for(int i = 0; i < bufferSize; i++)
  if(inStream.available() != 0)
    tmpFloat[i] = inStream.readFloat();

FloatBuffers are created this way:

FloatBuffer VertexBuffer = ByteBuffer.allocateDirect(VertexFloatArray.length * mBytesPerFloat).order(ByteOrder.nativeOrder()).asFloatBuffer();
VertexBuffer.put(VertexFloatArray).position(0);

Does anyone have a idea why this happens?

UPDATE: I already compared the data written and readed and they are equal. The problem is still there and this is just more confusing.

ZeroTek
  • 1,302
  • 1
  • 11
  • 30
  • Can you be more descriptive than 'the object is messed up'? Have you tried just comparing the values you write with the values you read in a debugger? – Tim Oct 31 '12 at 06:15
  • "messed up" means the displayed 3D Model is drawn with a lot of artifacts (seems like the vertices position data is wrong). I already compared the values but they are equal. This is why i'm so confused. – ZeroTek Oct 31 '12 at 13:17

1 Answers1

0

Well, i didn't solve the problem but instead of writing just the vertexbuffer to a file i tried writing a packed buffer (containing vertex, texture coords, normals, etc) and this worked perfectly. I can't figure out why this works and a single buffer doesn't but for my needs the question is answered.

ZeroTek
  • 1,302
  • 1
  • 11
  • 30