>From a look at some reference you need to do

put(data, offset, length-offset);
as it's not really a length but a count of the number of items to
read.
http://java.sun.com/j2se/1.4.2/docs/api/java/nio/IntBuffer.html#put(int[],
int, int)

On Jun 16, 9:24 pm, djp <david.perou...@gmail.com> wrote:
> In a process of switching from indirect to direct buffers for OpenGL
> geometry specification I've found a problem with the following
> function in java.nio.IntBuffer class:
>
> IntBuffer put(int[] src, int off, int len)
>
> this function is supposed to do a bulk transfer of int data from the
> given array starting at the specified offset. It should be an
> optimized version of the following code:
>
> for (int i = 0; i < len; i++) {
>     buffer.put(src[off + i]);
>
> }
>
> The problem is that the bulk transfer method does not work properly
> with non-zero offset when the IntBuffer is created from a direct
> ByteBuffer. I'll try to demonstrate the problem using a code sample:
>
> ByteBuffer directBuffer = ByteBuffer.allocateDirect(size).order
> (ByteOrder.nativeOrder());
> IntBuffer intBuffer = directBuffer.asIntBuffer();
>
> // does *not* work with offset > 0
> intBuffer.put(data, offset, length);
>
> // does work with offset > 0
> for (int i = 0; i < length; i++) {
>     intBuffer.put(data[offset + i]);
>
> }
>
> I'm using G1 with an official 1.5 firmware.
>
> Regards,
> David
--~--~---------~--~----~------------~-------~--~----~
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