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. Double quotes in resources?

I'm probably missing something obvious, but for some reason I don't
manage to put a string with double quotes in a resources file.

strings.xml:
   <resources>
      <string name="message_empty_folder">Folder &quot;%s&quot; is
empty.</string>
   </resources>

LIstFolderActivity.java:
   String format = getResources().getString
(R.string.message_empty_folder);
   System.out.println(format);

Log output:
   Folder %s is empty.

What's eating up the double quotes?

Thanks in advance,
Markus

-- 

2. polylines or polygons on map

Has anyone sucessfully implemented a polyline or polygon overlay on
the Android Maps?


-- 

3. Wallpaper

4. android sources in eclipse and slow 'refreshing external folders'

5. Permission to use bindAppWidgetId()

6. Is it possible to get raw events tuples for keyboard, touch screen etc?

7. Will the droid with andoid 2.0 get updates that give us more home screens>?