Paul, I forgot the assignment, mVertexBuffer=vbb; :)
Yes, it crashes because as I suspect, GL's JNI code can't deal with
XXXBuffer wrapping non-direct ByteBuffer. Thats why you should avoid
using anything except ByteBuffer when you use allocate(). Luckily
ByteBuffer has all the needed methods, putFloat, putInt, etc.


Dmitry

PS. As my investigations showed, this trick eliminates *some* of the
object allocations, but not all. For other allocations you should
check your code. Simple System.gc() on top of onDrawFrame() will tell
you how many objects were created in the last frame.


On 5 авг, 20:30, Paul Thomas
<dr.paul.thomas.android.st...@googlemail.com> wrote:
> Dimitry,
>
> 2009/8/5 Dmitry.Skiba <dmitry.sk...@gmail.com>:
>
>
>
> > should be
>
> >        ByteBuffer vbb = ByteBuffer.allocate(vertices.length*4);
> >        vbb.order(ByteOrder.nativeOrder());
> >        for (int vertex: vertices) {
> >                mVertexBuffer.putInt(vertex);
> >        }
> >        mVertexBuffer.position(0);
>
> Where are you getting mVertexBuffer from?  ByteBuffer mVertexBuffer =
> ByteBuffer.allocate(vertices.length*4); ?
>
> I tried switching to allocate from allocateDirect, but it crashes :-(
>
> If you are using integers in your vertex buffer, how are you setting
> up the vertex pointer?
>
> Thanks
>
> Paul.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to