User Tools

Site Tools


LAB1: Ogre Startup Sequence

This first Lab assignment is intended to get the Ogre3D environment started. Getting the development environment set up and configured can be a little tricky for the first time, so this Lab will be solely used to get the “Hello World” of Ogre3D built.
There will be a pdf guide that will take you through the basic application step by step. I strongly encourage you to try to understand the steps not just writing it down like a zombie parrot, as the follow up Labs will all be built on top of the base you create in Lab 1.


Discussion thread for this lab will be on Piazza: Lab 1 Discussion Thread. Please don't hesitate to ask questions or comment on the Lab assignment.


- Download and install C++ development environment, the instructions will assume you are using the MS Visual C++ Express 2010 environment, which you can get for free. You're free to use other environments or platforms as long as you take care of making it work on your own (with the help of the Internet).

  1. Download and install OGRE 1.9 SDK for Visual C++ 2010 (32-bit). I recommend extracting this to a folder with a relatively short path and no spaces. E.g. into “C:\OgreSDK”. You are free to use other versions, but be advised you will be rowing your own boat if problems arise :)

To prepare your environment and project you need to:

  1. Create a system environment variableOGRE_HOME” that points to Ogre SDK folder. You can then refer to this variable in your project setup as $(OGRE_HOME). This is so that you can easily take your project to a different machine where Ogre might be installed in a different folder. If each machine defines this variable, the project should be able to find the needed includes and libraries (see below). example: C:\Ogre1.9_vc100\OgreSDK_vc10_v1-9-0
  2. The Ogre run-time libraries (DLLs) are in folders called bin/debug and bin/release inside the SDK folder. You need to add these two folders to your system path variable so that the system can find them when you launch your application.
  3. It is good to organize all your lab source code, from the very beginning of this class to avoid a complete mess later. VC++ helps you organize the code into solutions and projects. A solution is really a collection of projects, which is a great way to keep track of labs. Once you launch VC++, create a new project called “Lab1” inside a new solution called “GEDE2013” (it is a good idea to let VC++ create a folder for your solution - use the check box - and then your projects will appear inside that folder). The project should be a WIN32 Console Application and completely empty. You will write it from scratch.
  4. Right-click on your project inside VC++ project explorer and choose properties. Add Ogre folders and files in several locations within the properties:
  5. Change your build output directory: Configuration Properties→General→Output Directory
    Add $(ProjectName)\ at the end of the output directory so it will look like:$(SolutionDir)$(Configuration)\$(ProjectName)\
    This will help with organizing the builds for each lab project.
  6. Add additional include libraries: C/C++→General→Additional Include Directories =


    If the C/C++ tab is missing. For some reason, with some versions of Visual Studio you will need to have created a cpp file in order to get the C/C++ tab in the configuration properties, so adding a main.cpp file with a basic “hello world” to the project and building it will suffice. )

  7. Add connections to additional Ogre and input libraries: Linker→Input→Additional Dependencies


    Add this to the end of the current string, do not replace it, and make sure to seperate it with a semicolon.

  8. Also you will need to add additional Library folders where the Ogre specific libraries and the required boost libraries are stored: Linker→General→Additional Library Directories =

  9. If you are using a different version of Visual studio than 2010, make sure to be using the vc100 toolset
    Project Configuration->General->Platform Toolset = Visual Studio 2010 (v100)


    If the v100 toolset is not available, you will need to install VS 2010, or at least the correct VC++ toolset

  10. Copy plugins_d.cfg and resources_d.cfg from the SDK bin/debug folder into your own GEDE2013/debug (or wherever your own compiled executables will be placed) if you followed section 5, thats where you will want to copy the files.


    You need to modify the resources_d.cfg file by replacing the relative path of the resources with an absalute path. Example: where the Ogre SDK path is “C:\Ogre1.9_vc100\OgreSDK_vc10_v1-9-0”
    Make sure to change all references of ../../ to your absalute path.
    Notice that Ogre cfg file wants forward slashes!

Lab Project

You should now follow the guide from “Ogre3D 1.7 Beginners Guide by Felix Kerger” which you can get Here.
For this Lab we will only do the sections 1 - 3 of the Ogre 3D beginners Guide. The rest will be covered in the next Lab assignment.

The first 2 labs will be following this guide and getting familiar with the Ogre3D environment.


After line 2 in section 2 of the Guide, please add this line to the code. Since the Ogre 1.9 default Scene Manager does not set the ambient light by default like back in 1.7, we have to that our selves.

	sceneManager->setAmbientLight(Ogre::ColourValue(0.3f, 0.3f, 0.3f));

Your final results should look something like this:


 #include "OGRE/Ogre.h"
 int main()
 	Ogre::Root* root = new Ogre::Root("plugins_d.cfg");
	if(!root->showConfigDialog()) {
		return -1;
	Ogre::RenderWindow* window = root->initialise(true, "Ogre3D Beginners Guide");
	Ogre::SceneManager* sceneManager = root->createSceneManager(Ogre::ST_GENERIC);
	Ogre::Camera* camera = sceneManager->createCamera("Camera");
	Ogre::Viewport* viewport = window->addViewport(camera);
	//Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Ogre SDK/OgreSDK_vc10_v1-8-1/media/packs/","Zip");
	Ogre::String sectionName, typeName, dataName;
	Ogre::ConfigFile cf;
	Ogre::ConfigFile::SectionIterator sectionIter = cf.getSectionIterator();
	while(sectionIter.hasMoreElements()) {
		sectionName = sectionIter.peekNextKey();
		Ogre::ConfigFile::SettingsMultiMap *settings = sectionIter.getNext();
		Ogre::ConfigFile::SettingsMultiMap::iterator i;
		for( i = settings->begin() ; i != settings->end() ; ++i ) {
			typeName = i->first;
			dataName = i->second;
			Ogre::ResourceGroupManager::getSingleton().addResourceLocation(dataName, typeName, sectionName);
	Ogre::Entity* ent = sceneManager->createEntity("Sinbad.mesh");
	return 0;

When You Are Finished

Upload your commented source files into Lab1 in MySchool (zip them up if more than one). The lab projects will not be graded, but their completion counts towards your participation grade.

And check out the next Lab :)

/var/www/ailab/WWW/wiki/data/pages/public/t-gede-14-1/lab1.txt · Last modified: 2014/01/20 16:34 by marino