[android-developers] Re: Crash in glDrawElements() using VBOs just after glBufferData()

2010-02-26 Thread Viktor Linder
Sure! It doesn't really do very much, just a wrapper around a buffer. frame_reset() is called once each frame. public class DynamicBuffer { private static final int BUFFER_SIZE = 32*1024; private static final int SCRATCH_SIZE = 32*1024; private static int _p = 0;

[android-developers] Re: Crash in glDrawElements() using VBOs just after glBufferData()

2010-02-25 Thread Twisted Ware
Robert has a very good point, but I also think you can expect the GL implementation to allow the buffers to get garbage collected before they have been used. You allocate the buffer in a scope and then pass that buffer pointer into the GL system - and then toss the memory away. Unless you flush

[android-developers] Re: Crash in glDrawElements() using VBOs just after glBufferData()

2010-02-25 Thread Bob Kerns
This would be a bug in the JNI code, which is responsible for protecting from the GC any and all memory which it is using. Only it can do so, because only it knows when it is done. That's unlikely, though. The the JNI API makes it impossible to get your JNI code to get its hands on the data

[android-developers] Re: Crash in glDrawElements() using VBOs just after glBufferData()

2010-02-25 Thread Viktor Linder
To clarify, in the original example, no buffer is allocated. The call to DynamicBuffer.allocate() simply moves a position in a previously allocated buffer which is filled each frame - ie. an arena allocator. DynamicBuffer.deallocate_last(size) simply moves the position back without destroying any

[android-developers] Re: Crash in glDrawElements() using VBOs just after glBufferData()

2010-02-25 Thread Robert Green
Actually, let me clear something technical up. I just realized that the OpenGL native side is using GetPrimitiveArrayCritical and not GetDirectBufferAddress. I'm not sure why they decided to take that route but I'm sure there was a good reason for it. The fact of the matter is that while GPAC

[android-developers] Re: Crash in glDrawElements() using VBOs just after glBufferData()

2010-02-25 Thread Robert Green
Let me explain something. Using directly allocated NIO buffers is a DIRECT LINK between Java and native. The pointer you get from (void *)GetDirectBufferAddress points to the exact memory that the Java buffer is using. The memory is not managed in Java on the heap like everything else. This is

[android-developers] Re: Crash in glDrawElements() using VBOs just after glBufferData()

2010-02-25 Thread Robert Green
Viktor, Would you be willing to show a bit of your DynamicBuffer code so I can see what it's doing? It's hard for me to help when there's a black box in the middle. On Feb 25, 1:41 pm, Viktor Linder linder.vik...@gmail.com wrote: To clarify, in the original example, no buffer is allocated. The

[android-developers] Re: Crash in glDrawElements() using VBOs just after glBufferData()

2010-02-24 Thread Clankrieger
As what I am aware of, VBOs do not need direct buffers (and indirect buffers might be handled faster), but this is just a detail. I also tried GL_FIXED but it did not make much difference for me. I assume that it gives performance gains only if you have a) static data that is converted to fixed

[android-developers] Re: Crash in glDrawElements() using VBOs just after glBufferData()

2010-02-24 Thread Robert Green
The OpenGL wrappers take the data pointer passed in by those sorts of methods using native GetDirectBufferAddress of the corresponding type (int or float) and pass that pointer into the native gl method. That only works correctly if it's a direct buffer. I just checked android_opengl_GLES10.cpp

[android-developers] Re: Crash in glDrawElements() using VBOs just after glBufferData()

2010-02-16 Thread Robert Green
You're probably pointing something to some bad memory location somewhere. I know you didn't post all of your real code so I can't really say for sure but it looks to me like you may be doing something wrong with your buffers. Here's how I do it: -- Load -- GL11 gl11 =

[android-developers] Re: Crash in glDrawElements() using VBOs just after glBufferData()

2010-02-16 Thread Viktor Linder
As you say, the most likely explanation is that I have a bad pointer being used somewhere. The thing is I have gone over this code a bunch of times and tried lots of different checks and I just can't find what's wrong. Do you have any pointers on ways to debug the crash in the GL library? I