IntBuffer, ByteBuffer, ByteOrder and GLES20 for Android
<p>I have three fragments of code which should behave alike, or maybe not, I'm still studying how OpenGL ES is bound to Java for Android. However I really would like to know why fragment  B and C are behaving differently:</p>

<p>The following (A) works:</p>

<pre><code>        ByteBuffer bb = ByteBuffer.allocateDirect(8);
        bb.order(ByteOrder.nativeOrder());
        IntBuffer ib = bb.asIntBuffer();
        Log.d("Info", "Generating buffers...");
        GLES20.glGenBuffers(2, ib);
        Log.d("Info", "Done!");
        int buff1 = ib.get();
        int buff2 = ib.get();
        Log.d("A) buff1", String.format("%d", buff1));
        Log.d("A) buff2", String.format("%d", buff2));
</code></pre>

<p>The following (B) DOES NOT work, and causes SIGSEGV on glGenBuffers; note that the only difference with the previous is in the allocate call instead of allocateDirect:</p>

<pre><code>        ByteBuffer bb = ByteBuffer.allocate(8);
        bb.order(ByteOrder.nativeOrder());
        IntBuffer ib = bb.asIntBuffer();
        Log.d("Info", "Generating buffers...");
        GLES20.glGenBuffers(2, ib);
        Log.d("Info", "Done!");
        int buff1 = ib.get();
        int buff2 = ib.get();
        Log.d("B) buff1", String.format("%d", buff1));
        Log.d("B) buff2", String.format("%d", buff2));
</code></pre>

<p>The following (C) works, which really surprised me because it is again a call to allocate and not to allocateDirect:</p>

<pre><code>        IntBuffer ib = IntBuffer.allocate(2);
        Log.d("Info", "Generating buffers...");
        GLES20.glGenBuffers(2, ib);
        Log.d("Info", "Done!");
        int buff1 = ib.get();
        int buff2 = ib.get();
        Log.d("C) buff1", String.format("%d", buff1));
        Log.d("C) buff2", String.format("%d", buff2));
</code></pre>

<p>With the word "works" I mean that there are no errors showing up in the log and buff1 and buff2 get positive "reasonable" values, like 70001, 140002, or 210004, which look like they may be names.</p>
