Sunday, October 25, 2009

Irrlicht Engine – Easy Tutorial - Intro

Irrlicht Engine is a powerful way to make your own game even if you are not pro at game development. I decided to write a simple and easy tutorial for beginners on how to make games with Irrlicht. I’ll make it in several parts with a lot of examples.
What do you need to know for this tutorial?

  • Basic programming
  • C++

What do you need for this tutorial?
  • Irrlicht -
  • C++ IDE – I use Eclipse - for many of my projects, I’ll use it here too.
  • If you want to use Irrlicht with DirectX9 you must get DirectX SDK and build Irrlicht with it. I am lazy so I’ll use OpenGL.

How to make Eclipse build your project with Irrlicht support. Of course you don’t need to use Eclipse, if so skip this part.

Create new Eclipse project – in my case I’ll call it IrrlichtTutorial.

To add Irrlicht to your project you need to select it and go to Project->Properties from the main menu tab.

Then select C/C++ Build -> Settings. You will see something like this:

Go to GCC C++ Compiler->Directories and add the path to Irrlicht includes in my case D:\irrlicht-1.6\include.

Then go to the C++ Linker part and select Libraries Tab. Add Irrlicht in the first field (Libraries) and the path to the appropriate Irrlicht lib subfolder in the second. In my case it would be D:\irrlicht-1.6\lib\Win32-gcc.

That’s it. Let’s test if we can build a project. Of course to run an Irrlicht project you must have Irrlicht.dll in your path. If you use multiple Irrlicht versions you can add the correct dll in your project folder.
Now, lets build something simple yet useful. A simple window doing nothing is just fine. Here is the code:

#include <irrlicht.h>

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

int main()
 IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<u32>(800, 600), 16,
   false, false, false, 0);

 if (!device)
  return 1;

 IVideoDriver* driver = device->getVideoDriver();
 ISceneManager* sceneManager = device->getSceneManager();
 IGUIEnvironment* guiEnvironment = device->getGUIEnvironment();


  driver->beginScene(true, true, SColor(255,50,130,50));

 return 0;

And what we’ve done:

An empty window. Cool!

Next: Irrlicht Engine - Easy Tutorial - Basics

No comments: