Author Topic: Code completion + OGRE  (Read 7223 times)

iceberk

  • Guest
Code completion + OGRE
« on: February 12, 2007, 03:42:25 pm »
I have the folowing code
Code
#include "ExampleApplication.h"

class TutorialApplication : public ExampleApplication
{
protected:
public:
    TutorialApplication()
    {
    }

    ~TutorialApplication()
    {
    }
protected:
    void createScene(void)
    {
        mSceneMgr->setAmbientLight(ColourValue(0.7, 1, 1));       
    }
};

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
    // Create application object
    TutorialApplication app;

    try {
        app.go();
    } catch( Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
        fprintf(stderr, "An exception has occured: %s\n",
                e.getFullDescription().c_str());
#endif
    }

    return 0;
}
When i'm writing "mSceneMgr->"(or "ap."), code completion displays nothing. Why?

OS: Windows XP
Code::Blocks version: svn build rev 3592

Code completion settings:
  Code completion - only "Automatically launch..." checked
  C/C++ parser - all checked
  Symbol browser - only "Automatically expand namespaces" checked

iceberk

  • Guest
Re: Code completion + OGRE
« Reply #1 on: February 12, 2007, 04:02:29 pm »
Ok, problem is solved by adding following line :o
Code
using namespace Ogre;
I suggest this line should be added to Ogre's template
« Last Edit: February 12, 2007, 04:05:55 pm by IceBerk »

Offline san

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Code completion + OGRE
« Reply #2 on: February 14, 2007, 12:31:18 pm »
This may solve the problem for windows users perhaps... but I'm on Ubuntu Linux and the problem still occurs.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Code completion + OGRE
« Reply #3 on: February 14, 2007, 02:02:26 pm »
This may solve the problem for windows users perhaps... but I'm on Ubuntu Linux and the problem still occurs.

For linux, things are a little different because we use shell scripts to configure the project for Ogre (e.g. "pkg-config --cflags OGRE"). For this reason, the C/C++ parser doesn't know where to find the files.
To help the parser find (and parse) the files, add OGRE's include dir in "Project->Properties->C/C++ parser options". Save your project, close and re-open it and then it should work.
Be patient!
This bug will be fixed soon...

Offline san

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Code completion + OGRE
« Reply #4 on: February 14, 2007, 05:58:39 pm »
Thanks for the fast reply!

For future reference:
I added this path "/somewhere/ogrenew/OgreMain/include" at the location you suggested and restarted code::blocks. That in combination with the following line makes code completion work!
Code
using namespace Ogre;

It would be nice if the Ogre examples also were there for linux (now new users need to modify them by hand).. but other than that I'm very pleased!

Thanks,
San

« Last Edit: February 14, 2007, 06:13:11 pm by san »

Offline san

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Code completion + OGRE
« Reply #5 on: February 14, 2007, 07:36:23 pm »
Hmm only now is my compiler complaining about namespaces in the source :)

Code
SkeletalAnimation.h:22: error: ‘Ogre’ is not a namespace-name
SkeletalAnimation.h:22: error: expected namespace-name before ‘;’ token

Any clues?

Offline Sensei

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Code completion + OGRE
« Reply #6 on: June 17, 2009, 05:48:22 pm »
Hello,

I had the same problem concerning the "not a namespace-name" error and I tested a bit.

I do have nearly the same code as given in the first post.

I fixed the "not a namespace-name" problem by writing:

#include <Ogre.h> in a line above the using namespace Ogre; line

Result: Code completition works and the compiler won't give that error message.

BUT:

I tried to split the class definition into a separate file for example TutorialApplication.h and included it a line below my using namespace Ogre; line.
I discovered that if I try to code in the *.h file the code completition won't work.

Why does this happen and how can I fix this.

Thanks in advance

Sensei