Tank2005
Tank2005

Reputation: 909

Substitution of queueEvent when not using GLSurfaceView

When controlling OpenGL from other threads, if it is GLSurfaceView, we use queueEvent(). Then, in cases where OpenGL is created on SurfaceView (use eglCreateWindowSurface, eglMakeCurrent, etc.), how should I implement for operating OpenGL from other threads?

Upvotes: 1

Views: 917

Answers (1)

Dalinaum
Dalinaum

Reputation: 1162

You can implement your own queueEvent.

  1. Make a queue. (ArrayList<Runnable> mQueue)
  2. queueEvent() adds Runnable instances to this queue(mQueue).
  3. Your SurfaceView's rendering thread pops event from the queue.
  4. invokes event.run()

Use locks (synchronized or explicit locks) to avoid problems.

In GLSurfaceView, there are 3 and 4 steps in a loop of GLThread and mQueue is protected by synchronized blocks.

see also: GLSurfaceView

PS: sorry for my poor english.

Upvotes: 1

Related Questions