basic problems

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
Vlad_
Posts: 9
Joined: Fri Jan 04, 2008 9:25 pm
Location: Berlin/Germany

basic problems

Post by Vlad_ »

hi,

i m new to irrlicht. i want to implement a small skybox with stars and i want to get an input from the user to end the programm. according to a tutorial from the site i've implemented this:

Code: Select all

#include <irrlicht.h>
#include <stdio.h>
#include <wchar.h>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

ISceneNode* node = 0;
IrrlichtDevice *device = 0;

class MyEventReceiver : public IEventReceiver
{
public:
	virtual bool OnEvent(SEvent event)
	{
		if (node != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT &&
				!event.KeyInput.PressedDown)
		{
			switch(event.KeyInput.Key)
			{
			case KEY_KEY_W:
			case KEY_KEY_S:
				{
					device->drop();
				}
				return true;
			}
	}


	return false;
	}
};

int main()
{
	MyEventReceiver receiver;
	
	device = createDevice(EDT_OPENGL, dimension2d<s32>(800, 600), 32, false, false, false, &receiver);
		
	device->setWindowCaption(L"Lostsignal v0.1");
	
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	IGUIEnvironment* guienv = device->getGUIEnvironment();
	
	guienv->addStaticText(L"Hello World!", rect<int>(10,10,200,22), false);
	
	smgr->addSkyBoxSceneNode(driver->getTexture("nightsky.jpg"),
							 driver->getTexture("nightsky.jpg"),
							 driver->getTexture("nightsky.jpg"),
							 driver->getTexture("nightsky.jpg"),
							 driver->getTexture("nightsky.jpg"),
							 driver->getTexture("nightsky.jpg"), 0, 0);
	
	smgr->addSphereSceneNode(3.0f, 32, 0, -1, vector3df(2.0f, 2.0f, 2.0f),
											  vector3df(0.0f, 0.0f, 0.0f),
											  vector3df(1.0f, 1.0f, 1.0f));
	
	smgr->addCameraSceneNodeFPS();
	device->getCursorControl()->setVisible(false); 
	
	int lastFPS = -1;
	
	while(device->run())
	{
		driver->beginScene(true, true, SColor(0,0,0,0));
		
		smgr->drawAll();
		guienv->drawAll();
		driver->endScene();
		
		int fps = driver->getFPS();
		
		if(lastFPS != fps)
		{
			wchar_t tmp[1024];
			
			swprintf(tmp, 1024, L"Lostsignal FPS: (%d),(%s)",
					 driver->getName(), fps);
					 
			device->setWindowCaption(tmp);
			
			lastFPS = fps;
		}
	}
	
	device->drop();
	
	return 0;
}
i m using ubuntu 7.10 and geany for programming here is a screenshot from the compiler output... something's not ok with the MyEventReceiver declaration in the main method. is there anything incorrect in the class?

here is the link to the screenshot: http://img229.imageshack.us/my.php?imag ... otoks6.png
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Haha, pretty cool translation. You have a pure virtual method, because your event receiver uses a wrong signature for OnEvent (which changed in Irrlicht 1.4). So you have to use OnEvent( const SEvent& event )
Vlad_
Posts: 9
Joined: Fri Jan 04, 2008 9:25 pm
Location: Berlin/Germany

Post by Vlad_ »

great thank you. so... never believe that the tutorials are correct :D
Vlad_
Posts: 9
Joined: Fri Jan 04, 2008 9:25 pm
Location: Berlin/Germany

Post by Vlad_ »

ok so far... new errors...

Code: Select all

test.cpp:(.text+0x1aa): undefined reference to `irr::createDevice(irr::video::E_DRIVER_TYPE, irr::core::dimension2d<int> const&, unsigned int, bool, bool, bool, irr::IEventReceiver*, char const*)'
i've added the IRRLICHT_SDK_VERSION element to this line:

Code: Select all

device = createDevice(EDT_OPENGL, dimension2d<s32>(800, 600), 32, false, false, false, &receiver, IRRLICHT_SDK_VERSION);
Vlad_
Posts: 9
Joined: Fri Jan 04, 2008 9:25 pm
Location: Berlin/Germany

Post by Vlad_ »

i ve consulted the http://irrlicht.sourceforge.net/docu/namespaceirr.html
function documentation of createDevice.... and i modified the createDevice function again.

now it looks like this, but it is STILL not working... and i wonder why??

screenshot:
http://img516.imageshack.us/img516/2869 ... otoil2.png
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

hybrid wrote:Haha, pretty cool translation. You have a pure virtual method, because your event receiver uses a wrong signature for OnEvent (which changed in Irrlicht 1.4). So you have to use OnEvent( const SEvent& event )
I'm wondering why are people still tripping over this?
Image
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

dlangdev wrote:
hybrid wrote:Haha, pretty cool translation. You have a pure virtual method, because your event receiver uses a wrong signature for OnEvent (which changed in Irrlicht 1.4). So you have to use OnEvent( const SEvent& event )
I'm wondering why are people still tripping over this?
Old demo code, and a blind spot for the sticky FAQ right at the top of this forum section that explains it. Plus, liberalism. Which also causes earthquakes.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Vlad_
Posts: 9
Joined: Fri Jan 04, 2008 9:25 pm
Location: Berlin/Germany

Post by Vlad_ »

solved: parantheses added to (dimension2d.......)
xskinyx
Posts: 25
Joined: Fri Dec 29, 2006 3:28 am

Post by xskinyx »

I just upgraded from a really old version of irrlicht. ALL I had to change was the OnEvent thing. Pretty amazing.
Post Reply