Skip to main content

History: Setting Up An Application - Visual Studio

Preview of version: 137

ee402630.VisualStudio_lg.png
Setting Up An Application With Visual Studio


Introduction

This set of instructions will walk you through setting up a Visual Studio C++ project from scratch. An alternative to this tutorial is to use the Ogre Application Wizard instead. This tutorial is still useful if you wish to understand what the Application Wizard does for you. When you have finished this tutorial you will be able to compile a working Ogre Application and you will be ready to start the Basic Tutorials.

Guide for setting up an Ogre application using Visual Studio 2010 (VC10).

Prerequisites

  • Visual Studio 2010 must be installed. Express and higher.
  • The Ogre SDK version 1.7 or greater must be installed.
    • Installing the Ogre SDK: Installing the Ogre SDK
    • Build Ogre from source with CMake: CMake Quick Start Guide If you are building Ogre from source, you must build the debug and release targets and execute the Install script for both targets as well. This will create a directory structure that is identical to the binary install structure.

Setting Up an Application for Visual Studio 2010

Environment Variables

Run setx OGRE_HOME path_to_ogre_sdk in a command console (cmd.exe):
vc10step0.png
Alternatively, create this handy batch script:

Copy to clipboard
setx OGRE_HOME %CD% pause

Save it as OGRE_HOME.bat and put it in the root directory of the Ogre SDK.
Run it, and the OGRE_HOME environment variable points to that directory.
Handy when you switch between several Ogre SDKs.

New Project

Create a new Win32 project (File -> New -> Project):
vc10step1.png
Make sure that Windows Application is selected and Empty Project is checked:
vc10step2.png
Tutorial Framework:
vc10step3.png
Download the Ogre Wiki Tutorial Framework here:
No such attachment on this page

Edit: If you are using Ogre 1.9, download this updated No such attachment on this page

Extract Tutorial Framework:
vc10step4.png

Add Existing Items to Project:
vc10step5.png
Select Files:
vc10step6.png

Project Configuration

Project Properties:
vc10step7.png


Common Settings

Switching to All Configurations:
vc10step8.png


General Configuration Properties

Set Character Set to Use Multi-Byte Character Set on the General Configuration Properties page:

vc10step9.png


Debugging Configuration Properties

Command:

Copy to clipboard
$(OGRE_HOME)\Bin\$(Configuration)\$(ProjectName).exe

Working Directory:

Copy to clipboard
$(OGRE_HOME)\Bin\$(Configuration)


vc10step10.png


Configuration Properties - C/C++ - General - Additional Include Directories

Copy to clipboard
$(OGRE_HOME)\include $(OGRE_HOME)\include\OIS $(OGRE_HOME)\include\OGRE $(OGRE_HOME)\Samples\Common\include $(OGRE_HOME)\boost

Note: If you are using Ogre >1.9 also add "$(OGRE_HOME)\include\OGRE\Overlay"

vc10step12.png


Configuration Properties - Linker - General - Additional Library Directories

Copy to clipboard
$(OGRE_HOME)\lib\$(Configuration) $(OGRE_HOME)\boost\lib


vc10step13.png


Configuration Properties - Build Events - Post-Build Event - Command Line

Copy to clipboard
copy "$(OutDir)\$(TargetFileName)" "$(OGRE_HOME)\Bin\$(Configuration)"


vc10step14.png


Configuration Specific Settings

Switch configuration to "Active(Debug)".
vc10step15.png


Configuration Properties - Linker - Input - Additional Dependencies - Debug

Add input libraries for debug:

Copy to clipboard
OgreMain_d.lib OIS_d.lib

Note: If you are using Ogre >1.9, also add "OgreOverlay_d.lib".

vc10step16.png


Configuration Properties - Linker - Input - Additional Dependencies - Release

Switch configuration from "Active(Debug)" to "Active(Release)".
Add input libraries for release:

Copy to clipboard
OgreMain.lib OIS.lib

Note: If you are using Ogre >1.9, also add " OgreOverlay.lib".

vc10step17.png


That's it!

You've set up an Ogre project succesfully.
All that remains is to build and run it. 😊

Note: If you are running Ogre 1.9 and are getting a runtime error saying: "Cannot locate resource shadows.glsl in resource group Popular or any...", you have to edit "resources_d.cfg" and "resources.cfg" and add "FileSystem=../../media/materials/programs/GLSL" to the files. See this troubleshooting guide if you can not find the files.

If you are getting errors like: "The program can't start because d3dx9_43.dll (or d3dcompiler_43.dll) is missing from your computer...." try to install the DXSDK_Jun10.exe, if you want to use a DirectX renderer. If you only want to use the OpenGL-renderer, edit the "plugins_d.cfg" and "plugins.cfg" files, and edit out the lines

Plugin=RenderSystem_Direct3D9_d
Plugin=RenderSystem_Direct3D11_d

(Put a # in front of them, or delete them!)


vc10step18.png
Make sure you optimize your build time with Precompiled headers

ogre.cfg

Copy to clipboard
Render System=Direct3D9 Rendering Subsystem [Direct3D9 Rendering Subsystem] Allow NVPerfHUD=No FSAA=0 Floating-point mode=Fastest Full Screen=No Rendering Device=NVIDIA GeForce FX 5200 VSync=No Video Mode=800 x 600 @ 32-bit colour [OpenGL Rendering Subsystem] Colour Depth=32 Display Frequency=60 FSAA=0 Full Screen=Yes RTT Preferred Mode=FBO VSync=No Video Mode=1024 x 768


Note: If you hear your graphics card squealing when showing the Ogre head, turn Vsync to "yes" in ogre.cfg! Your graphics card will squeal when there are too many frames per second being rendered.

-(Visual Studio 2008 - VC9)-

Prerequisites

  • Visual Studio 2008 must be installed. Visual Studio Downloads
  • The Ogre SDK version 1.7 or greater must be installed.
    • Installing the Ogre SDK: Installing the Ogre SDK
    • Build Ogre from source with CMake: CMake Quick Start Guide If you are building Ogre from source, you must build the debug and release targets and execute the Install script for both targets as well. This will create a directory structure that is identical to the binary install structure.

Tutorial

Creating a new project

  • Start Visual Studio 2008
  • Create a new project: File | New | Project
  • Under project types select Visual C++ then under Templates select Win32 Project.
  • Navigate to the location in which your project will be located by clicking the Browse button. It should not be in either the SDK directory or in the source files for Ogre.
    VC2008_Window_NewProject
  • Click the OK button and the Win32 Application Wizard will be displayed.
    VC2008 Win32 AppWizard Page 1.jpg
  • Click the Next Button.
  • Select 'Windows Application' and 'Empty project' when prompted for the type of project to create.
    VC2008 Win32 AppWizard Page 2.jpg
  • Click the Finish button.

Creating the directory structure and adding files

Download and extract the Ogre Wiki Tutorial Framework into your project directory and add them to the project.
VC2008 Solution Explorer Default.jpg

  • If you hover over the second button in the Solution Explorer's toolbar, you will see that it says "Show all files" It should not currently be toggled so you should click on it to toggle it. Now you will see this display of Solution Explorer.
    VC2008 Solution Explorer with Folders.jpg

  • Open each of the folders by clicking on the + signs to the left of each folders name.
    VC2008 Solution Explorer Files Not Added.jpg
  • Right click on the each of the files and select Include In Project.
    VC2008 Solution Explorer Files Added.jpg
  • Select File|Save All from the Visual Studio menu.

Setting up the environment

  • Right click on the project OgreTemplate and select properties. The following screen will be displayed.
    VC2008 Property Pages.jpg

The Properties Pages are arranged in a hierarchy.
By default, Visual Studio creates two configurations. The project is created with two configurations: Debug and Release. You will notice in the upper left corner of the last screen shot that the "Debug" configuration is currently the active configuration. You can change which configuration is being shown by selecting the arrow in that drop-down box. There is an additional value in that drop-down box that indicates that you wish to change a property in all configurations called, surprisingly enough, All Configurations.
This tutorial assumes that the operating system environment variable OGRE_HOME has been set up to point to the SDK directory.

  • Select the All Configurations Configuration by selecting the Configuration drop-down box and selecting "All configurations". Set the variables according to the following chart. You should click Apply after each group of properties.
    Copy to clipboard
    General | Output Directory : bin\$(ConfigurationName) General | Intermediate Directory : obj\$(ConfigurationName) General | Character Set : Use Multi-Byte Character Set Debugging | Command : bin\$(ConfigurationName)\$(ProjectName).exe Debugging | Working Directory : bin\$(ConfigurationName) Debugging | Environment : path=$(OGRE_HOME)\Bin\$(ConfigurationName) C/C++ | General | Additional Include Directories : include;$(OGRE_HOME)\include;$(OGRE_HOME)\include\OIS;$(OGRE_HOME)\include\OGRE;$(OGRE_HOME)\boost Linker | General | Additional Library Directories : $(OGRE_HOME)\lib\$(ConfigurationName);$(OGRE_HOME)\boost\lib
  • Select the Debug Configuration by selecting the Configuration drop-down box and selecting "Debug". Set the properties according to the following chart.
    Copy to clipboard
    Linker | Input | Additional Dependencies : OgreMain_d.lib OIS_d.lib Linker | Debugging | Generate Debug Info : Yes (/DEBUG)
  • Select the Release Configuration by selecting the Configuration drop-down box and selecting "Release". Set the properties according to the following chart.
    Copy to clipboard
    Linker | Input | Additional Dependencies : OgreMain.lib OIS.lib Linker | Debugging | Generate Debug Info : No

Building the project

  • Choose the Debug Solution Configuration.
  • Right click on the project OgreTemplate and select Build Project.

There should be no compile or link errors.

Build Output-Debug.jpg
  • Choose the Release Solution Configuration.
  • Right click on the project OgreTemplate and select Build Project.

There should be no compile or link errors.

Build Output-Release.jpg

Make sure you optimize your build time with Precompiled headers

Copying the config files from OGRE_HOME to the project

As a final step we need to copy some additional files that will be needed to run this project. The build steps just performed created a folder in the project folder called bin and underneath that folder two folders called release and debug. Each of these folders acts as the working directory for their respective configurations when Ogre runs. The Ogre framework will be looking in the working directory for some configuration files and they will be slightly different depending on whether a debug or release version is being run. The configuration files that you will need to run each version are located in $(OGRE_HOME)\bin\debug and $(OGRE_HOME)\bin\release. Copy the *.cfg files from the OGRE_HOME directory to the corresponding project directory.

Running the project

  • Run each version of the Project. If it all works correctly, you will the following screen:
    The rendering engine selection screen.

  • Select a rendering subsystem from the select box in the middle of the window and click 'Ok'. You should see the following:
    The tutorial application rendering an empty scene.
  • If not, go back and verify that you entered all the project properties correctly. You are now ready to move on to the Basic Tutorials.


-(Visual Studio 2005 - VC8)-
TBD
-(Visual Studio 2003 - VC7.1)-
TBD

History

Information Version
Wed 22 of Apr, 2020 09:56 GMT-0000 paroj 141
Mon 24 of Aug, 2015 04:11 GMT-0000 petrocket Fixed link to Ogre app wizard 140
Sun 31 of May, 2015 11:26 GMT-0000 spacegaier 139
Tue 31 of Mar, 2015 06:24 GMT-0000 kabbotta 138
Fri 17 of Oct, 2014 13:29 GMT-0000 spacegaier 137
Fri 19 of Sep, 2014 08:50 GMT-0000 gerymate 136
Fri 19 of Sep, 2014 08:49 GMT-0000 gerymate 135
Sat 21 of Sep, 2013 21:04 GMT-0000 Flateno Page updated for alternative Ogre 1.9 134
Sat 21 of Sep, 2013 20:57 GMT-0000 Flateno 133
Sat 21 of Sep, 2013 20:55 GMT-0000 Flateno 132
Sat 21 of Sep, 2013 20:42 GMT-0000 Flateno Update for Ogre 1.9 131
Sat 21 of Sep, 2013 20:27 GMT-0000 Flateno 130
Sat 21 of Sep, 2013 20:27 GMT-0000 Flateno 129
Sat 21 of Sep, 2013 19:49 GMT-0000 Flateno 128
Sat 21 of Sep, 2013 19:48 GMT-0000 Flateno 127
Sat 21 of Sep, 2013 19:48 GMT-0000 Flateno 126
Sat 21 of Sep, 2013 19:38 GMT-0000 Flateno 125
Sat 21 of Sep, 2013 19:35 GMT-0000 Flateno 124
Sat 21 of Sep, 2013 19:30 GMT-0000 Flateno 123
Fri 08 of Jun, 2012 03:47 GMT-0000 jacmoe 122
Fri 25 of May, 2012 23:55 GMT-0000 jacmoe Boost version is no longer part of directory name 121
Mon 26 of Mar, 2012 07:42 GMT-0000 Nikitron 120
Mon 26 of Mar, 2012 07:41 GMT-0000 Nikitron Fixed links to new version of the Boost from the Ogre. 119
Fri 14 of Oct, 2011 08:25 GMT-0000 Tytanis Added ogre.cfg because I believe it should be here as well! 118
Sun 31 of Jul, 2011 23:41 GMT-0000 jacmoe 117