Building errors?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Fox
Posts: 14
Joined: Sun Nov 23, 2008 5:59 am
Location: Okinawa, Japan

Building errors?

Post by Fox »

Hi everyone, sorry for my english (im japanese) but i have question, i build and i get error about 'fps' why is this happening?

Code: Select all

error C2065: 'FPS' : undeclared identifier

some people say i am putting it in a if statement, outside if?

and they say put it in a while loop, i looked up while loop but don't hardly understand much. please help me? please and thank's.

Here is what itype:

Code: Select all

#include <irrlicht.h>
#include <iostream>

using namespace irr;


#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif

int main()
{
       

        video::E_DRIVER_TYPE driverType;

        printf("Please select the driver you want for this example:\n"\
                " (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
                " (d) Software Renderer\n (e) Burning's Software Renderer\n"\
                " (f) NullDevice\n (otherKey) exit\n\n");

        char i;
        std::cin >> i

        ;switch(i)
{
                case 'a': driverType = video::EDT_DIRECT3D9;break;
                case 'b': driverType = video::EDT_DIRECT3D8;break;
                case 'c': driverType = video::EDT_OPENGL;   break;
                case 'd': driverType = video::EDT_SOFTWARE; break;
                case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
                case 'f': driverType = video::EDT_NULL;     break;
                default: return 1;
        }       

       

        IrrlichtDevice* device =
                createDevice(driverType, core::dimension2d<s32>(640, 480));

        if (device == 0)
                return 1;

        device->setWindowCaption(L"Load .irr file example");

        video::IVideoDriver* driver = device->getVideoDriver();
        scene::ISceneManager* smgr = device->getSceneManager();
		

		{
        smgr->loadScene("../../media/example.irr");


        smgr->addCameraSceneNodeFPS();
		}
    

        int lastFPS = -1;

        while(device->run())
        if (device->isWindowActive())

        {
                driver->beginScene(true, true, video::SColor(0,200,200,200));
                smgr->drawAll();
                driver->endScene();

				int fps = driver->getFPS(); 
		}
                
                {
                        core::stringw str = L"Load Irrlicht File example - Irrlicht Engine [";
                        str += driver->getName();
                        str += "] FPS:";
                        str += fps;

                        device->setWindowCaption(str.c_str());
                        lastFPS = fps;
                }

        

        device->drop();
        
        return 0;
}
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

You've got a fair number of unnecessary brackets in there...

Move the one after "int fps = driver->getFPS();" to just before "device->drop();", then add the statement "if (fps!=lastFPS)" to right after "int fps = driver->getFPS();". That should solve your compiler error.
Fox
Posts: 14
Joined: Sun Nov 23, 2008 5:59 am
Location: Okinawa, Japan

Post by Fox »

Im very sorry but could you give me an example? i know nothing into what your trying to say.

Code: Select all

 {
                driver->beginScene(true, true, video::SColor(0,200,200,200));
                smgr->drawAll();
                driver->endScene();

				int fps = driver->getFPS();
				if (fps!=lastFPS);
		}
                
                {
                        core::stringw str = L"Load Irrlicht File example - Irrlicht Engine [";
                        str += driver->getName();
                        str += "] FPS:";
                        str += fps;

                        device->setWindowCaption(str.c_str());
                        lastFPS = fps;
                }

				{

        device->drop();

        return 0;
}

is this what you means?
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

Almost:

Code: Select all

        while(device->run())
        if (device->isWindowActive())

        {
                driver->beginScene(true, true, video::SColor(0,200,200,200));
                smgr->drawAll();
                driver->endScene();

            int fps = driver->getFPS();
               if (fps!=lastFPS)
                {
                        core::stringw str = L"Load Irrlicht File example - Irrlicht Engine [";
                        str += driver->getName();
                        str += "] FPS:";
                        str += fps;

                        device->setWindowCaption(str.c_str());
                        lastFPS = fps;
                }

       }

        device->drop();
       
        return 0;
}
Fox
Posts: 14
Joined: Sun Nov 23, 2008 5:59 am
Location: Okinawa, Japan

Post by Fox »

Thanks you soo much!!! it worked!

I have another question(s) tho. How come there is nothing displayed? it's a white screen. And what would i have to change in the code to make my stuff work? like if i want to put my 3d max file in there, i put it into irr-Edit and made it a irr file where do i put it? soo it will load? would i put it here?

Code: Select all

      {
        smgr->loadScene("../../media/example.irr");


        smgr->addCameraSceneNodeFPS();
      } 
Like smgr->loadScene("Documents and settings/scenefile.irr"); ?
Post Reply