Then, I started using TortoiseSVN to keep up with updates. I tried compiling something and I got a runtime error while debugging. The line where it crashed had the code:
Code: Select all
smgr->drawAll();

Code: Select all
smgr->drawAll();
Code: Select all
#include <irrlicht.h>
#include "CEventReceiver.h"
#pragma comment(lib, "Irrlicht.lib")
using namespace irr;
using namespace core;
using namespace gui;
using namespace io;
using namespace scene;
using namespace video;
// Create the Irrlicht device - global variable
IrrlichtDevice* device = 0;
CEventReceiver EventReceiver;
int main()
{
// Create the Irrlicht device
device = createDevice(EDT_OPENGL, dimension2d<s32>(800, 600), 16, false, true, true, &EventReceiver);
IGUIEnvironment* guienv = device->getGUIEnvironment();
ISceneManager* smgr = device->getSceneManager();
IVideoDriver* driver = device->getVideoDriver();
// Set the window title
device->setWindowCaption(L"Tick Tock Clock");
// Create FPS style camera
ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0, 100, 100);
camera->setPosition(vector3df(0, 0, 0));
camera->setTarget(vector3df(0, 0, 100));
// Use media.dat
device->getFileSystem()->addZipFileArchive("media.dat");
// Define textures
ITexture* TEXWall = driver->getTexture("wall.bmp");
// Add a cube to make it interesting... kind of
ISceneNode* cube = smgr->addCubeSceneNode(10, 0, 0, vector3df(0, 0, 100));
if (cube)
{
cube->setMaterialTexture(0, TEXWall);
cube->setMaterialFlag(EMF_LIGHTING, false);
}
// Let's go!
while (device->run())
{
driver->beginScene(true, true, SColor(255, 0, 0, 50));
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
Code: Select all
First-chance exception at 0x100c09ce in Clocks.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x100c09ce in Clocks.exe: 0xC0000005: Access violation reading location 0x00000000.
Code: Select all
#ifndef __CEVENTRECEIVER
#define __CEVENTRECEIVER
// Include headers
#include <irrlicht.h>
// Use namespaces
using namespace irr;
using namespace core;
// Event Receiver Class
class CEventReceiver : public IEventReceiver
{
public:
CEventReceiver();
virtual bool OnEvent(SEvent Event);
bool getKeyState(EKEY_CODE key);
private:
bool keys[KEY_KEY_CODES_COUNT];
};
#endif
Code: Select all
// Include headers
#include <CEventReceiver.h>
// Constructor
CEventReceiver::CEventReceiver()
{
// Set the keypress array to false
for (s32 i = 0; i < KEY_KEY_CODES_COUNT; i++)
{
keys[i] = false;
}
}
// Event handler function
bool CEventReceiver::OnEvent(SEvent Event)
{
// If the event type is a key input event
if (Event.EventType == EET_KEY_INPUT_EVENT)
{
// Set the corresponding value in the array to the state of the key
keys[Event.KeyInput.Key] = Event.KeyInput.PressedDown;
}
// Return false - ensures FPS cameras will still work
return false;
}
// Get key state
bool CEventReceiver::getKeyState(EKEY_CODE key)
{
return keys[key];
}