Code: Select all
error :Unhandled exception at 0x0042771f in irrGame.exe: 0xC0000005: Access violation reading location 0x00000001.
Code: Select all
//gameManager.h
#ifndef GAMEMANAGER_H
#define GAMEMANAGER_H
#include <iostream>
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
class CGameManager : public IEventReceiver
{
public:
CGameManager();
virtual ~CGameManager();
void pause();
IrrlichtDevice* getDevice();
IVideoDriver* getDriver();
ISceneManager* getSceneManager();
IGUIEnvironment* getGUIEnvironment();
virtual bool OnEvent(SEvent event);
bool CreateDevice(int width, int height, int bitDepth);
void update();
protected:
private:
//Device parameters -> renderer|screen size|colour depth|full window|shadows|vsync|input device
IrrlichtDevice* device;
IVideoDriver* driver;
ISceneManager* smgr;
IGUIEnvironment* guiEnv;
};
#endif
Code: Select all
//gameManager.cpp
#include "GameManager.h"
//! Default constructor
CGameManager::CGameManager()
{
std::cout << "-- Game Manager created!\n";
}
//! Default destructor
CGameManager::~CGameManager()
{
}
void CGameManager::pause()
{
int pNum;
std::cin >> pNum;
}
bool CGameManager::CreateDevice(int width, int height ,int bitDepth)
{
//Device parameters -> renderer|screen size|colour depth|full window|shadows|vsync|input device
device = createDevice(EDT_DIRECT3D9, dimension2d<s32>(width, height), bitDepth, false, false, true, this);
if (device == NULL)
device = createDevice(EDT_OPENGL, dimension2d<s32>(width, height), bitDepth, false, false, true, this);
driver = device->getVideoDriver();
smgr = device->getSceneManager();
guiEnv = device->getGUIEnvironment();
return 1;
}
bool CGameManager::OnEvent(SEvent event)
{
if (!driver)
return false;
return true;
}
IrrlichtDevice* CGameManager::getDevice()
{
return device;
}
IVideoDriver* CGameManager::getDriver()
{
return driver;
}
ISceneManager* CGameManager::getSceneManager()
{
return smgr;
}
IGUIEnvironment* CGameManager::getGUIEnvironment()
{
return guiEnv;
}
void CGameManager::update()
{
//this is where the error occurs
driver->beginScene(true, true, video::SColor(0,100,100,100));
smgr->drawAll();
guiEnv->drawAll();
driver->endScene();
}
I have stepped through it, and the device, driver, smgr, and guiEnv are all created, so I don't quite understand why I am getting this error....Please help, thanks in advance....