CTimer issues [Solved]

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
Atraides
Posts: 18
Joined: Wed Jun 06, 2007 1:09 am
Location: Australia

CTimer issues [Solved]

Post by Atraides »

Hi all

Been trying to implement a timer into my game, but i want to be able to stop and start it at will rather than using the device time. So i have tried to use the CTimer class.

Heres my code for it

Code: Select all

 
CTimer timer;
CTimer.setTimer(0);
CTimer.start();
...
...
However when i do it this way i get 11 unresolved externals saying that im redefining functions that already exist in CTimer.

So i tried making it a pointer

Code: Select all

 
CTimer* timer; // = new CTimer();
CTimer->setTimer(0)
CTimer->start();
...
...
This works until we try to use the timer as of course it isnt initalised.
EDIT: BTW when i use new it gives me the same unresolved externals.

So im a little perplexed .. is there a bug with CTimer or am i doing something wrong.

Any help is greatly appriciated.
Last edited by Atraides on Thu Jul 05, 2007 1:01 pm, edited 1 time in total.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You need to create an instance of the class CTimer. You can do that in either of these two ways...

Code: Select all

CTimer timer;
CTimer* pointerToTimer = new CTimer;
It sounds like you've created your own class named CTimer, right? Well, you will get unresolved symbols if you fail to link the compiled source for the CTimer class. You probably have a file named CTimer.h and one named CTimer.cpp. You need to compile CTimer.cpp and then the resulting object file needs to be linked with your exe. If you're using Visual Studio, you just add the .h and .cpp files to the project.

Travis
Atraides
Posts: 18
Joined: Wed Jun 06, 2007 1:09 am
Location: Australia

Post by Atraides »

Nah, i am just using the CTimer.h that is in the Irrlicht source dir.

Do i need to make my own version of it (.cpp) or can i just use that and instansiate it?

Also i tried your idea and i still get all the unresolved externals.
Cheers
Courtney
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The Irrlicht timer isn't exported from the Irrlicht.dll, so you can't use it directly. Not only that, but the Irrlicht timer uses shared implementation, so even if you could create several individual timers, any function you called on one timer would affect the others.

You are best off to write your own timer implementation. It isn't difficult to do, and if necessary you could copy much of the code you'd need from os.cpp.

Travis
Atraides
Posts: 18
Joined: Wed Jun 06, 2007 1:09 am
Location: Australia

Post by Atraides »

ok cool thanks for your input.

I was leaning towards that anyway as i have read that other people have had problems trying to instansiate the CTimer class.
Cheers
Courtney
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

You can find my solution to that here (Multiple timers): http://www.michaelzeilfelder.de/irrlicht.htm
The website might be a little slow currently.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Atraides
Posts: 18
Joined: Wed Jun 06, 2007 1:09 am
Location: Australia

Post by Atraides »

Thanks for that link..
its the implementation that i found while searching the forums and works quite nicely.
Cheers
Courtney
Post Reply