GLES2.0 DeviceLost / DeviceRestore

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 100

GLES2.0 DeviceLost / DeviceRestore

Post by Wolfmanfx »

Hi,

As you know Android destroys the GLContext on device rotation or when you go to the home screen (and few other situations) - this means you have to destroy all resources on device lost and recreate on restore (on Android you get an event when the os destroys your window and when it creates a new one).

So far i checked the dx9 impl of device -lost/-restore.
It has a global (static) ResourceManager which is created in the dx9RS which used to propagate the device -lost/-restore to all resources which needs recreated - also it has a Dx9Resource interface (so lost / restore events are handled).
The D3D9Resource calls D3D9RenderSystem::getResourceManager()->_notifyResourceCreated(static_cast<D3D9Resource*>(this)); at construction time and
D3D9RenderSystem::getResourceManager()->_notifyResourceDestroyed(static_cast<D3D9Resource*>(this)); on destruction.
This means the D3D9ResourceManager keeps track of all created resources.

We/I could impl it the same way for gles2 - the question is if there is a better approach todo this?
User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 100

Re: GLES2.0 DeviceLost / DeviceRestore

Post by Wolfmanfx »

Ok i have impl. this on my fork https://bitbucket.org/wolfmanfx/ogre/changesets and it is working :) a few things still missing
+ device orientation: when you rotate it have to update the viewport
+ And 1 sample is crashing on recreation: the character demo
User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 100

Re: GLES2.0 DeviceLost / DeviceRestore

Post by Wolfmanfx »

Here a video showing it in action

[youtube]B0NTbU_CDnE[/youtube]