We show a static splash screen with a ProgressBar.  I can't remember
if I ever played a game with an animated splash, and our theme doesn't
call for animated so we figured static is good enough (hey, if it's
good enough for Angry Birds... ;-)).

This way the loading code tends to be simpler, too, and I'd like to
keep it that way.

On Thu, Aug 2, 2012 at 11:09 PM, RichardC
<[email protected]> wrote:
> AsyncTask be used for loading because an OpenGL ES context can only be used
> on one thread, which in this case is the rendering thread.
>
> If do my restore state after loosing the context in onDrawFrame as I don't
> like to leave the user looking at a blank screen.
>
> I use a worker thread that decodes objects into memory and queues them for
> the renderer thread, but not too many or I run out of memory (textures can
> be quite large).  The renderer thread then pulls completed "load jobs" from
> the queue and submits them to OpenGL ES.  This is done in onDrawFrame whilst
> showing a simple OpenGL splash screen.  During  onDrawFrame if the load code
> takes more then 10ms it stops loading, animates the splash screen and exits.
> When onDrawFrame is called subsequently it continues loading in approx 10ms
> chunks until the full state is restored.
>
> On Thursday, August 2, 2012 9:46:57 PM UTC+1, bob wrote:
>>
>> Sounds like the real problem is that your
>>
>>
>> "onDrawFrame() goes into texture & geometry loading routine which can take
>> up to several seconds"
>>
>>
>> I'd say onDrawFrame is not the place for that.  Sounds like a job for an
>> AsyncTask.
>>
>>
>>
>> On Thursday, August 2, 2012 10:18:04 AM UTC-5, Latimerius wrote:
>>>
>>> I'd like to call join() on it to make sure the thread has exited.
>>>
>>> (Broader context for those interested: I have a crash in my GL-based
>>> app that happens like this:
>>>
>>> - device is put to sleep with my app in the foreground
>>> - an incoming call wakes the device up
>>> - I receive onResume() and I call onResume() on my GLSurfaceView
>>> - I receive onPause() almost immediately after onResume() since the
>>> phone app goes to the background due to the incoming call
>>> - the time between onResume() and onPause() is rather short but enough
>>> for GLSurfaceView to go through all of its setup up to and including
>>> the initial onDrawFrame() call
>>> - my onDrawFrame() goes into texture & geometry loading routine which
>>> can take up to several seconds so it's still loading when onPause() is
>>> called as mentioned previously
>>> - like many people here I have a globally-accessible method of
>>> retrieving a reference to my main Activity to be used as the current
>>> Context.  This is used while loading graphics data to read asset
>>> files.
>>> - this Context reference however gets nulled out in onPause() in an
>>> attempt not to leak main Activity instances.  As the main thread
>>> running onPause() nulls it while the rendering thread is still needing
>>> it to finish loading the program crashes.
>>>
>>> The idea is to call GLSurfaceView.onPause() and then wait until the
>>> rendering thread actually exit.  Then null the Context reference.)

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