Displaying the ProgressDialog from the OpenGL thread.

by Dmitriy Shilonosov » Wed, 12 May 2010 15:13:07 GMT


Sponsored Links
 Hi!

Does anyone have expirience with opengl-ui-opengl threading
interraction?

I'am developing a small opengl application. I'am a little bit confused
with separate opengl thread...
Currently, my application is logically separated in two parts - the
controlling one and the rendering one.
The controlling part interracts with user - accepting user input,
changing activities, dealing with files and so on.
The rendering part - just render everything it should.

Ok, so when I need to load new texture to opengl (unfortunatelly its
large and I cant reduce its size), I'd like to show a ProgerssDialog
dialog.
Trying to show it from the open gl thread brings me an exception:
"Can't create handler inside thread that has not called
Looper.prepare()".
Because the initiator of loading is in the ui thread (for example -
user selected a menu option), I'am opening the dialog, adding the load
Runnable to stack on Runnables that will be called in
Render.onDrawFrame and passing there a callback that will be executed
after texture is loaded.

Like this:

//ui

public class Controller extends Activity {

  ...

  protected void loadTexture(InputStream aStream) {
    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setTitle("Please wait...");
    dialog.setMessage("Loading texture");
    dialog.show();
    _renderer.loadTexture(_stream, new Runnable() {
      @Override
      public void run() {
        dialog.dismiss();
      }});
  }

  ...
}

//gl

public class SceneRenderer implements Renderer {
  @Override
  public void onDrawFrame(GL10 aGL) {
    this.runGLRunnables(aGL);
  }

  public void loadTexture(final InputStream aStream, final Runnable
aCallback) {
    _glRunnablesStack.push(new GLRunnable() {
    @Override
    public void run(GL10 aGL) {
      SceneRenderer.this.doLoadTexture(aStream);
      aCallback.run();
    };});
  }
}

So the question is: Is there any way to show ProgressDialog from the
opengl thread?
I need exactly the ProgressDialog. There is a way to show some
picture, previously loaded, like a splashscreen using opengl renderer,
but I'd like to avoid it.

Thanks!

--



Other Threads

1. is there any plans to release c++ version of andriod

is there any plans to release c++ version of andriod
--~--~---------~--~----~------------~-------~--~----~

2. Progmatic Selection of List Item

Hi,

in ListActivity UI, how to pre select an item in the list, so that as
soon as the list gets displayed, that item would be selected.

Regards,
Nagendra
--~--~---------~--~----~------------~-------~--~----~

3. Any one tried uisng mediaplayer example ,I ma unable to play video file from local directory

4. need help in debugging/making sense of this code

5. MediaPlayer example: Has anyone been able to stream an .mp4 file yet?

6. style and the color of the separator

7. Autocomplete and filtering issue