Print

Image

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(external link) 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):
Image
Alternatively, create this handy batch script:

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:
Image
Tutorial Framework:
Image
Download the Ogre Wiki Tutorial Framework here:
 TutorialFramework.zip

Edit: If you are using Ogre 1.9, download this updated TutorialFramework19.zip
TutorialFramework19.zip

Extract Tutorial Framework:
Image

Add Existing Items to Project:
Image
Select Files:
Image

Project Configuration

Project Properties:
Image


Common Settings

Switching to All Configurations:
Image


General Configuration Properties

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

Image


Debugging Configuration Properties

Command:

$(OGRE_HOME)\Bin\$(Configuration)\$(ProjectName).exe

Working Directory:

$(OGRE_HOME)\Bin\$(Configuration)

 
Image


 

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

 

$(OGRE_HOME)\include
$(OGRE_HOME)\include\OIS
$(OGRE_HOME)\include\OGRE
$(OGRE_HOME)\Samples\Common\include
$(OGRE_HOME)\boost

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

Image


Configuration Properties - Linker - General - Additional Library Directories

$(OGRE_HOME)\lib\$(Configuration)
$(OGRE_HOME)\boost\lib

 
Image


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

 

copy "$(OutDir)\$(TargetFileName)" "$(OGRE_HOME)\Bin\$(Configuration)"

 
Image


Configuration Specific Settings

Switch configuration to "Active(Debug)".
Image


Configuration Properties - Linker - Input - Additional Dependencies - Debug

Add input libraries for debug:

OgreMain_d.lib
OIS_d.lib

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

Image


Configuration Properties - Linker - Input - Additional Dependencies - Release

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

OgreMain.lib
OIS.lib

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

Image


That's it!

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

Edit: 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.

If you are getting errors like: "The program can't start because d3dx9_43.dll is missing from your computer...." try to install the DXSDK_Jun10.exe(external link), 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!)

 
Image
Make sure you optimize your build time with Precompiled headers

ogre.cfg

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.


Contributors to this page: Flateno781 points  , Tytanis118 points  , thebaldwin778 points  , spacegaier5891 points  , piiichan875 points  , Nikitron787 points  , jacmoe171980 points  , harkathmaker245 points  , haltendehand742 points  , Emmentaler2337 points  , binarycrusader173 points  and archeboc427 points  .
Page last modified on Saturday 21 of September, 2013 21:04:58 UTC by Flateno781 points .


The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.