@@ -236,6 +236,8 @@ struct Application : public OgreBites::ApplicationContext, public OgreBites::Inp
236
236
return ret;
237
237
}
238
238
239
+ size_t numWindows () const { return mWindows .size (); }
240
+
239
241
void locateResources () CV_OVERRIDE
240
242
{
241
243
OgreBites::ApplicationContext::locateResources ();
@@ -277,9 +279,10 @@ class WindowSceneImpl : public WindowScene
277
279
Ptr<Rectangle2D> bgplane;
278
280
279
281
Ogre::RenderTarget* depthRTT;
282
+ int flags;
280
283
public:
281
- WindowSceneImpl (Ptr<Application> app, const String& _title, const Size& sz, int flags )
282
- : title(_title), root(app->getRoot ()), depthRTT(NULL )
284
+ WindowSceneImpl (Ptr<Application> app, const String& _title, const Size& sz, int _flags )
285
+ : title(_title), root(app->getRoot ()), depthRTT(NULL ), flags(_flags)
283
286
{
284
287
if (!app->sceneMgr )
285
288
{
@@ -337,6 +340,25 @@ class WindowSceneImpl : public WindowScene
337
340
rWin->addViewport (cam);
338
341
}
339
342
343
+ ~WindowSceneImpl ()
344
+ {
345
+ if (flags & SCENE_SEPERATE)
346
+ {
347
+ MaterialManager::getSingleton ().remove (bgplane->getMaterial ());
348
+ bgplane.release ();
349
+ String texName = sceneMgr->getName () + " _Background" ;
350
+ TextureManager::getSingleton ().remove (texName, RESOURCEGROUP_NAME);
351
+ }
352
+
353
+ if (_app->sceneMgr == sceneMgr && (flags & SCENE_SEPERATE))
354
+ {
355
+ // this is the root window owning the context
356
+ CV_Assert (_app->numWindows () == 1 && " the first OVIS window must be deleted last" );
357
+ _app->closeApp ();
358
+ _app.release ();
359
+ }
360
+ }
361
+
340
362
void setBackground (InputArray image) CV_OVERRIDE
341
363
{
342
364
CV_Assert (bgplane);
0 commit comments