Commit 0bb0989f authored by Pavel Rojtberg's avatar Pavel Rojtberg

ovis: drop SCENE_RENDER_FLOAT which is replaced by getCompositorTexture

the latter allows explicitly specifying channel nr/ format. Also we no
longer have to manually manage an extra rendertarget any more.
parent c4c2e85d
...@@ -24,10 +24,8 @@ enum SceneSettings ...@@ -24,10 +24,8 @@ enum SceneSettings
SCENE_INTERACTIVE = 2, SCENE_INTERACTIVE = 2,
/// draw coordinate system crosses for debugging /// draw coordinate system crosses for debugging
SCENE_SHOW_CS_CROSS = 4, SCENE_SHOW_CS_CROSS = 4,
/// @ref WindowScene::getScreenshot returns images as CV_32FC4 instead of CV_8UC3
SCENE_RENDER_FLOAT = 8,
/// 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 = 16 SCENE_AA = 8
}; };
enum MaterialProperty enum MaterialProperty
......
...@@ -264,7 +264,6 @@ class WindowSceneImpl : public WindowScene ...@@ -264,7 +264,6 @@ class WindowSceneImpl : public WindowScene
Ptr<OgreBites::CameraMan> camman; Ptr<OgreBites::CameraMan> camman;
Ptr<Rectangle2D> bgplane; Ptr<Rectangle2D> bgplane;
Ogre::RenderTarget* frameSrc;
Ogre::RenderTarget* depthRTT; Ogre::RenderTarget* depthRTT;
public: public:
WindowSceneImpl(Ptr<Application> app, const String& _title, const Size& sz, int flags) WindowSceneImpl(Ptr<Application> app, const String& _title, const Size& sz, int flags)
...@@ -324,18 +323,6 @@ public: ...@@ -324,18 +323,6 @@ public:
} }
rWin->addViewport(cam); rWin->addViewport(cam);
frameSrc = rWin;
if (flags & SCENE_RENDER_FLOAT)
{
// also render into an offscreen texture
// currently this draws everything twice, but we spare the float->byte conversion for display
TexturePtr tex = TextureManager::getSingleton().createManual(
title + "_rt", RESOURCEGROUP_NAME, TEX_TYPE_2D, sz.width, sz.height, 0, PF_FLOAT32_RGBA,
TU_RENDERTARGET);
frameSrc = tex->getBuffer()->getRenderTarget();
frameSrc->addViewport(cam);
}
} }
void setBackground(InputArray image) CV_OVERRIDE void setBackground(InputArray image) CV_OVERRIDE
...@@ -361,9 +348,9 @@ public: ...@@ -361,9 +348,9 @@ public:
{ {
CompositorManager& cm = CompositorManager::getSingleton(); CompositorManager& cm = CompositorManager::getSingleton();
// this should be applied to all owned render targets // this should be applied to all owned render targets
Ogre::RenderTarget* targets[] = {frameSrc, rWin, depthRTT}; Ogre::RenderTarget* targets[] = {rWin, depthRTT};
for(int j = (frameSrc == rWin); j < 3; j++) // skip frameSrc if it is the same as rWin for(int j = 0; j < 2; j++)
{ {
Ogre::RenderTarget* tgt = targets[j]; Ogre::RenderTarget* tgt = targets[j];
if(!tgt) continue; if(!tgt) continue;
...@@ -386,7 +373,7 @@ public: ...@@ -386,7 +373,7 @@ public:
int mrtIndex) CV_OVERRIDE int mrtIndex) CV_OVERRIDE
{ {
CompositorManager& cm = CompositorManager::getSingleton(); CompositorManager& cm = CompositorManager::getSingleton();
CompositorChain* chain = cm.getCompositorChain(frameSrc->getViewport(0)); CompositorChain* chain = cm.getCompositorChain(rWin->getViewport(0));
CV_Assert(chain && "no active compositors"); CV_Assert(chain && "no active compositors");
CompositorInstance* inst = chain->getCompositor(compname); CompositorInstance* inst = chain->getCompositor(compname);
...@@ -441,8 +428,6 @@ public: ...@@ -441,8 +428,6 @@ public:
// BGRA as uchar // BGRA as uchar
ColourValue _color = ColourValue(color[2], color[1], color[0], color[3]) / 255; ColourValue _color = ColourValue(color[2], color[1], color[0], color[3]) / 255;
rWin->getViewport(0)->setBackgroundColour(_color); rWin->getViewport(0)->setBackgroundColour(_color);
if(frameSrc != rWin)
frameSrc->getViewport(0)->setBackgroundColour(_color);
} }
void createEntity(const String& name, const String& meshname, InputArray tvec, InputArray rot) CV_OVERRIDE void createEntity(const String& name, const String& meshname, InputArray tvec, InputArray rot) CV_OVERRIDE
...@@ -594,17 +579,14 @@ public: ...@@ -594,17 +579,14 @@ public:
void getScreenshot(OutputArray frame) CV_OVERRIDE void getScreenshot(OutputArray frame) CV_OVERRIDE
{ {
PixelFormat src_type = frameSrc->suggestPixelFormat(); frame.create(rWin->getHeight(), rWin->getWidth(), CV_8UC3);
int dst_type = src_type == PF_BYTE_RGB ? CV_8UC3 : CV_32FC4;
frame.create(frameSrc->getHeight(), frameSrc->getWidth(), dst_type);
Mat out = frame.getMat(); Mat out = frame.getMat();
PixelBox pb(frameSrc->getWidth(), frameSrc->getHeight(), 1, src_type, out.ptr()); PixelBox pb(rWin->getWidth(), rWin->getHeight(), 1, PF_BYTE_RGB, out.ptr());
frameSrc->copyContentsToMemory(pb, pb); rWin->copyContentsToMemory(pb, pb);
// convert to OpenCV channel order // convert to OpenCV channel order
cvtColor(out, out, dst_type == CV_8UC3 ? COLOR_RGB2BGR : COLOR_RGBA2BGRA); cvtColor(out, out, COLOR_RGB2BGR);
} }
void getDepth(OutputArray depth) CV_OVERRIDE void getDepth(OutputArray depth) CV_OVERRIDE
...@@ -615,8 +597,8 @@ public: ...@@ -615,8 +597,8 @@ public:
// render into an offscreen texture // render into an offscreen texture
// currently this draws everything twice as OGRE lacks depth texture attachments // currently this draws everything twice as OGRE lacks depth texture attachments
TexturePtr tex = TextureManager::getSingleton().createManual( TexturePtr tex = TextureManager::getSingleton().createManual(
title + "_Depth", RESOURCEGROUP_NAME, TEX_TYPE_2D, frameSrc->getWidth(), title + "_Depth", RESOURCEGROUP_NAME, TEX_TYPE_2D, rWin->getWidth(),
frameSrc->getHeight(), 0, PF_DEPTH, TU_RENDERTARGET); rWin->getHeight(), 0, PF_DEPTH, TU_RENDERTARGET);
depthRTT = tex->getBuffer()->getRenderTarget(); depthRTT = tex->getBuffer()->getRenderTarget();
depthRTT->addViewport(cam); depthRTT->addViewport(cam);
depthRTT->setAutoUpdated(false); // only update when requested depthRTT->setAutoUpdated(false); // only update when requested
......
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