First tutorial

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
tomtetlaw
Posts: 110
Joined: Sun Jul 05, 2009 9:57 am

First tutorial

Post 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 :)
MarcinS
Posts: 25
Joined: Tue Feb 17, 2009 3:14 pm
Location: Poland

Post by MarcinS »

probably it cant find the mesh model
tomtetlaw
Posts: 110
Joined: Sun Jul 05, 2009 9:57 am

Post by tomtetlaw »

i changed the code, and now it can load but its still does the same thing
tomtetlaw
Posts: 110
Joined: Sun Jul 05, 2009 9:57 am

Post by tomtetlaw »

Dw, it fixed itself/.
addalock
Posts: 1
Joined: Wed Jul 08, 2009 4:26 am

:/

Post 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
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
Post Reply