Download the prebuilt Ogre SDK for your platform and compiler from www.ogre3d.org/index.php?option=com_content&task=view&id=411&Itemid=131
Run the installer (i.e., open the SDK you downloaded). This installs Ogre and its dependencies on your system
. Install Ogre to a directory with no spaces in the name (e.g., C:\OgreSDK). While this isn’t absolutely necessary, it helps avoid problems that may occur when using additional non-standard Ogre components.
Ogre is now installed and ready to be used with Visual C 2005 Express Edition. You should be able to build the demos in the samples folder under the Ogre SDK. Ogre is supported on a number of other platforms including Mac OS X and several popular Linux distributions including Debian and Ubuntu. Ogre is also supported on Gentoo and Fedora using the source code, but prebuilt SDKs aren’t available. You can find more information on installing Ogre on these platforms at www.ogre3d.org/wiki/index.php/Installing_An_SDK
To develop your own Ogre application, you must configure your project to use Ogre. A setup guide is available at www.ogre3d.org/wiki/index.php/SettingUpAnApplication
. The guide walks through creating an Ogre project using several different compilers and IDEs on various platforms. Here we explain how to set up an Ogre project using Visual C 2005 Express Edition.
Create a new Win32 Console Application. When the Win32 Application Wizard opens, click Application Settings. Change the type to a Windows application
and select Empty project from the Additional options. Click Finish.
Next you need to tell your application where to find the Ogre header and library files. Add a .cpp file to your project—the C/C Configuration Properties won’t be visible until you create the .cpp file. Open the project’s Properties dialog. In the Configuration Properties -> C/C -> General tab, add the Ogre include folder, $(OGRE_HOME)\include, to the Additional Include Directories field. Also add $(OGRE_HOME)\samples\include folder. This folder holds the header files for the Ogre demos and examples. OGRE_HOME is an environment variable created by the Ogre SDK installer. It points to the location of the Ogre SDK on your system. If you used the source code distribution you’ll need to manually create an environment variable pointing to the Ogre directory. Common convention is to name this variable OGRE_SRC, then use that in place of OGRE_HOME.
In the Configuration Properties -> Linker -> General tab, add the Ogre library folder, $(OGRE_HOME)\lib, to the Additional Library Directories field. Your application will be directly dependent on several Ogre .lib files. In the Configuration Properties -> Linker -> Input tab, add the OgreMain_d.lib and OIS_d.lib (for Debug mode) or the OgreMain.lib and OIS.lib (for Release mode) to the Additional Dependencies field.
Test your project settings by copying
the code example from www.ogre3d.org/wiki/index.php/SettingUpAnApplication#Your_First_Application
into your .cpp file. If you configured the settings correctly, the project will build successfully, but the program won’t run—it needs to be in the same folder as the Ogre .dll files. You can copy the project’s .exe file to the OgreSDK\bin\debug folder. Now the program runs fine. The code you copied creates a black screen with the Ogre logo and some frame rate statistics. Press Escape to exit.
There are several ways you can avoid having to copy your project’s .exe file into the Ogre SDK’s bin folder manually. You can copy the entire bin folder from the Ogre SDK into your projects directory—you’ll also need to copy the media
folder. Then in the Configuration Properties -> Linker -> General tab, set the Output File field to “..\bin\debug\$(ProjectName).exe” (replace debug with release for Release mode). The project’s .exe file is created in the bin\debug folder in your project folder. Alternatively, you can set the field to “$(OGRE_HOME)\bin\$(ConfigurationName)\$(ProjectName).exe” to create the .exe file directly in the Ogre SDK’s bin folder.
You’re now setup to create your own Ogre applications
, but Ogre doesn’t support sound. To add sound to an Ogre application, you can install OgreAL, an add-on that allows you to easily use the OpenAL audio library in an Ogre application. For more information on OgreAL check out the forum at http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
. The OgreAL installation is a little more involved than the Ogre installation. Here we walk you through installing OgreAL and configuring your project to use it.
You’ll need to download several packages to get OgreAL up and running. First, download the OgreAL source code from the SVN repository. If you have SVN software
that runs from the command line, use the command “svn co https://svn.sourceforge.net/svnroot/ogreal/trunk/OgreAL-Eihort OgreAL”. If you don’t have SVN software installed, you can download the Windows TortoiseSVN client from tortoisesvn.net. TortoiseSVN is an extension to Windows Explorer. It provides and easy to use graphical interface. You can find a command line SVN client for other platforms at subversion.tigris.org/project_packages.html.
To download the OgreAL source code using TortoiseSVN, open Windows Explorer and create a folder to download the files to. Right click on the folder and select SVN Checkout. A dialog box opens. Enter the URL repository svn.sourceforge.net/svnroot/ogreal/trunk/OgreAL-Eihort. Click OK. The OgreAL files are downloaded to the folder your selected. You also need to download the OpenAL packages. Go to www.openal.org/downloads.html and download the OpenAL 1.1 Installer, OpenAL 1.1 SDK and the freealut Binary ZIP. Also go to xiph.org/downloads/ and download the libogg and libvorbis packages. These are audio library packages used by OgreAL. The OgreAL, libogg and libvorbis folders must all be in the same directory level. We suggest creating a folder to hold all three. Rename the libogg folder to ogg and the libvorbis folder to vorbis. After renaming the folders, open the ogg\win32\ogg.dsw file. Ogg.dsw is a VC 6 project. When you open it in Visual C 2005 you’ll be prompted to convert the project files to the VC 2005 format—click yes to all. The projects should build fine with no modifications. Build in both Debug and Release modes.
Next install the OpenAL components. Run the OpenAL and OpenAL SDK installers. These install the necessary OpenAL files. Create an environment variable called OPENAL_SDK that points to the directory where you installed the OpenAL SDK (the default on Windows is C:\Program Files\OpenAL 1.1 SDK). Extract the freealut-1.1.0-bin.zip folder (for organizational purposes, we extracted it to the same folder containing the OgreAL, ogg and vorbis folders). Create an environment variable called ALUT_BIN that points to the freealut-1.1.0-bin folder.
Now you can build OgreAL. Open the OgreAL.sln file in the folder you downloaded the SVN files to. Open the Properties dialog for the OgreAL project—the other projects are demos and aren’t necessary. Open the Configuration Properties -> Linker -> General tab. Change $(OGRE_HOME)\lib\$(ConfigurationName) to $(OGRE_HOME)\lib\ for both Debug and Release. Build the project in both Debug and Release modes. OgreAL is now installed on your computer.
To use OgreAL in your Ogre application, you need to follow steps similar to setting up the project to use Ogre. First, create an environment variable called OGREAL_HOME that points to the folder containing the OgreAL download. Open your project’s Properties dialog. Open the Configuration Properties -> C/C -> General tab. Add the following include directories:
Next open the Configuration Properties -> Linker -> General tab and add the OgreAL library directory, $(OGREAL_HOME)\lib\$(ConfigurationName). Now open the Configuration Properties -> Linker -> Input tab and add the OgreAL_d.lib (or OgreAL.lib for Release mode) to the Additional Dependencies field.
As before, you need to be sure the program can find the necessary .dll files for it to actually run. The OpenAL .dll file (OpenAL32.dll) is automatically included in the Path variable when you run the OpenAL installer. You must copy the OgreAL_d.dll (or OgreAL.dll for Release mode) and the alut.dll files into the directory containing application’s .exe file—just like the Ogre .dll files. The OgreAL .dll files are in the lib folder within your OgreAL download. The alut.dll file is in the lib folder of your freealut download. With all the .dll files in place you can now run your application.