Skip to content Skip to sidebar Skip to footer

Convert Vertex Buffer To Vertex Array

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 e

Solution 1:

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.


Solution 2:

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);

Post a Comment for "Convert Vertex Buffer To Vertex Array"