Hey Guys,

I've made some edits to my application but I'm pretty sure it crashing
is linked to my updating my Nexus One. I've included the error as well
as all code I think is relevant. Anyone got any ideas?

07-05 12:07:04.292: ERROR/AndroidRuntime(5751): FATAL EXCEPTION:
GLThread 11
07-05 12:07:04.292: ERROR/AndroidRuntime(5751):
java.lang.IllegalArgumentException: No config chosen
07-05 12:07:04.292: ERROR/AndroidRuntime(5751):     at
android.opengl.GLSurfaceView
$BaseConfigChooser.chooseConfig(GLSurfaceView.java:771)
07-05 12:07:04.292: ERROR/AndroidRuntime(5751):     at
android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:916)
07-05 12:07:04.292: ERROR/AndroidRuntime(5751):     at
android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:
1246)
07-05 12:07:04.292: ERROR/AndroidRuntime(5751):     at
android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)


public class GLCamTest extends Activity {
        private CamLayer mPreview;
        private GLLayer glView;
        static int counter=0;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        counter++;
    }

    /** Called when the activity is first created. */
    @Override
    public void onResume() {
        super.onResume();

 
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

        final Window win = getWindow();
        win.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

        // Hide the window title.
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        glView=new GLLayer(this);

                mPreview = new CamLayer(this, glView);

        setContentView(glView);
        addContentView(mPreview, new
LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    }
    protected void onPause() {
        super.onPause();
        if (counter>=2) {
                System.exit(0);
        }
    }
}

public class GLLayer extends GLSurfaceView implements
SurfaceHolder.Callback,
                Camera.PreviewCallback, Renderer {

        int onDrawFrameCounter=1;
        int[] cameraTexture;
        byte[] glCameraFrame=new byte[256*256]; //size of a texture
must be a power of 2
        FloatBuffer cubeBuff;
        FloatBuffer texBuff;

        public GLLayer(Context c) {
                super(c);

        this.setEGLConfigChooser(5, 6, 5, 8, 16, 0);
        this.setRenderer(this);
        this.getHolder().setFormat(PixelFormat.TRANSLUCENT);
        }

        public void onDrawFrame(GL10 gl) {
                onDrawFrameCounter++;

                gl.glEnable(GL10.GL_TEXTURE_2D);
                gl.glClear(GL10.GL_COLOR_BUFFER_BIT |
GL10.GL_DEPTH_BUFFER_BIT);

                bindCameraTexture(gl);

                gl.glLoadIdentity();
                GLU.gluLookAt(gl, 0, 0, 4.2f, 0, 0, 0, 0, 1, 0);

                gl.glRotatef(onDrawFrameCounter,1,0,0); //Rotate the
camera image
                gl.glRotatef((float)Math.sin(onDrawFrameCounter/
20.0f)*40,0,1,0); //Rotate the camera image
                gl.glRotatef((float)Math.cos(onDrawFrameCounter/
40.0f)*40,0,0,1); //Rotate the camera image

                gl.glNormal3f(0,0,1);
                gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
                gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 4, 4);
                gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 8, 4);
                gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,12, 4);
                gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,16, 4);
                gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,20, 4);
        }

        public void onSurfaceChanged(GL10 gl, int width, int height) {
                gl.glViewport(0, 0, width, height);

                float ratio = (float) width / height;
                gl.glMatrixMode(GL10.GL_PROJECTION);
                gl.glLoadIdentity();
                gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10);

                gl.glMatrixMode(GL10.GL_MODELVIEW);
                gl.glLoadIdentity();
                GLU.gluLookAt(gl, 0, 0, 4.2f, 0, 0, 0, 0, 1,
0);
        }

        public void onSurfaceCreated(GL10 gl, EGLConfig config) {
                gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
GL10.GL_FASTEST);

                gl.glClearColor(0, 0, 0, 0);
                gl.glEnable(GL10.GL_CULL_FACE);
                gl.glShadeModel(GL10.GL_SMOOTH);
                gl.glEnable(GL10.GL_DEPTH_TEST);

                cubeBuff = makeFloatBuffer(camObjCoord);
                texBuff =
makeFloatBuffer(camTexCoords);
                gl.glVertexPointer(3, GL10.GL_FLOAT, 0, cubeBuff);
                gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
                gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texBuff);
                gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
        }

        /**
         * Generates a texture from the black and white array filled
by the onPreviewFrame
         * method.
         */
        void bindCameraTexture(GL10 gl) {
                synchronized(this) {
                        if (cameraTexture==null)
                                cameraTexture=new int[1];
                        else
                                gl.glDeleteTextures(1, cameraTexture,
0);

                        gl.glGenTextures(1, cameraTexture, 0);
                        int tex = cameraTexture[0];
                        gl.glBindTexture(GL10.GL_TEXTURE_2D, tex);
                        gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0,
GL10.GL_LUMINANCE, 256, 256, 0, GL10.GL_LUMINANCE,
GL10.GL_UNSIGNED_BYTE, ByteBuffer.wrap(glCameraFrame));
                        gl.glTexParameterf(GL10.GL_TEXTURE_2D,
GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
                }
        }

        /**
         * This method is called if a new image from the camera
arrived. The camera
         * delivers images in a yuv color format. It is converted to a
black and white
         * image with a size of 256x256 pixels (only a fraction of the
resulting image
         * is used). Afterwards Rendering the frame (in the main loop
thread) is started by
         * setting the newFrameLock to true.
         */
        public void onPreviewFrame(byte[] yuvs, Camera camera)
{
             int bwCounter=0;
             int yuvsCounter=0;
             for (int y=0;y<160;y++) {
                  System.arraycopy(yuvs, yuvsCounter, glCameraFrame,
bwCounter, 240);
                  yuvsCounter=yuvsCounter+240;
                  bwCounter=bwCounter+256;
             }
        }

        FloatBuffer makeFloatBuffer(float[] arr) {
                ByteBuffer bb =
ByteBuffer.allocateDirect(arr.length*4);
                bb.order(ByteOrder.nativeOrder());
                FloatBuffer fb = bb.asFloatBuffer();
                fb.put(arr);
                fb.position(0);
                return fb;
        }

        final static float camObjCoord[] = new float[] {
                                // FRONT
                                 -2.0f, -1.5f,  2.0f,
                                  2.0f, -1.5f,  2.0f,
                                 -2.0f,  1.5f,  2.0f,
                                  2.0f,  1.5f,  2.0f,
                                 // BACK
                                 -2.0f, -1.5f, -2.0f,
                                 -2.0f,  1.5f, -2.0f,
                                  2.0f, -1.5f, -2.0f,
                                  2.0f,  1.5f, -2.0f,
                                 // LEFT
                                 -2.0f, -1.5f,  2.0f,
                                 -2.0f,  1.5f,  2.0f,
                                 -2.0f, -1.5f, -2.0f,
                                 -2.0f,  1.5f, -2.0f,
                                 // RIGHT
                                  2.0f, -1.5f, -2.0f,
                                  2.0f,  1.5f, -2.0f,
                                  2.0f, -1.5f,  2.0f,
                                  2.0f,  1.5f,  2.0f,
                                 // TOP
                                 -2.0f,  1.5f,  2.0f,
                                  2.0f,  1.5f,  2.0f,
                                 -2.0f,  1.5f, -2.0f,
                                  2.0f,  1.5f, -2.0f,
                                 // BOTTOM
                                 -2.0f, -1.5f,  2.0f,
                                 -2.0f, -1.5f, -2.0f,
                                  2.0f, -1.5f,  2.0f,
                                  2.0f, -1.5f, -2.0f,
                        };
                        final static float camTexCoords[] = new
float[] {
                                // Camera preview
                                 0.0f, 0.0f,
                                 0.9375f, 0.0f,
                                 0.0f, 0.625f,
                                 0.9375f, 0.625f,

                                // BACK
                                 0.9375f, 0.0f,
                                 0.9375f, 0.625f,
                                 0.0f, 0.0f,
                                 0.0f, 0.625f,
                                // LEFT
                                 0.9375f, 0.0f,
                                 0.9375f, 0.625f,
                                 0.0f, 0.0f,
                                 0.0f, 0.625f,
                                // RIGHT
                                 0.9375f, 0.0f,
                                 0.9375f, 0.625f,
                                 0.0f, 0.0f,
                                 0.0f, 0.625f,
                                // TOP
                                 0.0f, 0.0f,
                                 0.9375f, 0.0f,
                                 0.0f, 0.625f,
                                 0.9375f, 0.625f,
                                // BOTTOM
                                 0.9375f, 0.0f,
                                 0.9375f, 0.625f,
                                 0.0f, 0.0f,
                                 0.0f, 0.625f
                        };

}

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