頂点とそのプロパティを持つバイナリファイルを解析しています。これらのファイルの範囲は50,000〜200,000の頂点です。下位のファイルについては、配列の割り当てとポイントの描画に問題はありませんが、ファイルが大きい場合は大きな問題です。私のようなfloatbufferを作成するとAndroid OpenGL OutOfMemory(バッファ割り当て)
:
FloatBuffer buf = ByteBuffer.allocateDirect(vertices.length * 4);
私は時々のOutOfMemoryエラーが発生します。これは私が描く唯一のバッファではない、私はまた色をする。頂点を描画するか、バッファにバッファに割り当てるより良い方法がありますか?毎回描画しますか? new ProgressTask(ctx).execute();
だけで解析し、配列を移入し
public PointCloud(String passedFileName, Context ctx) {
fileName = passedFileName;
header = new LAS_HeadParser(fileName);
numVertices = (int)header.numberOfPoints;
lasVertices = new float[numVertices*3];
lasColors = new float[numVertices*4];
intensity = new float[numVertices];
vbb = ByteBuffer.allocateDirect(lasVertices.length * 4);
cbb = ByteBuffer.allocateDirect(lasColors.length * 4);
new ProgressTask(ctx).execute();
}
public void setupBuffers(){
// a float is 4 bytes, therefore we multiply the number if
// vertices with 4.
vbb.order(ByteOrder.nativeOrder());
vertexBuffer = vbb.asFloatBuffer();
vertexBuffer.put(lasVertices);
vertexBuffer.position(0);
cbb.order(ByteOrder.nativeOrder());
colorBuffer = cbb.asFloatBuffer();
colorBuffer.put(lasColors);
colorBuffer.position(0);
}
public void draw(GL10 gl) {
//Log.d("Enter Draw", "*****************");
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);
}
コール:ここで私が使用していますいくつかの基本的な描画コードです。私は継続的にファイルを解析する余裕がない、それは時間がかかります。どのようなオプションがありますか?
どのコード行がOutOfMemoryエラーを投げていますか? – DoomGoober
@DoomGoober - vbb = ByteBuffer.allocateDirect(lasVertices.length * 4); – RedLeader