It stops when the loading part is ready (loading of the terrain heightmap and so on)
Oh miracle, the Debugger talks to me
I just waited a bit while the program was stuck, and now the debugger says: "Your programm has caused an access violation" and this line is marked:
Code: Select all
vector3df pos = camera->getPosition();
EDIT: You want me to post the whole code? Ok then:
Code: Select all
#include <irrlicht.h>
#include <iostream.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")
IAnimatedMeshSceneNode* node = 0;
IrrlichtDevice* device = 0;
ICameraSceneNode* camera =0;
float mwheel;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
switch(event.EventType)
{
case EET_MOUSE_INPUT_EVENT:
{
switch(event.MouseInput.Event)
{
case EMIE_MOUSE_WHEEL:
{
mwheel = event.MouseInput.Wheel;
}
}
}
}
return false;
}
};
void RTS_camera()
{
position2d<f32> p = device->getCursorControl()->getRelativePosition();
if(p.X <= 0.1)
{
vector3df pos = camera->getPosition();
pos.Z = pos.Z + 5;
camera->setPosition(pos);
}
if(p.X >= 0.9)
{
vector3df pos = camera->getPosition();
pos.Z = pos.Z - 5;
camera->setPosition(pos);
}
if(p.Y <= 0.1)
{
vector3df pos = camera->getPosition();
pos.X = pos.X + 5;
camera->setPosition(pos);
}
if(p.Y >= 0.9)
{
vector3df pos = camera->getPosition();
pos.X = pos.X - 5;
camera->setPosition(pos);
}
if(mwheel == 1)
{ vector3df pos = camera->getPosition();
pos.Y = pos.Y - 50;
camera->setPosition(pos);
mwheel = 0;
}
if(mwheel == -1)
{ vector3df pos = camera->getPosition();
pos.Y = pos.Y + 50;
camera->setPosition(pos);
mwheel = 0;
}
}
int main()
{
MyEventReceiver receiver;
device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640,480),32, false, true,false, &receiver);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
ICameraSceneNode *camera;
camera = smgr->addCameraSceneNodeFPS (0, 100, 500);
camera->setInputReceiverEnabled (false);
camera->setPosition(core::vector3df(0,1000,0));
camera->setRotation(vector3df(90.0f,0.0f,0.0f));
camera->setFarValue(12000.0f);
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode("media/terrain-heightmap.bmp");
terrain->setScale(core::vector3df(40, 4.4f, 40));
terrain->setMaterialFlag(video::EMF_LIGHTING, false);
terrain->setMaterialTexture(0, driver->getTexture("media/terrain-texture.jpg"));
terrain->setMaterialTexture(1, driver->getTexture("media/detailmap3.jpg"));
terrain->setMaterialType(video::EMT_DETAIL_MAP);
terrain->scaleTexture(1.0f, 20.0f);
while(device->run())
{
RTS_camera();
driver->beginScene(true,true,SColor(255,0,0,140));
smgr->drawAll();
device->getGUIEnvironment()->drawAll();
driver->endScene();
}
device->drop();
return 0;
}