1

I was wondering if there is a way to receive callbacks inside the OpenGL thread (meaning NO inter-thread communication). I've tried to use the Handler, but I it didn't work, as can be seen here. Also:

Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

I have some custom Animations in OpenGL which can be initialized. Now I want to receive some sort of callback after the animation is finished. The AsyncTask would not be the best choice for my purpose, since I am not able to call return properly in my scenario. The Handler would have been a good choice - each element would have had a reference to the Handler and simply send some message with valuable information when the animation is finished.

Is there another way to receive callbacks within the OpenGL thread?

Community
  • 1
  • 1
  • Should _GLSurfaceView.queueEvent(Runnable)_ be close enough ; http://developer.android.com/reference/android/opengl/GLSurfaceView.html#queueEvent(java.lang.Runnable) ? – harism Jun 09 '14 at 22:01
  • Thanks for your quick reply! I'm already using queueEvent to access the GL thread from outside, but how can I achieve callbacks within the GL thread? – user3465898 Jun 09 '14 at 22:07
  • So, the case is you want to send notification from GLSurfaceView.Renderer methods back to UI thread? – harism Jun 09 '14 at 22:21
  • No, I have a coordinator inside the GL Renderer which should invoke another animation after a previous animation has finished. That should happen automatically, no need to handle anything in the UI thread - it should work in the GL thread exclusively. – user3465898 Jun 09 '14 at 22:26
  • 1
    And is there a reason why you cannot implement an interface to handle these events in your Renderer, which could be passed to each element? – harism Jun 09 '14 at 22:32
  • Sounds like a neat idea, I'll take a look into that! – user3465898 Jun 09 '14 at 22:37

0 Answers0