Hi,

you have to use direct buffers with native byte ordering for this to
work. Instead of

testBuffer = IntBuffer.wrap( testArray );

you have to do a bit more work like this:

ByteBuffer buffer = ByteBuffer.allocateDirect( testArray.length * 4 );
buffer.order( ByteOrder.nativeOrder() );
testBuffer = buffer.asIntBuffer();
testBuffer.put( testArray );
testBuffer.flip();

I didn't test this but wrote it from the top of my head. It should
work though.

hth,
Mario

On 17 Mrz., 01:23, ac <[email protected]> wrote:
> Hello,
>
> I have experienced some trouble using VBOs, since the method
> glBufferData crashes when I try to copy data to the vertex buffer.
> Below is the smallest snippet of code that I found to generate the
> crash:
>
> int numVert = 32;
> GL11 gl11 = (GL11)gl;
> testArray = new int[numVert * 3];
> testBuffer = IntBuffer.wrap(testArray);
> gl11.glGenBuffers(1, testID, 0);
> gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, testID[0]);
> final int siz = testBuffer.capacity() * Integer.SIZE;
> gl11.glBufferData(GL11.GL_ARRAY_BUFFER, siz, testBuffer,
> GL11.GL_STATIC_DRAW);
> gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);
>
> testArray, testBuffer and testID are members of the class containing
> this code, declared as follows:
>
> int[] testArray;
> IntBuffer testBuffer;
> int[] testID = {0};
>
> I tried this code in several OpenGL applications which don't show any
> problem otherwise.
>
> The crash occurs specifically at the glBufferData() method call. If
> numVert is set to zero, then the crash doesn't occur.
>
> Any comments will be greatly appreciated.
>
> Thanks,
> ac

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to