Very N00b Question

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.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I think you need to spend a bit more time understanding irrlicht before you actually go and make a project...

The timer class given to you above does not have any rendering code in it, so of course it won't render itself on the screen and as you've not written any code to render it yourself that would be why it's not appearing...

If you look at the tutorials you'll find a way to get text and numbers rendered on the screen, but you really should have worked through the tutorials before embarking on your own project...
Image Image Image
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

JP wrote:Well you could just put a check into an update function of the timer so if it's time to call the callback it's called. So all you'd have to do is add into your while (device->run()) loop the line 'timer->update();'

And of course declare the function ;)
No, but thats it what I was talking about.
"While", is framerate dependet.
if not, if I set it independent, I will have let say un update every 60 Hz. for this functions.
This is not enough accuracy.
Should it be something multitheath.
In this way and asuuming that the threath is enought calling then it wil work.

is this the only way of implementation?
declan07
Posts: 6
Joined: Tue Feb 12, 2008 1:22 pm

Post by declan07 »

Its just ive had to learn irrlicht quick because im doing a project for uni and ive had to change engine at last min because of a problem with the uni engine
chaotischerapostel
Posts: 19
Joined: Wed Jan 23, 2008 7:10 am

Post by chaotischerapostel »

declan07 wrote:What would be the rendering code?
Ok I'm sorry but I can see why the more advanced users get annoyed about questions, I'v started Irrlicht recently and even if you need to have your project fineshed soon you'll have to do most of it yourself, I dought anyone will do it for you. Read the tutorials and documentation. You can teach your self just about everything the engine has to offer with the documentation.
FuzzYspo0N wrote:Device->getTimer()->

that returns a bunch of things regarding time. getTime from that gives u a number, divide the number by a thousand and u get seconds.

Im sure u can figure out how to use the seconds the timer has been running... or make a new timer object per application of timer
That right there tells me everything I need to know about timers and how to use them. If you can't figure out how to make a timer for your game with this then you should probably pick a different, less complex hobby(probably something that you could'nt hurt your self doing because you'll need some common sense for that, ex. coloring books)

Sorry that might have been out of place on my part but STUPID people bother me.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

@declan07: I'm not sure how much time you have, how good programmer are you, at which progress is your project but maybe my not-ready-for-use engine could help you start.. but be warned, it's unusable now but you can learn from the design and see how I do things going through the docs.

OR, following chaotischerapostel, rethink your project in respect of your ETA, see if you're capable of doing what you want. If you can't choose another project which you Can finish. If you can, set yourself a schedule each day to learn what you need and start working really hard, depending on how much time you have left.

P.S
If you want a quick sum of tutorials and info check the Irrlicht Wiki.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

declan07 wrote:Its just ive had to learn irrlicht quick because im doing a project for uni and ive had to change engine at last min because of a problem with the uni engine
You poor dear. Here, have some code.

Code: Select all

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

using namespace irr;
#pragma comment(lib, "Irrlicht.lib")

int main()
{
	IrrlichtDevice *device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480));

	video::IVideoDriver* driver = device->getVideoDriver();

	// You can use \tools\IrrFontTool\newFontTool to create fonts.
	gui::IGUIFont* font = device->getGUIEnvironment()->getFont("../../media/fonthaettenschweiler.bmp");

	u32 startTime = device->getTimer()->getTime();
	const u32 countDownTime = 10000; // = 10 seconds

	while(device->run())
	{
		driver->beginScene(true, true, video::SColor(0,120,102,136));

		u32 now = device->getTimer()->getTime();
		core::stringw text;
		video::SColor textColour(255,0,255,0);

		if(now < startTime + countDownTime)
		{
			u32 elapsedSeconds = 1 + (startTime + countDownTime - now) / 1000; // round down
			text = L"Time ";
			text += elapsedSeconds;

			if(elapsedSeconds <= (countDownTime / 3000))
				textColour.set(255, 255, 0, 0);
		}
		else
		{
			char asciiText[] = { 89, 111, 117, 32, 102, 97, 105, 108, 32, 105, 116 };
			text = asciiText;
			textColour.set(255, 255, 255, 255);
		}

		font->draw(text.c_str(), 
			core::rect<s32>(5,5,0,0),
			textColour);

		driver->endScene();
	}

	device->drop();

	return 0;
}
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

Rogerborg, but I am still think that this doens work for for example make a functions make called every 100 ms for example.
if we are assuming that besides that checking we wil have rendering, physic, ia , other logic, etc. Then checking in a loop if the time is ==100 will fail because maybe it jumps (due to framerate) from 98 to 102.
So you'll never wil have the call.

Thats why I told that must be done with some other threat.
In allegro you declared some timer that runs in "parallel" and when time is proper call to the function that you passed to it. (Beside you must Lock some variables and if remember well, the function too).

In irrlicht the only way for implementin this will be another threath right? and mixed with for example your timer. Or is this another way.
Thanks.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

The code above does what the original poster asked for. I'm not sure what problem you're trying to solve.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply