Android suspend lose GL context

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
Post Reply
aoikonom
Gnoblar
Posts: 23
Joined: Tue Aug 07, 2012 11:05 am

Android suspend lose GL context

Post by aoikonom »

Using Ogre 1.8 on Android.

When application loses focus gl context is destroyed and after resume I only see black screen.

This is described in Android documentation here http://developer.android.com/reference/ ... derer.html
EGL Context Lost

There are situations where the EGL rendering context will be lost. This typically happens when device wakes up after going to sleep. When the EGL context is lost, all OpenGL resources (such as textures) that are associated with that context will be automatically deleted. In order to keep rendering correctly, a renderer must recreate any lost resources that it still needs. The onSurfaceCreated(GL10, EGLConfig) method is a convenient place to do this.
How can handle this situation with Ogre?

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 99
Contact:

Re: Android suspend lose GL context

Post by Wolfmanfx »

Hi,

Yes we can handle that! But not in 1.8 switch to 1.9 and take a look at the samples.

aoikonom
Gnoblar
Posts: 23
Joined: Tue Aug 07, 2012 11:05 am

Re: Android suspend lose GL context

Post by aoikonom »

Wolfmanfx, thanks for replying.

Could you indicate me in which files-points this functionality is implemented, so that I can add it to version 1.8?

This is because, I don't use Ogre as it is, but a port of Ogre to Maramalade, which was branched from version 1.8 and on which I have made some changes. So I don't know if it is better to try to make a port of 1.9 to marmalade based on previous port, or apply specific changes to the port I have, related to the problem with GL context on Android devices.

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 99
Contact:

Re: Android suspend lose GL context

Post by Wolfmanfx »

You port to 1.9 - 1.8 has many bugs inside. With 1.9 you get many fixes not just on android also we have new features like WP8 support and many many things. So go ahead and port :)

aoikonom
Gnoblar
Posts: 23
Joined: Tue Aug 07, 2012 11:05 am

Re: Android suspend lose GL context

Post by aoikonom »

Can you please inform me how does Ogre 1.9 handle problem with Android GL context ? Does it keep a copy of all GL resources in RAM?
Because if this is the case I might have a problem with RAM consumption.

Also I have a problem porting my project to Ogre 1.9 found here http://www.ogre3d.org/forums/viewtopic.php?f=1&t=79709

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 99
Contact:

Re: Android suspend lose GL context

Post by Wolfmanfx »

No infact we release all gpu resources when device is lost and recreate the gpu resources when the device is active again. Of course the meshdata is kept inside sysram otherwise it would not possible to recreate the resources fast.
Infact the context lost can also happen when you rotate the device.

aoikonom
Gnoblar
Posts: 23
Joined: Tue Aug 07, 2012 11:05 am

Re: Android suspend lose GL context

Post by aoikonom »

Textures for example are kept in memory?

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 99
Contact:

Re: Android suspend lose GL context

Post by Wolfmanfx »

Sorry for the late replay - Textures can freed completely to save memory as long there are not referenced somewhere.

Post Reply