Commit c9514b80 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #2358 from paroj:ovisup

parents 6a955588 647e79cf
...@@ -25,7 +25,9 @@ enum SceneSettings ...@@ -25,7 +25,9 @@ enum SceneSettings
/// draw coordinate system crosses for debugging /// draw coordinate system crosses for debugging
SCENE_SHOW_CS_CROSS = 4, SCENE_SHOW_CS_CROSS = 4,
/// Apply anti-aliasing. The first window determines the setting for all windows. /// Apply anti-aliasing. The first window determines the setting for all windows.
SCENE_AA = 8 SCENE_AA = 8,
/// Render off-screen without a window. Allows separate AA setting. Requires manual update via @ref WindowScene::update
SCENE_OFFSCREEN = 16
}; };
enum MaterialProperty enum MaterialProperty
...@@ -276,6 +278,10 @@ public: ...@@ -276,6 +278,10 @@ public:
CV_WRAP virtual void setCameraIntrinsics(InputArray K, const Size& imsize, CV_WRAP virtual void setCameraIntrinsics(InputArray K, const Size& imsize,
float zNear = -1, float zNear = -1,
float zFar = -1) = 0; float zFar = -1) = 0;
/**
* render this window, but do not swap buffers. Automatically called by @ref ovis::waitKey
*/
CV_WRAP virtual void update() = 0;
}; };
/** /**
......
...@@ -289,7 +289,7 @@ class WindowSceneImpl : public WindowScene ...@@ -289,7 +289,7 @@ class WindowSceneImpl : public WindowScene
Root* root; Root* root;
SceneManager* sceneMgr; SceneManager* sceneMgr;
SceneNode* camNode; SceneNode* camNode;
RenderWindow* rWin; RenderTarget* rWin;
Ptr<OgreBites::CameraMan> camman; Ptr<OgreBites::CameraMan> camman;
Ptr<Rectangle2D> bgplane; Ptr<Rectangle2D> bgplane;
std::unordered_map<AnimationState*, Controller<Real>*> frameCtrlrs; std::unordered_map<AnimationState*, Controller<Real>*> frameCtrlrs;
...@@ -344,11 +344,22 @@ public: ...@@ -344,11 +344,22 @@ public:
if (!app->sceneMgr) if (!app->sceneMgr)
{ {
CV_Assert((flags & SCENE_OFFSCREEN) == 0 && "off-screen rendering for main window not supported");
app->sceneMgr = sceneMgr; app->sceneMgr = sceneMgr;
rWin = app->getRenderWindow(); rWin = app->getRenderWindow();
if (camman) if (camman)
app->addInputListener(camman.get()); app->addInputListener(camman.get());
} }
else if (flags & SCENE_OFFSCREEN)
{
// render into an offscreen texture
TexturePtr tex = TextureManager::getSingleton().createManual(
title, RESOURCEGROUP_NAME, TEX_TYPE_2D, sz.width, sz.height, 0, PF_BYTE_RGB,
TU_RENDERTARGET, NULL, false, flags & SCENE_AA ? 4 : 0);
rWin = tex->getBuffer()->getRenderTarget();
rWin->setAutoUpdated(false); // only update when requested
}
else else
{ {
OgreBites::NativeWindowPair nwin = app->createWindow(title, sz.width, sz.height); OgreBites::NativeWindowPair nwin = app->createWindow(title, sz.width, sz.height);
...@@ -820,6 +831,11 @@ public: ...@@ -820,6 +831,11 @@ public:
ndc = (2 * f * n) / ndc; ndc = (2 * f * n) / ndc;
} }
void update()
{
rWin->update(false);
}
void fixCameraYawAxis(bool useFixed, InputArray _up) CV_OVERRIDE void fixCameraYawAxis(bool useFixed, InputArray _up) CV_OVERRIDE
{ {
#if OGRE_VERSION >= ((1 << 16) | (11 << 8) | 5) #if OGRE_VERSION >= ((1 << 16) | (11 << 8) | 5)
...@@ -923,6 +939,7 @@ public: ...@@ -923,6 +939,7 @@ public:
CV_EXPORTS_W void addResourceLocation(const String& path) CV_EXPORTS_W void addResourceLocation(const String& path)
{ {
CV_Assert(!_app && "must be called before the first createWindow");
_extraResourceLocations.insert(Ogre::StringUtil::normalizeFilePath(path, false)); _extraResourceLocations.insert(Ogre::StringUtil::normalizeFilePath(path, false));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment