first: please excuse my bad english.
I recently started with Irrlicht and I wanted to do a fps. I started and when I was ready with the collision, I noticed that my project wasn't really too good structured. So I started the project new and wanted to make some classes to have 'good c++ style'. But now I've got another problem: I can compile it under Dev-Cpp and then execute it. But there's only a black screen and there comes an error message that says something wants to read '0xffffffff'. When I use Dev-Cpp's debugging mode the screen turns white and it only says that there was a segmention fault. I don't know what to do. Perhaps you could help me. Thx.
Here's the code:
main.cpp
Code: Select all
#include <irrlicht.h>
#include "graphics.h"
using namespace irr;
int main(){
system sys;
map simple_room(sys);
simple_room.lighting(false);
sys.fpscamera();
sys.cursorVisible(false);
while(sys.active()){
sys.begin();
sys.draw();
sys.end();
}
}
Code: Select all
#ifndef _GRAPHICS_H_
#define _GRAPHICS_H_
#include <irrlicht.h>
using namespace irr;
class map;
class system;
class system{
protected:
IrrlichtDevice *device;
video::IVideoDriver *driver;
scene::ISceneManager *manager;
public:
system(){
device = createDevice(video::EDT_OPENGL,core::dimension2d<s32>(1600,1200),16,true,false,false);
driver = device->getVideoDriver();
manager = device->getSceneManager();
}
~system(){
device->drop();
}
scene::IAnimatedMesh* mesh(const c8* name){
return manager->getMesh(name);
}
scene::ISceneNode* bigNode(scene::IAnimatedMesh* m){
return manager->addOctTreeSceneNode(m->getMesh(0));
}
void fpscamera(){
manager->addCameraSceneNodeFPS();
return;
}
void cursorVisible(bool visible){
device->getCursorControl()->setVisible(visible);
return;
}
bool active(){
return device->run();
}
void begin(){
driver->beginScene(true,true,video::SColor(0,200,200,200));
return;
}
void end(){
driver->endScene();
return;
}
void draw(){
manager->drawAll();
return;
}
};
class map{
friend scene::ISceneNode* bigNode(scene::IAnimatedMesh*);
protected:
scene::IAnimatedMesh* mesh;
scene::ISceneNode* node;
public:
map(system s){
mesh = s.mesh("maps/simple_room.x");
node = 0;
node = s.bigNode(mesh);
}
void lighting(bool activated){
node->setMaterialFlag(video::EMF_LIGHTING,activated);
return;
}
scene::IAnimatedMesh* returnMesh(){
return mesh;
}
};
#endif