Application Error

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
RayOfAsh
Posts: 56
Joined: Wed Dec 24, 2003 4:08 am
Location: San Diego
Contact:

Application Error

Post by RayOfAsh »

http://img.photobucket.com/albums/v317/ ... h/temp.jpg

Whats causing this? I never used to get this problem. I'm using Dev-C++. As you can see it loads fine, but then when it goes to display, it crash's with that error. It compiles just fine, but heres the code anyways:

Code: Select all

#include <irrlicht.h>
#include <iostream>


using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#pragma comment(lib, "Irrlicht.lib")

//main
int main()

{
    IrrlichtDevice *device =
    //createDevice(video::EDT_DIRECTX8, core::dimension2d<s32>(800, 600),32, false, false, false,0);
    //createDevice(video::EDT_DIRECTX9, core::dimension2d<s32>(800, 600),32, true, false, false,0);
    createDevice(video::EDT_OPENGL, core::dimension2d<s32>(800, 600),32, false, false, false,0);
//-----------------------------------------------------------------------------------------------//

    video::IVideoDriver* driver = device->getVideoDriver();
    scene::ISceneManager* smgr = device->getSceneManager();
    driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
    
    device->getFileSystem()->addZipFileArchive("data/data.pk3");
    scene::IAnimatedMesh* bspmesh = 0;
    scene::IAnimatedMesh* mesh = smgr->getMesh("Newmap.bsp");
    
    scene::ISceneNode* bspnode = 0;     
    bspnode = smgr->addOctTreeSceneNode(bspmesh->getMesh(0));
    bspnode->setPosition(core::vector3df(0,0,0));
    bspnode->setScale( irr::core::vector3df(1,1,1) );
    //bspnode->setMaterialType(video::EMT_LIGHTMAP_LIGHTING); //bsp affected by dynamic lights
	//bspnode->setMaterialType(video::EMT_SOLID); //shows only bsp
	//bspnode->setMaterialFlag(EMF_FOG_ENABLE,true); //enables fog
	//driver->setFog(SColor(0,125,125,0),true, 0,4000); //fog color-final values= amount of fog, distance
	
//-----------------------------------------------------------------------------------------------//	
		// create sky box

		scene::ISceneNode* skybox = smgr->addSkyBoxSceneNode( 
		driver->getTexture("Galax_up.jpg"),
		driver->getTexture("Galax_dn.jpg"),
		driver->getTexture("Galax_lf.jpg"),
		driver->getTexture("Galax_rt.jpg"),
		driver->getTexture("Galax_ft.jpg"),
		driver->getTexture("Galax_bk.jpg"));	
	
//-----------------------------------------------------------------------------------------------//

	//wasd navigation
	SKeyMap keyMap[8];

	keyMap[1].Action = EKA_MOVE_FORWARD;
	keyMap[1].KeyCode = KEY_KEY_W;

	keyMap[3].Action = EKA_MOVE_BACKWARD;
	keyMap[3].KeyCode = KEY_KEY_S;

	keyMap[5].Action = EKA_STRAFE_LEFT;
	keyMap[5].KeyCode = KEY_KEY_A;

	keyMap[7].Action = EKA_STRAFE_RIGHT;
	keyMap[7].KeyCode = KEY_KEY_D;
	

//-----------------------------------------------------------------------------------------------//	
	//selector

	scene::ITriangleSelector* selector = 0;
	
	if (bspnode)
	{		
		bspnode->setPosition(core::vector3df(0,-100,0));

		selector = smgr->createOctTreeTriangleSelector(bspmesh->getMesh(0), bspnode, 128);
		bspnode->setTriangleSelector(selector);
		selector->drop();
	}


//-----------------------------------------------------------------------------------------------//	
	//fps cam

	scene::ICameraSceneNode* camera = 0; 
	camera = smgr->addCameraSceneNodeFPS(0,80.0f,300.0f,-1, keyMap, 8); //1st value= obligatory 0-2nd value= mouse sensitivity-3rd value handles cam speed
	camera->setPosition(core::vector3df(150,70,-70)); //1st=pos in x-2nd value= spawn height-3rd=pos in y
	camera->setFarValue (  50000.0f  ) ; //sets the distance for the clipping plane, the bigger the farther
	camera->setFOV(1.4f); // a value of 0.5 makes it look alienish
	//camera->setTarget( core::vector3df(-150,70,0)); //target camera position-3rd value negative =90, positive=0 -1st value (-) rotates camera
	camera->setRotation(core::vector3df(0,270,0)); //rotate the camera x,y,z degrees

	scene::ISceneNodeAnimator* anim = 0; 
	anim = smgr->createCollisionResponseAnimator(selector, camera, core::vector3df(30,50,30),
	core::vector3df(0,-100,0), 100.0f, 
	core::vector3df(0,50,0));
	camera->addAnimator(anim);
	anim->drop();

//-----------------------------------------------------------------------------------------------//	
	// disable mouse cursor

	device->getCursorControl()->setVisible(false);

//-----------------------------------------------------------------------------------------------//	
	// automatic picking

	scene::ISceneNode* selectedSceneNode = 0;
	scene::ISceneNode* lastSelectedSceneNode = 0;

//-----------------------------------------------------------------------------------------------//	
	//draw everything
	

		while(device->run())
		{
		driver->beginScene(true, true, 0);

		smgr->drawAll();

		driver->endScene();
		
        }

	device->drop();
	
	return 0;
}
	
	
Image
Guest

Post by Guest »

Here's your culprit:

Code: Select all

    scene::IAnimatedMesh* bspmesh = 0; 
    scene::IAnimatedMesh* mesh = smgr->getMesh("Newmap.bsp"); 
    
    scene::ISceneNode* bspnode = 0;      
    bspnode = smgr->addOctTreeSceneNode(bspmesh->getMesh(0)); 
My guess is you'll want to store the result from smgr->getMesh into bspmesh, not into mesh.
bspmesh is currently NULL, so bspmesh->getMesh(0) tries to access unallocated memory.
Post Reply