windkiosk
windkiosk

Reputation: 490

Render UI component in GLSurfaceView

I met a problem with OpenGL integration. The requirement is to show a complex UI component on top of map (rendered by OpenGL engine). And this UI component should pin to specific point while map is moving.

One straight forward solution is to render the complex UI component by OpenGL Engine. But it takes a lot of effort to layout/render and event handling.

Another way I come up is to put an overlay UI component on top of OenpGL map, and make it moving while map is panning. As you know, for GLSurfaceView, the rendering happens in a separate thread while UI component renders in main UI thread. I can make it functionally work. But it always be a little shift between UI component and map while panning since they are actually running in two thread.

Do you have any idea to overcome this problem?

Two directions I am thinking are:

  1. any way to render OpenGL map in UI thread?
  2. How to render a common UI component in GL thread.

Upvotes: 0

Views: 321

Answers (1)

Onur
Onur

Reputation: 5625

For 1, probably not.

As for 2, you can't touch any ui component outside of ui-thread.

Your problem is very much like Vsync-Mouse lag problems. And as far as my limited knowledge about it, they solve that problem(well, not solve completely but...) by keeping last N location of the mouse and predicting the N+1 th one by extrapolation. You can implement something like this.

I also suggest you to look at multi-threaded rendering stuff. As literally this is what you are trying to do.

Upvotes: 1

Related Questions