[2.3] createChildSceneNode() returning unsuccessful

Problems building or running the engine, queries about how to use features etc.
Post Reply
rrl
Halfling
Posts: 67
Joined: Sun Jun 04, 2017 12:33 am

[2.3] createChildSceneNode() returning unsuccessful

Post by rrl »

I've been porting from 2.1 to 2.3 on linux using GL3+ and I'm stuck with the following.

Code: Select all

    cameraNode = camera->getSceneManager()->getRootSceneNode()->createChildSceneNode();
    if (!cameraNode)
        std::cout << "This will print\n";
And trying to access cameraNode will segfault my app. Has anything changed with respect to these lines in 2.3 that I should be aware of?

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

Re: [2.3] createChildSceneNode() returning unsuccessful

Post by dark_sylinc »

Nothing has changed between 2.1 and 2.3 that would explain this behavior. createChildSceneNode also never returns nullptr.

My best guess is some of your code is seeing old/wrong headers or being linked against the wrong library thus it looks at the wrong offset to call (or you just need a clean rebuild).

rrl
Halfling
Posts: 67
Joined: Sun Jun 04, 2017 12:33 am

Re: [2.3] createChildSceneNode() returning unsuccessful

Post by rrl »

Fro 2.3, I'm pulling master from https://github.com/OGRECave/ogre-next. Is this correct or should I be pulling from one of the branches?

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

Re: [2.3] createChildSceneNode() returning unsuccessful

Post by dark_sylinc »

That branch is correct

rrl
Halfling
Posts: 67
Joined: Sun Jun 04, 2017 12:33 am

Re: [2.3] createChildSceneNode() returning unsuccessful

Post by rrl »

This is something that used to work in 2.1, and in 2.3 I haven't been able to find why this createChildSceneNode() is constantly set to NULL. I saw minor changes in the 2.3 tutorials so I started messing around in the initialization() area and noticed that when retrieving RenderSystems that I don't have one, even though I am using GL3Plus in plugins.cfg I have "Plugin=RenderSystem_GL3Plus" and in 2.1 this has always worked.

Code: Select all

    void GraphicsSystem::initialize(const Ogre::String &windowTitle)
    {
        // ...

        root = OGRE_NEW Ogre::Root(pluginsPath, mWriteAccessFolder + "ogre.cfg",
            mWriteAccessFolder + "Ogre.log" );

        // ...

        // I added the following section even though I use only GL3+ ...
        staticPluginLoader.install(root);

        Ogre::RenderSystemList::const_iterator itor =
            root->getAvailableRenderers().begin();
        Ogre::RenderSystemList::const_iterator itor_end =
            root->getAvailableRenderers().begin();

        if (itor == itor_end)
            std::cout << "This always prints\n";

        // ...

        // and this line will crash it.
        root->getRenderSystem()->setConfigOption("sRGB Gamma Conversion", "Yes");

        // ...
    }
Should these iterators at least show one RenderSystem in place for the one I am using?

So because createChildSceneNode() relies on Ogre::Root and Ogre::SceneManager, I double checked these, but don't see anything wrong.

Can anyone glean anything from this that I'm not seeing?

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

Re: [2.3] createChildSceneNode() returning unsuccessful

Post by dark_sylinc »

I'll try to make it clear: It's EXTREMELY LIKELY that you're mixing an old header or dll/library from 2.1 when you're building or loading for 2.3

You could be linking against the new 2.3 library, but then at runtime the wrong library is loaded. Or a variation of that

The plugin in the plugins folder could be an old one.

The ldd tool may help you troubleshoot which shared libraries are getting linked by your app.

Be very careful of the paths. The DLL name may be right but it could be getting read from the wrong location.

TL;DR: The problem is caused due to mixing libraries from 2.1 and 2.3 at the same time.

rrl
Halfling
Posts: 67
Joined: Sun Jun 04, 2017 12:33 am

Re: [2.3] createChildSceneNode() returning unsuccessful

Post by rrl »

Ok, I am certain it has nothing to do with mixing old headers or libs. I've removed every single tree of Ogre on my system, to include rebuilding everything from scratch and checking all env vars. I've run ldd on my executables and all is right using 2.3.

I've noticed something else, just as soon as I make this call ...

Code: Select all

void GraphicsSystem::initialize(const Ogre::String &windowTitle) {
    Ogre::String pluginsPath;
    pluginsPath = mPluginsFolder + "../etc/plugins.cfg";

    root = OGRE_NEW Ogre::Root(pluginsPath, mWriteAccessFolder + "ogre.cfg",
        mWriteAccessFolder + "Ogre.log" );
    root->getRenderSystem()->setConfigOption("sRGB Gamma Conversion","Yes");
... it will segfault. This used to work for me in 2.1 and I see this section has changed in the 2.3 tutorials so I tried adding the following ...

Code: Select all

Ogre::RenderSystemList::const_iterator itor = 
        root->getAvailableRenderers().begin();
Ogre::RenderSystemList::const_iterator itor_end = 
        root->getAvailableRenderers().begin();

if (itor == itor_end)
    std::cout << "this will print, so no renderers found even though GL3+ has loaded.\n";

while (itor != itor_end) {
    // i don't quite get this loop as it seems to have no effect elsewhere.
    Ogre::RenderSystem *rs = *itor;
    rs->setConfigOption("sRGB Gamma Conversion", "Yes");

    ++itor;
}
So with the above, it would seem there are no available renderers even though I get the following in the console before reaching the GraphicsSystem::initialize() method.

Code: Select all

...
Loading library /opt/ogre-next/lib/OGRE/RenderSystem_GL3Plus
Installing plugin: GL 3+ RenderSystem
OpenGL 3+ Rendering Subsystem created.
Plugin successfully installed
...
I'm not saying my code is without fault, I'm just not seeing where I'm going wrong. Any help, thanks.

Also, I've been trying to trace the Ogre routines, but so far to no avail.

LtZ
Gnoblar
Posts: 7
Joined: Thu Dec 19, 2019 9:51 am
x 6

Re: [2.3] createChildSceneNode() returning unsuccessful

Post by LtZ »

Ogre::RenderSystemList::const_iterator itor =
root->getAvailableRenderers().begin();
Ogre::RenderSystemList::const_iterator itor_end =
root->getAvailableRenderers().begin();
Something I noticed.. shouldn't the latter be .end() ?

rrl
Halfling
Posts: 67
Joined: Sun Jun 04, 2017 12:33 am

Re: [2.3] createChildSceneNode() returning unsuccessful

Post by rrl »

Yeah, I caught that last week, but to no avail. Thanks though.

Post Reply