OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username:
Password:
CapsLock is on.
Remember me (for 1 year)
Log in
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: Building MOGRE with Thread support
View page
Source of version: 2
(current)
{TOC(type="plain")}{TOC} !Introduction Ogre supports threee different thread support options: None, background resource loading and full thread support. The default one is the first option (none). The second one seems to be most interessting one, because async resource loading makes it easy to implement an loading screen. Because of this, this guide will focus on option two: background resource loading. The "thread provider" will be Poco (alternatives are Boost and TPM). I chooosed Poco just because Boost caused some trouble with Mogre, nothing more. It is of course possible to use one of the other providers, only the names will change ;) . !Remarks * This is an __advanced tutorial__, not a really step-by-step bullet proof tutorial * Although I managed to compile (M)Ogre with Poco successfuly and also set up an test project, this guide is some how "theoretical". ## Ogre is not designed to be thread safe, because thread safety does not means "faster" but "more difficult to maintain" (in addistion there is an additional overhead). Thread safety is accomplished by using mutexes. ## Ogre 1.7.* (and higher) have a "bug". There is a __race condition and possible dead lock__ caused by the mutexes in both the resource manager and D3D. As a result, as soon as you start your project, ogre freezes because it locked itself (and not only the background thread): both main thread and background thread are waiting for each other Please keep that in mind. !Steps: # Download poco from [http://pocoproject.org/|here], extract it somewhere (e.g. C:\) and compile it. # We have to compile both mogre and ogre. For that we will use [http://www.ogre3d.org/tikiwiki/MogreBuilder|MogreBuilder]. Compile it, too, and make sure that you can compile mogre without any modifications # Start mogre builder and wait until it compiled the dependencies. Kill it now (completely). # Open cmake-gui and navigate to the ogre source (e.g. C:\...\Main\OgreSrc\ogre\). The build directory will be "C:\...\Main\OgreSrc\build\" (you may need to create the directory). # Press "configure" and fill in the fields for "Poco": POCO_INCLUDE_DIR = (The include dir of poco, e.g. "C:/poco-1.4.4/Foundation/include") and POCO_LIBRARY_DBG = (the PocoFoundationd.lib, e.g. "C:/poco-1.4.4/lib/PocoFoundationd.lib") # Press "Generate" (if there are any erros, double check the paths) # Copy the below patch and apply it. This modified Attributes.xml includes some fixes which include the class "ResourceBackgroundQueue" into the auto wrapper process and "restore" the workqueue id. {CODE(wrap="1", colors="c++")}diff -r c2be4e87dc8b Codegen/AutoWrap/Attributes.xml --- a/Codegen/AutoWrap/Attributes.xml Wed Apr 18 02:28:03 2012 +0200 +++ b/Codegen/AutoWrap/Attributes.xml Tue Sep 11 11:09:44 2012 +0200 @@ -215,7 +215,7 @@ <class name="ControllerFunctionRealPtr" Ignore=""/> <class name="ManualResourceLoader" WrapType="Interface"/> <class name="MaterialSerializer" WrapType="PlainWrapper"/> - <class name="ResourceBackgroundQueue" Ignore=""/> + <!-- <class name="ResourceBackgroundQueue" Ignore=""/> --> <!-- to avoid name clash with System.Exception --> <class name="Exception" WrapType="PlainWrapper" ReadOnly="" Rename="OgreException"> @@ -302,7 +302,15 @@ <class name="Listener" WrapType="NativeDirector"/> </class> <class name="ResourceBackgroundQueue"> - <class name="Listener" WrapType="Interface"/> + <_CustomIncDeclaration> + public: typedef unsigned long BackgroundProcessTicket& + </_CustomIncDeclaration> + <class name="Listener" WrapType="Interface"> + </class> + <function name="canHandleRequest" Ignore=""/> + <function name="handleRequest" Ignore=""/> + <function name="canHandleResponse" Ignore=""/> + <function name="handleResponse" Ignore=""/> </class> <class name="SceneManager"> <class name="SkyBoxGenParameters" WrapType="ReadOnlyStruct"/> @@ -898,8 +906,8 @@ <_CustomIncPreDeclaration> public: typedef Ogre::WorkQueue::RequestID RequestID; </_CustomIncPreDeclaration> - <typedef name="RequestID" Ignore="" /> - <function name="addRequest" Ignore="" /> + <typedef name="RequestID" ReplaceBy="unsigned long" /> + <!-- <function name="addRequest" Ignore="" /> --> <class name="Request" WrapType="PlainWrapper"> <function name="Request" Ignore="" /> </class>{CODE} # Open "C:\...\Main\OgreSrc\ogre\OgreMain\include\OgreConfig.h" and change {CODE(wrap="1", colors="c++")}#define OGRE_THREAD_SUPPORT 0{CODE} to {CODE(wrap="1", colors="c++")}#define OGRE_THREAD_SUPPORT 1{CODE} and {CODE(wrap="1", colors="c++")}#define OGRE_THREAD_PROVIDER 0{CODE} to {CODE(wrap="1", colors="c++")}#define OGRE_THREAD_PROVIDER 2{CODE}Save the file. # Fire up MogreBuilder again and let it finish (if the AutoWrapper step is skipped, do it manually by starting "C:\...\Codegen\AutoWrap\bin\Debug\AutoWrap.exe" and pressing "Produce". And that's it (do not forget to copy "PocoFoundationd.dll" into your app directory). Ogre now supports background resource loading (which is not working properly (:sad:) ).
Search by Tags
Search Wiki by Freetags
Latest Changes
IDE Eclipse
FMOD SoundManager
HDRlib
Building Ogre V2 with CMake
Ogre 2.1 FAQ
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
MogreSocks
...more
Search
Find
Advanced
Search Help
Online Users
99 online users