Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

Irrlicht: Creating a Basic Template Application

Save for later
  • 3 min read
  • 21 Nov 2011

article-image

(For more resources related to this topic, see here.)

Creating a new empty project

Let's get started by creating a new project from scratch. Follow the steps that are given for the IDE and operating system of your choice.

Visual Studio

Open Visual Studio and select File | New | Project from the menu. Expand the Visual C++ item and select Win32 Console Application. Click on OK to continue:

irrlicht-creating-basic-template-application-img-0

In the project wizard click on Next to edit the Application Settings. Make sure Empty project is checked. Whether Windows application or Console application is selected will not matter. Click on Finish and your new project will be created:

irrlicht-creating-basic-template-application-img-1

Let's add a main source file to the project. Right-click on Source Files and select Add New Item...|. Choose C++ File(.cpp) and call the file main.cpp:

irrlicht-creating-basic-template-application-img-2

CodeBlocks

Use the CodeBlocks project wizard to create a new project as described in the last chapter. Now double-click on main.cpp to open this file and delete its contents. Your main source file should now be blank.

Linux and the command line

Copy the make file of one of the examples from the Irrlicht examples folder to where you wish to create your new project. Open the make file with a text editor of your choice and change, in line 6, the target name to what you wish your project to be called.

Additionally, change, in line 10, the variable IrrlichtHome to where you extracted your Irrlicht folder. Now create a new empty file called main.cpp.

Xcode

Open Xcode and select File | New Project. Select Command Line Tool from Application. Make sure the type of the application is set to C++ stdc++:

irrlicht-creating-basic-template-application-img-3

When your new project is created, change Active Architecture to i386 if you are using an Intel Mac, or ppc if you are using a PowerPC Mac.

Create a new target by right-clicking on Targets, select Application and click on Next. Target Name represents the name of the compiled executable and application bundle:

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at £16.99/month. Cancel anytime

irrlicht-creating-basic-template-application-img-4

The target info window will show up. Fill in the location of the include folder of your extracted Irrlicht package in the field Header Search Path and make sure the field GCC_ PREFIX_HEADER is empty:

irrlicht-creating-basic-template-application-img-5

Right-click on the project file and add the following frameworks by selecting Add Existing Frameworks...|:

  • Cocoa.framework
  • Carbon.framework
  • IOKit.framework
  • OpenGL.framework

Now, we have to add the static library named libIrrlicht.a that we compiled in Chapter 1, Installing Irrlicht. Right-click on the project file and click on Add | Existing Frameworks.... Now click on the button Add Other... and select the static library.

Delete the original compile target and delete the contents of main.cpp.

Time for action – creating the main entry point

Now that our main file is completely empty, we need a main entry point. We don't need any command-line parameters, so just go ahead and add an empty main() method as follows:

int main()
{
return 0;
}

If you are using Visual Studio, you need to link against the Irrlicht library. You can link from code by adding the following line of code:

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

This line should be placed between your include statements and your main() function.

If you are planning to use the same codebase for compiling on different platforms, you should use a compiler-specific define statement, so that this line will only be active when compiling the application with Visual Studio.

#if defined(_MSC_VER)
#pragma comment(lib, "Irrlicht.lib")
#endif