Author
Topic: To another View and back? (Read 3041 times)

Has anybody an idea how to replace the GLSurfaceView with another View and make it render again after the other View is done?

What i'm trying to do, is to open another View (defined in a layout.xml file) when pressing OK (on the phone). This actually works fine. When i press OK, i set the content view to the new view, the GLSurfaceView obviously stops doing rendering and i can use the GUI in the new View. After pressing a button, i want to return to the GLSurfaceView and continue rendering. It tried this by doing another setContentView(...), this time with the GLSurfaceView. This works to a degree. The GUI View goes away, the GLSurfaceView thread requests and gets the gl surface again (judging from the logs) and...nothing happens. The onDrawFrame()-method never gets called again!? Even if i enqueue something to be executed in the gl thread, this never happens.

I tried several other things like playing around with setVisibility(...) and stuff, but to no avail. I couldn't find any example in the sources and wasn't lucky on the net either.

I did some further debugging and obviously, setContentView() isn't the way to go. When doing this, the render thread gets stopped and never starts again. I can avoid this by overriding one method in GLSurfaceView, but then, the surface gets created again after returning to the render thread, which also isn't what i want. There has to be some other solution...

final View v2=this.findViewById(R.id.mylayout);mGLView.setVisibility(View.INVISIBLE);v2.setVisibility(View.VISIBLE);

...and when i'm done in the GUI View, i'm doing this in reverse...

My main fault before was, that i expected the View to be available via findViewById() in any case, but i always got "null", which was why i couldn't activate my GUI view...simply because i couldn't access it. The trick is to set the whole layout defined in the main.xml as content view. If you don't do this, you can't access neither the GLSurfaceView nor the GUI View.