Weird Problem

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
rz950
Posts: 9
Joined: Thu Dec 30, 2004 1:57 pm

Weird Problem

Post by rz950 »

I've been trying this engine for a game I'm working on and the stuff I have worked on compile but when I try to run it, it gives an windows crash error. I don't know why, so I decided to paste the code here and someone hopefully tell me whats wrong.

Code: Select all

#include <irrlicht/irrlicht.h>
#include <iostream>
using namespace irr;

int main()
{
        // starts up the engine
        IrrlichtDevice *device = createDevice(video::EDT_OPENGL,
            core::dimension2d<s32>(640,480), false);
            
        video::IVideoDriver* driver = device->getVideoDriver();
        scene::ISceneManager* smgr = device->getSceneManager();
        gui::IGUIEnvironment* env = device->getGUIEnvironment();

        driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
          
        device ->setWindowCaption(L"StarKraft3D");
                
        // add camera
        scene::ICameraSceneNode* camera =
            smgr->addCameraSceneNodeFPS(0,100.0f,1200.0f);
        camera->setPosition(core::vector3df(1900*2,255*2,3700*2));
        camera->setTarget(core::vector3df(2397*2,343*2,2700*2));
        camera->setFarValue(12000.0f);
        
        // terrain loading 
        // TODO: Add XML support for loading texture and terrain
        scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
             "../media/grass-heightmap.jpg");
        
        terrain->setScale(core::vector3df(40, 4.4f, 40));
        terrain->setMaterialFlag(video::EMF_LIGHTING, false);
        terrain->setMaterialTexture(0, driver->getTexture(
            "../media/grass.jpg"));
        
        // create triangle selector for the terrain	
        scene::ITriangleSelector* selector =
            smgr->createTerrainTriangleSelector(terrain, 0);
        terrain->setTriangleSelector(selector);
        selector->drop();

        // create collision response animator and attach it to the camera
        scene::ISceneNodeAnimator* anim = smgr->   createCollisionResponseAnimator(
            selector, camera, core::vector3df(60,100,60),
            core::vector3df(0,0,0), 
            core::vector3df(0,50,0));
        camera->addAnimator(anim);
        anim->drop();
   
        //deletes device 
        device->drop();
	    return 0;
}   

Other then my coding style, whats wrong with this code? It compiles fine but automatically gives and error when you try to run it.
Guest

Post by Guest »

Can you not step through with an IDE?

If not just put a cout << "Now doing : xyz" after every 10 lines or so to narrow the problem down a bit. It might be that your dropping a reference to an object that you shouldn't.
hybrid

Post by hybrid »

It would really help to know the exact error message.
after-life
Posts: 69
Joined: Wed Mar 30, 2005 8:16 am
Location: Keerbergen, Belgium

Post by after-life »

put the dll file in the same directory
if its something else, pls give us the error message
Post Reply