Lance,

This looks like issue 6109
http://code.google.com/p/android/issues/detail?id=6109

Which hasn't been updated but the good news is that I tried your code
with the master branch and it's been fixed. Hopefully it'll make the
next update to 2.1

-Dario

On Jan 11, 4:31 am, Lance Nanek <lna...@gmail.com> wrote:
> I'm getting exceptions when I try to use an interleaved buffer in
> OpenGL with android.opengl.GLLogWrapper. Has anyone else run into
> this?
>
> Everything works fine if I disable GLLogWrapper by removing this line:
> mGLSurfaceView.setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR |
> GLSurfaceView.DEBUG_LOG_GL_CALLS);
>
> Replacing that line with this also works fine:
> mGLSurfaceView.setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR);
>
> What I'm doing seems fine to OpenGL, just not GLLogWrapper. Using
> position() on Buffer to specify an offset is outlined 
> here:http://java.sun.com/javame/reference/apis/jsr239/
>
> Same results on my Android 1.6 G1 and the emulator running an Android
> 2.0.1 AVD. Stack trace from 2.0.1:
> V/GLSurfaceView(  226): glClear(GL_COLOR_BUFFER_BIT);
> I/ARMAssembler(   54): generated
> scanline__00000077:03010104_00000004_00000000 [ 22 ipp] (41 ins) at
> [0x504b80:0x504c24] in 679333 ns
> W/dalvikvm(  226): threadid=15: thread exiting with uncaught exception
> (group=0x4001b188)
> E/AndroidRuntime(  226): Uncaught handler: thread GLThread 8 exiting
> due to uncaught exception
> E/AndroidRuntime(  226): java.lang.IndexOutOfBoundsException
> E/AndroidRuntime(  226):        at java.nio.IntToByteBufferAdapter.get
> (IntToByteBufferAdapter.java:155)
> E/AndroidRuntime(  226):        at android.opengl.GLLogWrapper.doArrayElement
> (GLLogWrapper.java:1105)
> E/AndroidRuntime(  226):        at android.opengl.GLLogWrapper.doElement
> (GLLogWrapper.java:1126)
> E/AndroidRuntime(  226):        at android.opengl.GLLogWrapper.glDrawArrays
> (GLLogWrapper.java:1520)
> E/AndroidRuntime(  226):        at
> name.nanek.test.interleavedbuffer.TestInterleavedBuffer$1.onDrawFrame
> (TestInterleavedBuffer.java:75)
> E/AndroidRuntime(  226):        at android.opengl.GLSurfaceView
> $GLThread.guardedRun(GLSurfaceView.java:1112)
> E/AndroidRuntime(  226):        at android.opengl.GLSurfaceView$GLThread.run
> (GLSurfaceView.java:971)
> I/Process (   54): Sending signal. PID: 226 SIG: 3
> I/dalvikvm(  226): threadid=7: reacting to signal 3
>
> I can also get a slightly different exception if I modify the code to
> slice the buffer at zero and position the slice:
> V/GLSurfaceView(26498): glClear(GL_COLOR_BUFFER_BIT);
> W/dalvikvm(26498): threadid=15: thread exiting with uncaught exception
> (group=0x4001da28)
> E/AndroidRuntime(26498): Uncaught handler: thread GLThread exiting due
> to uncaught exception
> E/AndroidRuntime(26498): java.nio.BufferUnderflowException
> E/AndroidRuntime(26498):        at java.nio.IntToByteBufferAdapter.get
> (IntToByteBufferAdapter.java:148)
> E/AndroidRuntime(26498):        at android.opengl.GLLogWrapper.toByteBuffer
> (GLLogWrapper.java:977)
> E/AndroidRuntime(26498):        at android.opengl.GLLogWrapper.access$000
> (GLLogWrapper.java:38)
> E/AndroidRuntime(26498):        at android.opengl.GLLogWrapper
> $PointerInfo.bindByteBuffer(GLLogWrapper.java:3042)
> E/AndroidRuntime(26498):        at android.opengl.GLLogWrapper.bindArrays
> (GLLogWrapper.java:1147)
> E/AndroidRuntime(26498):        at
> android.opengl.GLLogWrapper.startLogIndices(GLLogWrapper.java:1166)
> E/AndroidRuntime(26498):        at android.opengl.GLLogWrapper.glDrawArrays
> (GLLogWrapper.java:1518)
> E/AndroidRuntime(26498):        at
> name.nanek.test.interleavedbuffer.TestInterleavedBuffer$1.onDrawFrame
> (TestInterleavedBuffer.java:75)
> E/AndroidRuntime(26498):        at android.opengl.GLSurfaceView
> $GLThread.guardedRun(GLSurfaceView.java:955)
> E/AndroidRuntime(26498):        at android.opengl.GLSurfaceView$GLThread.run
> (GLSurfaceView.java:887)
> I/Process (   76): Sending signal. PID: 26498 SIG: 3
> I/dalvikvm(26498): threadid=7: reacting to signal 3
>
> Here's some minimal sample code for the first case that uses robot.png
> from the API Demos. Paste bin version:http://pastebin.com/f3eb6b1d3
>
> Inline version:
> package name.nanek.test.interleavedbuffer;
>
> import java.nio.ByteBuffer;
> import java.nio.ByteOrder;
> import java.nio.IntBuffer;
>
> import javax.microedition.khronos.egl.EGLConfig;
> import javax.microedition.khronos.opengles.GL10;
>
> import android.app.Activity;
> import android.graphics.Bitmap;
> import android.graphics.BitmapFactory;
> import android.opengl.GLSurfaceView;
> import android.opengl.GLUtils;
> import android.opengl.GLSurfaceView.Renderer;
> import android.os.Bundle;
>
> public class TestInterleavedBuffer extends Activity {
>
>         private static final boolean LOG = true;
>
>         private static final boolean AUTOSLICE = false;
>
>         //One in fixed point.
>         private static final int F1 = 1 << 16;
>
>         //Number of vertexes needed for a square made using a triangle strip.
>         private static final int VERTEX_COUNT = 4;
>
>         //3 position values and 2 texture values per vertex.
>         private static final int INTS_PER_VERTEX = 5;
>
>         //Byte distance between vertexes.
>         private static final int STRIDE = INTS_PER_VERTEX * Integer.SIZE /
> Byte.SIZE;
>
>         //Total number of bytes.
>         private static final int BUFFER_BYTES = VERTEX_COUNT * STRIDE;
>
>     private final IntBuffer buffer = ByteBuffer
>                 .allocateDirect(BUFFER_BYTES)
>                 .order(ByteOrder.nativeOrder())
>                 .asIntBuffer();
>         {
>                 buffer.put(new int[] {
>                         0, F1, 0, 0, 0,//Top left.
>                         0, 0, 0, 0, F1,//Bottom left.
>                         F1, F1, 0, F1, 0,//Top right.
>                         F1, 0, 0, F1, F1//Bottom right.
>                 });
>                 buffer.rewind();
>         }
>
>     private GLSurfaceView mGLSurfaceView;
>
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>
>         mGLSurfaceView = new GLSurfaceView(this);
>         setContentView(mGLSurfaceView);
>
>         if ( LOG ) {
>                 //Enabling this causes an exception.
>                 mGLSurfaceView.setDebugFlags
> (GLSurfaceView.DEBUG_CHECK_GL_ERROR |
> GLSurfaceView.DEBUG_LOG_GL_CALLS);
>         } else {
>                 //This works fine.
>                 mGLSurfaceView.setDebugFlags
> (GLSurfaceView.DEBUG_CHECK_GL_ERROR);
>         }
>
>         mGLSurfaceView.setRenderer(new Renderer() {
>
>                         @Override
>                         public void onDrawFrame(GL10 gl) {
>                         gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
>                         gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0,
> VERTEX_COUNT);
>                         }
>
>                         @Override
>                         public void onSurfaceChanged(GL10 gl, int width, int 
> height) {
>                         gl.glViewport(0, 0, width, height);
>                         gl.glMatrixMode(GL10.GL_PROJECTION);
>                         gl.glLoadIdentity();
>                         gl.glOrthox(0, F1, 0, F1, 0, F1);
>                         gl.glMatrixMode(GL10.GL_MODELVIEW);
>                         }
>
>                         @Override
>                         public void onSurfaceCreated(GL10 gl, EGLConfig 
> config) {
>                         gl.glColor4x(F1, F1, F1, F1);
>                         gl.glClearColorx(F1, F1, F1, F1);
>                         gl.glEnable(GL10.GL_TEXTURE_2D);
>                         gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
>                         gl.glVertexPointer(3, GL10.GL_FIXED, STRIDE, buffer);
>                         gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
>
>                         //Skip first 3 position values to get to texture
> coordinates.
>                         buffer.position(3);
>
>                         //Both options here cause an exception in 
> GLLogWrapper.
>                         if ( AUTOSLICE ) {
>                                 gl.glTexCoordPointer(2, GL10.GL_FIXED, 
> STRIDE, buffer);
>                         } else {
>                                 gl.glTexCoordPointer(2, GL10.GL_FIXED, 
> STRIDE, buffer.slice
> ());
>
>                         }
>                         buffer.rewind();
>
>                         int[] textures = new int[1];
>                         gl.glGenTextures(1, textures, 0);
>                         gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
>                         gl.glTexParameterf(GL10.GL_TEXTURE_2D,
> GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
>                         gl.glTexParameterf(GL10.GL_TEXTURE_2D,
> GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_NEAREST);
>                         Bitmap bitmap = 
> BitmapFactory.decodeResource(getResources(),
> R.drawable.robot);
>                         GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
>                         bitmap.recycle();
>                         }
>
>         });
>     }
>
>     @Override
>     protected void onResume() {
>         super.onResume();
>         mGLSurfaceView.onResume();
>     }
>
>     @Override
>     protected void onPause() {
>         super.onPause();
>         mGLSurfaceView.onPause();
>     }
>
>
>
> }

-- 
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