Hi all,

I'm trying to find the best way to implement a "loading screen" when
using a GLSurfaceView.

Basically the situation is this:

The app (game) loads a bunch of textures into VRAM when the GL surface
is created (onSurfaceCreated), however these textures are only for the
current "level" of the game.  When the player reaches the end of the
level I need to remove these textures from VRAM and load the new ones.

Previously (during development) each level was a complete load/unload
of the Activity, which works fine, however this creates a bunch of
unnecessary overhead as I don't need to reload the world for a simple
level progression.  So I have been experimenting with different ways
to overlay a standard view (which is my "loading" screen) over the top
of the GLSurfaceView while the level data is loaded.

This has created some problems for me:

1. Because the GLSurfaceView is not actually destroyed, the
onSurfaceCreated call is only made once and hence the opportunity to
load textures is gone.  To overcome this, I have introduced a flag
into the Renderer thread which will load up the textures in the first
call to onDrawFrame after the level is loaded.  I don't particularly
like this, but can't seen any other solution.

2. I don't seem to be able to find a way to effectively "switch views"
in my Activity.  I initially set the view (setContentView(...)) to the
loading screen (i.e NOT the GLSurfaceView), then the actual level load
is done asynchronously and when complete calls back to the main
activity thread which then performs a second call to setContentView()
with the GLSurfaceView instance.  This works the first time, but
thereafter I can't seem to get the loading view to become visible.  If
I use setVisibility(View.VISIBLE) on the loading view it doesn't
display, and if I perform a further call to setContentView() my
GLSurfaceView never comes back... that is, after subsequently calling
setContentView with the GLSurfaceView I get nothing displayed... no
errors, but my loading screen basically never disappears.

So.. does anyone out there have a good approach to solving this?  That
is, how to best implement a loading screen to "hide" the process of
bootstrapping opengl resources etc.

Thanks!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to