irrlicht complete tutorial

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
siyuangao
Posts: 8
Joined: Wed Dec 02, 2009 3:48 pm

irrlicht complete tutorial

Post by siyuangao »

I tried to search a complete tutorial for irrlicht engine, but i just can't find one, the one on the forum is too short and i have problems with it. when i go through the third chapter, the compiler just can't compile the program for me. it give me this error.

74 G:\Desktop\Irrlicht Engine\main.cpp cannot declare variable `rv' to be of type `MyEventReceiver'

This is the key receiver, can anybody help me with that and find me a better tutorial?? Thanks
Ulf
Posts: 281
Joined: Mon Jun 15, 2009 8:53 am
Location: Australia

Post by Ulf »

Did you download the source of Irrlicht? And then run the example solution?

Or did you copy and paste the code from the internet (wiki) into your own project?
You should download the package and load the example solution. It should work, as the environment is set up to compile.
I can hear birds chirping
:twisted:

I live in the Eye of Insanity.
siyuangao
Posts: 8
Joined: Wed Dec 02, 2009 3:48 pm

Post by siyuangao »

I did download the newest version of the engine and all other examples works fine, but when i try to add the code for key controlled movements, the Dev-C++ compiler gives me this kind of error.
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

You should post the whole error message. :roll:

But since i have telepathic capabilities, it can tell you that have to change the signature of the event receiver's OnEvent method to:

Code: Select all

bool OnEvent(const irr::SEvent& event)
"Whoops..."
siyuangao
Posts: 8
Joined: Wed Dec 02, 2009 3:48 pm

Post by siyuangao »

The error message is like this.

32 G:\Desktop\irrlicht\main.cpp cannot declare variable `rv' to be of type `MyEventReceiver'
32 G:\Desktop\irrlicht\main.cpp because the following virtual functions are abstract:
351 F:\irrlicht-1.5.1\include\IEventReceiver.h virtual bool irr::IEventReceiver::OnEvent(const irr::SEvent&)
Here is the code of my sample program

Code: Select all

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

using namespace std;
using namespace irr; 
using namespace core; 
using namespace scene; 
using namespace video; 
using namespace gui; 
bool keys[irr::KEY_KEY_CODES_COUNT];
class MyEventReceiver : public IEventReceiver { 
 public: 
  bool OnEvent(SEvent event)  { 
  if(event.EventType == irr::EET_KEY_INPUT_EVENT){ 
   keys[event.KeyInput.Key] = event.KeyInput.PressedDown; 
   return false; 
  } 
   return false; 
  } 
}; 

#pragma comment(lib, Irrlicht.lib); 
 


int main()
{ 
    IrrlichtDevice* device = createDevice(EDT_OPENGL); 
    IVideoDriver* video = device->getVideoDriver();
    ISceneManager* smgr = device->getSceneManager();
    MyEventReceiver rv; 
    device->setEventReceiver(&rv);
    for(int x=0; x<irr::KEY_KEY_CODES_COUNT; x++) keys[x] = false;
    ISceneNode* cube = smgr->addCubeSceneNode(); 
    cube->setPosition(vector3df(0,0,5));
    while(device->run() && device)
    {
                        if(keys[KEY_KEY_W]) { 
   cube->setPosition(cube->getPosition()+vector3df(0,0,5)); 
                                                            } 
                         video->beginScene(true, true, video::SColor(255,0,0,255)); 
                         smgr->drawAll(); 
                         video->endScene();
    }
    return EXIT_SUCCESS;
}
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

That's exactly what my magic crystal ball told me. So just change the method's signature to the one i already posted and you're fine.

Image
"Whoops..."
siyuangao
Posts: 8
Joined: Wed Dec 02, 2009 3:48 pm

Post by siyuangao »

Thanks :lol:
Kirjuxa
Posts: 13
Joined: Thu Oct 15, 2009 8:55 am

Post by Kirjuxa »

You have no Constructor defined in your class,

i think thats why the compiling crashes
damn, it never works
Post Reply