[SOLVED] How to setup a workspace

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
Transporter
Minaton
Posts: 933
Joined: Mon Mar 05, 2012 11:37 am
Location: Germany
x 1

[SOLVED] How to setup a workspace

Post by Transporter » Tue Jan 21, 2014 3:04 pm

Hi,

I have a small problem:

Code: Select all

	Ogre::CompositorManager2* pCompositorManager = mRoot->getCompositorManager2();
		const Ogre::IdString workspaceName = "scene workspace " + Ogre::StringConverter::toString(i);
		pCompositorManager->createBasicWorkspaceDef(workspaceName.getFriendlyText(), Ogre::ColourValue::Black);
		pCompositorManager->addWorkspace(mSceneMgr, mRenderWnd, mCamera, workspaceName, true);
In Debug mode it's working, but on release:

Code: Select all

14:59:53: OGRE EXCEPTION(5:ItemIdentityException): Workspace definition '[Hash 0xbbe2a5a3]' not found in CompositorManager2::addWorkspace at ..\..\OgreMain\src\Compositor\OgreCompositorManager2.cpp (line 343)
Btw, why is the first parameter of createBasicWorkspaceDef a string and not an IdString anymore? Could you please update the porting guide?

THX
Transporter

Edit: It looks like a bug, I can reproduce it with different programs.
Attachments
TutorialFramework.zip
example
(6.63 KiB) Downloaded 137 times
Last edited by Transporter on Wed Jan 22, 2014 10:31 am, edited 1 time in total.
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4116
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 243
Contact:

Re: How to setup a workspace (BUG?)

Post by dark_sylinc » Tue Jan 21, 2014 11:04 pm

IdStrings are destructive. This means that you may no longer recover the real name it was constructed from.
createBasicWorkspaceDef changed its input parameter to full String so that the node defs it creates (CompositorNodeDef) could keep a hard, full copy of the name (which is useful for e.g. Editors, including the Compositor Sample itself) while still using IdStrings for the std::map lookup and other comparisons.

The reason your snippet is failing is because "workspaceName.getFriendlyText()" may not return the original string (in fact, in Release mode it's just returning [Hash 0xbbe2a5a3]) and thus you're creating a workspace definition named "[Hash 0xbbe2a5a3]".
But when you call addWorkspace, you're requesting the workspace def named "scene workspace 0".

To fix it, change your snippet to:

Code: Select all

Ogre::CompositorManager2* pCompositorManager = mRoot->getCompositorManager2();
      const Ogre::String workspaceName = "scene workspace " + Ogre::StringConverter::toString(i);
      const Ogre::IdString workspaceNameHash = workspaceName;
      pCompositorManager->createBasicWorkspaceDef(workspaceName, Ogre::ColourValue::Black);
      pCompositorManager->addWorkspace(mSceneMgr, mRenderWnd, mCamera, workspaceNameHash, true);
I'll check the manual to update the snippets, and possibly update IdString's documentation to make it more explicit it's destructive.
0 x

Transporter
Minaton
Posts: 933
Joined: Mon Mar 05, 2012 11:37 am
Location: Germany
x 1

Re: How to setup a workspace (BUG?)

Post by Transporter » Wed Jan 22, 2014 10:31 am

Thanks a lot!

I've made a small patch to simplify this code part: https://bitbucket.org/sinbad/ogre/pull- ... a-standard

Code: Select all

Ogre::CompositorManager2* pCompositorManager = mRoot->getCompositorManager2();
const Ogre::String workspaceName = "scene workspace " + Ogre::StringConverter::toString(i);
pCompositorManager->createBasicWorkspaceDef(workspaceName, Ogre::ColourValue::Black);
pCompositorManager->addWorkspace(mSceneMgr, mRenderWnd, mCamera, workspaceName, true);
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4116
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 243
Contact:

Re: [SOLVED] How to setup a workspace

Post by dark_sylinc » Tue Jan 28, 2014 5:54 pm

Fixed. The old method works again.
0 x

Gucci
Gnoblar
Posts: 6
Joined: Mon Nov 24, 2014 7:07 pm

Re: [SOLVED] How to setup a workspace

Post by Gucci » Thu Sep 03, 2015 3:24 pm

I also share concern regarding the use of NDEBUG. I am using ogre for scientific work alongside other libraries such as Eigen. I'm trying to port to Ogre 2.1 now, and having to define NDEBUG is a pain because that flag also affects these libraries (for example: http://eigen.tuxfamily.org/dox/TopicPre ... tives.html). Other than that keep up the great work!
0 x

alex566
Gnoblar
Posts: 1
Joined: Sat Nov 26, 2016 11:16 pm
Location: Ukraine, Kharkiv

Re: [SOLVED] How to setup a workspace

Post by alex566 » Sun Nov 27, 2016 2:25 am

Hi,

I have downloaded the last revision from branch v2-1-pso, looked at samples and tried to make a simple application for ios, but I ran into a same problem.

Image

Also, when I do something like this:

Code: Select all

const Ogre::IdString workspaceName = "Main workspace";
        
compositorManager->addWorkspaceDefinition(workspaceName);
compositorManager->addWorkspaceDefinition(workspaceName);
I don't get ERR_DUPLICATE_ITEM exception.

Can you help me with this problem?
Thanks.
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4116
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 243
Contact:

Re: [SOLVED] How to setup a workspace

Post by dark_sylinc » Tue Nov 29, 2016 3:36 pm

The problem must be the NDEBUG mismatch.

Make sure you link Debug version of your app with Debug version of Ogre, and Release with Release.
Additionally, check the preprocessor macro definition of both your app and Ogre of NDEBUG match for your build:
Image
0 x

Post Reply