Page 1 of 1

First tutorial

Posted: Sun Jul 05, 2009 11:17 am
by tomtetlaw
I am doing the first tutorial and whenever I run my code, a window opens, but then instantly closes, sorry for asking all the questions, but I just started. :P

Code: Select all

#include <irrlicht.h>

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

#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif

int main()
{
	IrrlichtDevice *device =
#ifdef _IRR_OSX_PLATFORM_
		createDevice( video::EDT_OPENGL, dimension2d<s32>(640, 480), 16,
		false, false, false, 0);
#else
		createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 16,
		false, false, false, 0);
#endif
	if (!device)
		return 1;

	device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");

	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	IGUIEnvironment* guienv = device->getGUIEnvironment();

	guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
	rect<s32>(10,10,260,22), true);

	IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
	if (!mesh)
		return 1;
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );

	if (node)
	{
		node->setMaterialFlag(EMF_LIGHTING, false);
		node->setMD2Animation(scene::EMAT_STAND);
		node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
	}
	smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));

	while(device->run())
	{
		driver->beginScene(true, true, SColor(255,100,101,140));

		smgr->drawAll();
		guienv->drawAll();

		driver->endScene();
	}
	device->drop();

	return 0;
}
Any help would be appreciated :)

Posted: Sun Jul 05, 2009 12:01 pm
by MarcinS
probably it cant find the mesh model

Posted: Sun Jul 05, 2009 12:36 pm
by tomtetlaw
i changed the code, and now it can load but its still does the same thing

Posted: Sun Jul 05, 2009 12:50 pm
by tomtetlaw
Dw, it fixed itself/.

:/

Posted: Wed Jul 08, 2009 4:31 am
by addalock
I got the same problem that tom had. My code is the same except that I use a D3D9 device type. Help please, this is my first time using Irrlicht

Posted: Wed Jul 08, 2009 7:48 am
by hybrid
Maybe you need a MSVC runtime library of a certain type, or you just lack the Irrlicht.dll in your path, or some model is not found and the app exits right away. Try to run from within MSVC to capture the output, or start manually from CMD window.