I'm using an Android tablet to parse a binary point cloud file,
populate arrays of position/colors, and provide an interactive viewing
environment for the result.
This works fine when collecting ~50K points (which would result in 3
floats for position, 3 floats for color, and 1 float for extra data I
use... all per point). However for still very common, larger files, my
application will crash while allocating to the buffers to draw. Here
is the basic way of allocating to a position buffer:
ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length * 4);
vbb.order(ByteOrder.nativeOrder());
vertexBuffer = vbb.asFloatBuffer();
vertexBuffer.put(vertices);
vertexBuffer.position(0);
On the first line (the allocate) if the vertices.length results in
more than maybe ~300,000 - I'll run out of memory. The only decent way
I know of in OpenGL-ES to draw points is with the buffers, and the
Draw() method looks like this:
public void draw(GL10 gl) {
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
gl.glColorPointer(4, GL10.GL_FLOAT, 0, colorBuffer);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
gl.glPointSize(0.6f);
gl.glDrawArrays(GL10.GL_POINTS, 0, numVertices);
gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
}
I have to only parse the file once, as this takes some time. Can I
somehow hold the arrays on the SD and populate the Draw() from that
memory, instead? Or some sort of database implementation? I've tried
everything I know of, but am at a dead end.
I would REALLY appreciate any help or advice you guys think would be
helpful. Thank you!
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en