convert Vertex buffer to Vertex array

2019-02-19 05:49发布

I'm working on OpenGL program and I must calculate a bounding box . I made the code to do it but I can't get vertexes coordinations from vertex buffer . Someone can explain me an easy way to get data from vertex buffer? I'm using Java for android and OpenGL es

2条回答
放荡不羁爱自由
2楼-- · 2019-02-19 06:13

If you use OpenGL ES 3.0 or later, you can use glMapBufferRange() to access buffer data directly. See the man page for details about the functionality, and the GLES30 documentation for details about the Java bindings in Android.

I don't think there's any reasonable way to do this in ES 2.0. I could think of absolutely awful ways, but I would feel bad to steer you in that direction. Well, for completeness, but please do not do this: You could render something that ends up leaving the vertex data in a render target, and read it back with glReadPixels().

If you need frequent access to the vertex data in your own code, it will most likely work better if you keep a copy of it. You already had the data when you called glBufferData(). If you're currently throwing it away after the glBufferData() call, simply keep it around, and use it whenever you need access to vertex data.

查看更多
小情绪 Triste *
3楼-- · 2019-02-19 06:17

i've found how to do it

    mFb= (FloatBuffer)    vb.getData(UlVertexBuffer.VERTEX_FIELD_POSITION).position(0);
    getmFloatArray(mFb);
    mSb= (ShortBuffer) ib.getData();
    getmShortArray(mSb);
查看更多
登录 后发表回答