@@ -289,7 +289,7 @@ class WindowSceneImpl : public WindowScene
289
289
Root* root;
290
290
SceneManager* sceneMgr;
291
291
SceneNode* camNode;
292
- RenderWindow * rWin;
292
+ RenderTarget * rWin;
293
293
Ptr<OgreBites::CameraMan> camman;
294
294
Ptr<Rectangle2D> bgplane;
295
295
std::unordered_map<AnimationState*, Controller<Real>*> frameCtrlrs;
@@ -344,11 +344,22 @@ class WindowSceneImpl : public WindowScene
344
344
345
345
if (!app->sceneMgr )
346
346
{
347
+ CV_Assert ((flags & SCENE_OFFSCREEN) == 0 && " off-screen rendering for main window not supported" );
348
+
347
349
app->sceneMgr = sceneMgr;
348
350
rWin = app->getRenderWindow ();
349
351
if (camman)
350
352
app->addInputListener (camman.get ());
351
353
}
354
+ else if (flags & SCENE_OFFSCREEN)
355
+ {
356
+ // render into an offscreen texture
357
+ TexturePtr tex = TextureManager::getSingleton ().createManual (
358
+ title, RESOURCEGROUP_NAME, TEX_TYPE_2D, sz.width , sz.height , 0 , PF_BYTE_RGB,
359
+ TU_RENDERTARGET, NULL , false , flags & SCENE_AA ? 4 : 0 );
360
+ rWin = tex->getBuffer ()->getRenderTarget ();
361
+ rWin->setAutoUpdated (false ); // only update when requested
362
+ }
352
363
else
353
364
{
354
365
OgreBites::NativeWindowPair nwin = app->createWindow (title, sz.width , sz.height );
@@ -820,6 +831,11 @@ class WindowSceneImpl : public WindowScene
820
831
ndc = (2 * f * n) / ndc;
821
832
}
822
833
834
+ void update ()
835
+ {
836
+ rWin->update (false );
837
+ }
838
+
823
839
void fixCameraYawAxis (bool useFixed, InputArray _up) CV_OVERRIDE
824
840
{
825
841
#if OGRE_VERSION >= ((1 << 16) | (11 << 8) | 5)
@@ -923,6 +939,7 @@ class WindowSceneImpl : public WindowScene
923
939
924
940
CV_EXPORTS_W void addResourceLocation (const String& path)
925
941
{
942
+ CV_Assert (!_app && " must be called before the first createWindow" );
926
943
_extraResourceLocations.insert (Ogre::StringUtil::normalizeFilePath (path, false ));
927
944
}
928
945
0 commit comments