Building MOGRE from source

From Ogre Wiki

Jump to: navigation, search

Author: Marioko

English version: DodongoXP

Revision 2

Latest Revision Date : May 20th 2008


Please follow these steps in the order shown below.

Contents

Before we begin

Before we start with the building process, we need to make sure we have met all the requirements:

  • DirectX 9.0c SDK Make sure that DX_DIR envirotment var is set before install DirectSDK.
  • At least 6 gigabytes of hard disk space for the building process


To build the redistributable SDK it is necessary to have installed:

  • HM NSIS Edit (optional)

The Steps

Getting the sources

In this step we need to get a copy of the MOGRE source from MOGRE's project SVN repository. We need to use TortoiseSVN this way:

A) First we create an empty folder somewhere on our hard drive and call it Mogre.

B) Inside that folder right click on blank space, click on SVN Checkout in the context menu and the following window should appear

C) In the field "URL of Repository" write https://mogre.svn.sourceforge.net/svnroot/mogre/trunk/Mogre

(Note: if you are trying to build 1.4, use https://mogre.svn.sourceforge.net/svnroot/mogre/branches/1.4.)

D) Finally click OK and TortoiseSVN will begin downloading the Mogre source code. Wait until the download is complete.

E) When the download has finished you should have a directory called Mogre with all the files inside looking like this:

Image:BuildingMogreNew3.gif

(Note: 'ogrenew' is only there if you got the 1.4 branch. If you download from the trunk, ogrenew will not be there, and (?) you should get a snapshot or checkout from Ogre.)

Compiling OGRE and MOGRE

This is the most important paft of the process of building MOGRE from source. Make sure you did all the required steps as listed before.

Before we begin you need to unzip the OGRE dependencies in the ogrenew folder but DONT OVERWRITE OIS.lib, OIS_d.lib or any other .dll related to OIS. The reason is that MOGRE uses a modified version of OIS and overwriting it with the one in the dependencies would cause severe problems during this process!

A) Open the Mogre_VC9.sln solution which is located in the main folder. This solution include the core of Mogre and related rendering subsystems and Plugins only.

B) Before anything else open the file CLRConfig.h which is inside the OgreMain project and make sure that LINK_TO_MOGRE is set to 0 (zero).

This is necessary because the Mogre.dll file doesn't exist yet.

#define LINK_TO_MOGRE 0

C) Now just build the solution

D) After a successful build, modify the file CLRConfig.h once again and set LINK_TO_MOGRE to 1

#define LINK_TO_MOGRE 1

This time it's only necessary to build (not rebuild, just build it) the OgreMain project. It will relink a couple of libs with MOGRE and it won't take too much to complete.

E) Thats it!! We are done with the process of building MOGRE from source. You will found all generated dll files in MOGRE\bin\ folder

Building the Redistributable SDK

This is the easiest part of the whole process. First make sure you have installed NSIS.

In the folder MOGRE\SDK\ we can find the file buildMogreSDK.bat. Execute it and after a few minutes there should be the installer in the same folder.

If you want, you can modify any of the installer information by editing the file MogreSDK.nsi in any text editor.



Addiontal Info

If someday you ask yourself how is OGRE wrapped then you need read this addional info. Mogre is created using an autowrapper tool that can convert all Ogre native headers code to C++/CLI managed code, all generated source files are in MOGRE\Mogre\include\auto and MOGRE\Mogre\src\auto folders. You can use this autowrapper following the next steps.

Wrapping OGRE

To wrap OGRE you need the following tools: cpp2java created by the programmers of Ogre4j and AutoWrap created by Argiris Kirtzidis alias Bekas to create MOGRE.

A brief introduction to these tools:

cpp2java: this is an excellent XSL stylesheet invoked by an ant script which uses doxygen to create an xml file with all the structure of the ogre headers or any other c++ project, the resulting meta.xml file can be used to easily create wrappers to other languages like ogre4j and mogre, as cpp2java uses java applications (ant and saxon as XSLT processor) you need to have the JRE (Java Runtime) installed on your pc to run it.

AutoWrap. created by our friend bekas it's an amazing tool which uses the meta.xml generated by cpp2java to automatically create all the required .h and .cpp files which encapsulate OGRE.

With the appropriate modifications made, this tool can be used to create wrappers for other projects besides OGRE or even to make wrappers for the OGRE addons (nxogre, plsm, paged geometry and so on).

All right, let's start:

A) In the directory cpp2java should be a file called build.bat. If you have the JRE succesfully installed we will only need to execute this file.

B) At the cpp2java folder we will find a directory called "build" which has the following files inside:

Image:BuildingMogre7.gif

C) Now we need to compile AutoWrap, which is in the autowrapp directory inside the Mogre directory. Open the VC# solution called autowrap.sln and build it, then run it and you should see this window:

Image:BuildingMogre8.gif

D) This is an application with a very simple interface but very powerful. Here we only need to click on the "Produce" button. If you want to see the code that will be generated you can click on a file on the list.

Image:BuildingMogre9.gif

E) If this message appears everything went ok. You can check by looking at the folders Mogre/Mogre/include/auto/ and Mogre/Mogre/src/auto/

Adding Unicode Support

The current version of AutoWrap will not automatically generate support for unicode text in the overlays, therefore it is necessary to do it manually.

The procedure is very simple:

A) In the MogreOverlayElement.cpp file that generates AutoWrap which should be in the folder src\auto of MOGRE it is needed that the Caption property is modified like this :

//Public Declarations
String^ OverlayElement::Caption::get()
{
  #ifdef OGRE_UNICODE_SUPPORT
        return UTF_TO_CLR_STRING( static_cast<const Ogre::OverlayElement*>(_native)->getCaption( ) );
  #else
        return TO_CLR_STRING( static_cast<const Ogre::OverlayElement*>(_native)->getCaption( ) );	
  #endif
}

void OverlayElement::Caption::set( String^ text )
{	
  #ifdef OGRE_UNICODE_SUPPORT
        DECLARE_NATIVE_UTFSTRING( o_text, text )
  #else
        DECLARE_NATIVE_STRING( o_text, text )
  #endif		
        static_cast<Ogre::OverlayElement*>(_native)->setCaption( o_text );
}


B) We do the same thing with the file MogreTextAreaOverlayElement.cpp which should be in the same folder as the previous file.

String^ TextAreaOverlayElement::Caption::get()
{
 #ifdef OGRE_UNICODE_SUPPORT
       return UTF_TO_CLR_STRING( static_cast<const Ogre::TextAreaOverlayElement*>(_native)->getCaption() );
 #else
       return TO_CLR_STRING( static_cast<const Ogre::TextAreaOverlayElement*>(_native)->getCaption( ) );
 #endif
} 

void TextAreaOverlayElement::Caption::set( String^ text )
{
  #ifdef OGRE_UNICODE_SUPPORT
        DECLARE_NATIVE_UTFSTRING( o_text, text )
  #else
        DECLARE_NATIVE_STRING( o_text, text )
  #endif
  static_cast<Ogre::TextAreaOverlayElement*>(_native)->setCaption( o_text);	
}


C) Thats it! Now you know how Mogre is created.

Personal tools
administration