News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Code completion + OGRE

Started by iceberk, February 12, 2007, 03:42:25 PM

Previous topic - Next topic

iceberk

I have the folowing 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

#1
Ok, problem is solved by adding following line :o
using namespace Ogre;
I suggest this line should be added to Ogre's template

san

This may solve the problem for windows users perhaps... but I'm on Ubuntu Linux and the problem still occurs.

mandrav

Quote from: san 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.

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...

san

#4
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!
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


san

Hmm only now is my compiler complaining about namespaces in the source :)

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


Any clues?

Sensei

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