Code error

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
darkelf
Posts: 5
Joined: Sun Feb 11, 2007 3:31 pm

Code error

Post by darkelf »

#include <irrlicht.h>
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")

int main () {
IrrlichtDevice *dev = createDevice (EDT_DIRECTX8, core::dimension2d<s32> (800, 600),
32, false, false, false, 0);
IVideoDriver *drv = dev->getVideoDriver ();
ISceneManager *smgr = dev->getSceneManager ();
IGUIEnvironment* guienv = device->getGUIEnvironment();
dev->setWindowCaption (L"test");
guienv->addStaticText (L"Hello World! This is the Irrlicht Software engine!", rect<int>(10,10,200,22), true);
dev->drop ();

return 0;
}


When i try to compile it says:

g:\irrlicht-1.2\include\irrtypes.h(66) : fatal error C1083: Cannot open include file: 'wchar.h': No such file or directory
Error executing cl.exe.

How do i fix it?
Phant0m51
Posts: 106
Joined: Mon Jan 15, 2007 6:07 am

Post by Phant0m51 »

It looks like you have the file wchar.h included into your project, and it can't find the file. Check to see if you do have it included, and if you do and you need it, make sure it's in the right folder.
darkelf
Posts: 5
Joined: Sun Feb 11, 2007 3:31 pm

Post by darkelf »

Thanks.
I already fixed it, i forgot to include dev c++ Libraries.

But i got another error
"node->setMaterialTexture(0, driver->getTexture("G:/irrlicht-1.2/media/sydney.bmp"));"

The compiler says: 'driver' undeclared (first use this fuction)
(each underclared identifier reported only once foe each fuction it appears in.)

Looks like i had to write "using namespace ---" before the code, but i dont know wats it.
Im doing hello world tutorial, first i got "device errors", so i wrote "*dev = create device" instead (it was *device = create device in the tutorial), but i dont kno how to fix the drive thing.
I wrote Using namespaces at the being of the code.
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace std;

#pragma comment(lib, "Irrlicht.lib")
buhatkj
Posts: 444
Joined: Fri Dec 12, 2003 4:53 am
Contact:

Post by buhatkj »

driver is supposed to be the pointer you got bach from your GetVideoDriver() call. in the above code you called it "drv", so you should call it that in your getmesh call too.
My irrlicht-based projects have gone underground for now, but if you want, check out my webcomic instead! http://brokenboomerang.net
darkelf
Posts: 5
Joined: Sun Feb 11, 2007 3:31 pm

Post by darkelf »

Oh, okay.

Thanks

I done compiling, n i got this error:
[Linker error] undefined reference to `irr::createDevice(irr::video::E_DRIVER_TYPE, irr::core::dimension2d<int> const&, unsigned int, bool, bool, bool, irr::IEventReceiver*, char const*)'
ld returned 1 exit status


it should be somethin wrong with "IrrlichtDevice *dev = createDevice (EDT_OPENGL, core::dimension2d<s32> (800, 600),
32, false, false, false, 0); "

But it looks okay to me, Wats wrong with this?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You need to tell the linker to link the irrlicht library file. The simplest thing you could do would be to use one of the examples as a starting point. You can just use the provided project file or makefile [depending on your platform] to build the executable.

Travis
darkelf
Posts: 5
Joined: Sun Feb 11, 2007 3:31 pm

Post by darkelf »

Ok thanks guys for helping me, everything works =)
So i made my first hello world thingie, now i understand how the engine works a bit.

Thanks again.

Ill try to do the next tutorial and see if i can do it alone =P


I made other two demos (both workin ^^), but i checked the CPU, and it was 98%, is there a way for make it less?
the FPS was 700
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The render loop runs as fast as it possibly can, and this will consume all of the cpu time that it is given. All modern desktop operating systems use preemptive scheduling, so this isn't really a problem...

Each process is given a priority. If there is one program that wants to burn cpu cycles, it will be allowed to do so as long as a process with a priority of greater or equal value does not want some cpu time. If you have two processes of the same priority that want 100% of the cpu, the scheduler will give each of them as much time as it can, which comes out to about 50% each. If there are 3, then they get 33%. In other words, your system performance should not be significantly impacted when a default priority process runs at 100% cpu.

If you really think it is important to not consume CPU time, you can periodically suspend your program with a call to Sleep() on windows or usleep() on *nix environments. I believe that a change was added to the driver to allow sleeping, but I haven't looked at it.

Travis
Post Reply