I need some help with my code.. Basically its breaks at the run time.. It is hello world program which works fine in one cpp file but when I started mess around with classes this nasty thing came up..
The error:
Unhandled exception at 0x00141359 in irrGame_ver_0.4.exe: 0xC0000005: Access violation reading location 0xbaadf00d.
The code:
Game.h
Code: Select all
#include "irrlicht.h"
#include "sydney.h"
using namespace irr;
using namespace core;
using namespace gui;
using namespace io;
using namespace video;
using namespace scene;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
class Game
{
private:
IrrlichtDevice *device;
scene::ISceneManager *smgr;
video::IVideoDriver *driver;
gui::IGUIEnvironment *guienv;
scene::ICameraSceneNode *camera;
public:
Game();
~Game();
};
Game.cpp
Code: Select all
#include "Game.h"
Game::Game()
{
{
device = createDevice(video::EDT_DIRECT3D9,core::dimension2d<u32>(800,600),16,false,false,false,0);
driver = device->getVideoDriver();
smgr = device->getSceneManager();
guienv = device->getGUIEnvironment();
camera = smgr->addCameraSceneNodeFPS();
sydney* Sydney = new sydney;
while(device->run())
{
driver->beginScene();
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
}
}
Game::~Game()
{
}
Code: Select all
#include "irrlicht.h"
using namespace irr;
class sydney
{
private:
IrrlichtDevice *device;
sc[code]ene::ISceneManager *smgr;
video::IVideoDriver *driver;
scene::IAnimatedMesh *mesh;
scene::IAnimatedMespublic:
sydney();
~sydney();
};
[/code]
Sydney.cpp
Code: Select all
#include "sydney.h"
sydney::sydney()
{
mesh = smgr->getMesh("../../../media/sydney.md2");
if (!mesh)
{
device->drop();
}
node = smgr->addAnimatedMeshSceneNode(mesh);
if (node)
{
node->setMaterialTexture(0,driver->getTexture("../../../media/sydney.bmp"));
node->setMaterialFlag(video::EMF_LIGHTING,false);
}
}
sydney::~sydney()
{
delete mesh;
mesh = 0;
}
Code: Select all
#include "Game.h"
int main()
{
Game *game = new Game;
return 0;
}
Code: Select all
mesh = smgr->getMesh("../../../media/sydney.md2");[/code]
