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.

4

1 に答える 1

0

さて、私は問題を解決しませんでしたが、ファイルに頂点バッファだけを書き込む代わりに、パックされたバッファ(頂点、テクスチャ座標、法線などを含む)を書き込んでみましたが、これは完全に機能しました。なぜこれが機能し、単一のバッファが機能しないのか理解できませんが、私のニーズのために質問に答えます。

于 2012-11-01T13:44:35.613 に答える