For anyone else stumbling in...

I achieved my result with a ViewFlipper.

1. Create a simple view and override the onDraw method to display
loading status
2. Create a ViewFlipper and add the loading view with index 0
3. Set the flipper to the content of the activity (setContentView)
4. Load the game/level and in so doing create the GLSurfaceView (which
will then load my textures)
5. Add the GLSurfaceView to the flipper with index 1
6. Force the gl view to the front with flipper.setDisplayedChild(1);

Then when the next level is loaded...

1. Force the loading view to the front with
flipper.setDisplayedChild(0);
2. Load the level using AsyncTask
3. On load complete, callback to activity as set gl view to front with
flipper.setDisplayedChild(1)


On Aug 19, 8:04 am, Jason <[email protected]> wrote:
> Thanks guys.  You have all been very helpful!
>
> On Aug 19, 5:15 am, Robert Green <[email protected]> wrote:
>
>
>
> > I just load the loading screen textures first and render it in OpenGL
> > ortho while loading.  I even have a progress bar, though you have to
> > load in steps to do that.
>
> > On Aug 18, 4:40 am, Miguel Morales <[email protected]> wrote:
>
> > > Well, I think the easiest thing for you would be to add an overlay
> > > view on top of your openGL view.
> > > This is fairly easy.
>
> > > On your activity's onCreate you could do this:
>
> > > LinearLayout base = new LinearLayout(this);
>
> > > FrameLayout frame = new FrameLayout(this);
> > > YourGLView gl_view  = new YourGLView(...);
>
> > > YourOverlayView overlay_view = new YourOverlayView(...);
>
> > > frame.addView(gl_view);
> > > frame.addView(overlay_view);
> > > base.addView(frame);
>
> > > setContentView(base);
>
> > > YourOverlayView can be derived from any view.  I personally extend
> > > ImageView and override the onDraw() method for full control.
>
> > > On Tue, Aug 17, 2010 at 11:56 PM, Jason <[email protected]> wrote:
> > > > Hi all,
>
> > > > I'm trying to find the best way to implement a "loading screen" when
> > > > using aGLSurfaceView.
>
> > > > 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 theGLSurfaceViewwhile the level data is loaded.
>
> > > > This has created some problems for me:
>
> > > > 1. Because theGLSurfaceViewis 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 theGLSurfaceView), 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 theGLSurfaceViewinstance.  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
> > > >GLSurfaceViewnever comes back... that is, after subsequently calling
> > > > setContentView with theGLSurfaceViewI 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
>
> > > --http://developingthedream.blogspot.com/,http://diastrofunk.com,http:/...,
> > >  ~Isaiah 55:8-9

-- 
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