I have made a Open GL program using TriangleRenderer in ApiDemos. I
made a button and I want to turn off GLSurfaceView when I click a
button. So firstly I addView GLSurfaceView in LinearLayout, and I
removeView GLSurfaceView when I click a button.
But when I removeView a GLSurfaceView, emulator was freezed printing a
LOG (
SurfaceComposerClient : lock_layer timed out (is the CPU pagged ). I
think some method call need before removing a GLSurfaceView. but I
don't know exactly.


package com.gltest;

import android.app.Activity;
import android.os.Bundle;
import android.opengl.GLSurfaceView;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

public class Hello extends Activity {
private LinearLayout mLayout;
private MyGLSurfaceView mGLSurface;
private Button mButton;
@Override public void
onCreate (Bundle savedInstanceState) {
     super.onCreate (savedInstanceState);

     mLayout = new LinearLayout (this);
     mLayout.setOrientation (LinearLayout.VERTICAL);

     mGLSurface = new MyGLSurfaceView(this);
     mLayout.addView (mGLSurface,
     new LinearLayout.LayoutParams (
           LinearLayout.LayoutParams.FILL_PARENT,
           LinearLayout.LayoutParams.FILL_PARENT,
           1.0f));

    mButton = new Button (this);
    mLayout.addView (mButton,
    new LinearLayout.LayoutParams (
           LinearLayout.LayoutParams.WRAP_CONTENT,
           LinearLayout.LayoutParams.WRAP_CONTENT,
           1.0f));
    mButton.setOnClickListener (new View.OnClickListener () {
          public void onClick (View v) {
                  mGLSurface.onPause ();
                  mLayout.removeView (mGLSurface);
          }
});

setContentView (mLayout);
}
}
package com..gltest;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.opengl.GLSurfaceView;
import android.widget.LinearLayout;

public class MyGLSurfaceView extends LinearLayout {
static final String TAG = "MyGLSurfaceView";
private GLSurfaceView mGLSurface;
public MyGLSurfaceView (Context context) {
this (context, null);
}

public MyGLSurfaceView (Context context, AttributeSet attrs) {
super (context, attrs);

mGLSurface = new GLSurfaceView (context);
mGLSurface.setEGLConfigChooser (false);
mGLSurface.setRenderer (new TriangleRenderer (context));

addView (mGLSurface);
}

@Override protected void
onDetachedFromWindow () {
     Log.v (TAG, "onDetatchedFromWindow");
     mGLSurface.onPause ();
}

public void onPause () {
     mGLSurface.onPause ();
}
}

SurfaceComposerClient : lock_layer timed out (is the CPU pagged?)



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