<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <style type="text/css"> <!-- .MainHeader { font-weight: bold; color: #FFFFFF; background-color: #003300; font-size: 10pt} body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; color: #003300; background-color: #FFFFFF} .BorderHeader { background-color: #999900; font-size: 8pt; font-weight: bold; color: #333300; text-align: center} .MainContent { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; color: #003300} .BorderContent { font-size: 8pt; color: #000000; border-color: black #666600 #666600; padding-top: 2px; padding-right: 2px; padding-bottom: 10px; padding-left: 2px; margin-bottom: 2px; border-style: solid; border-top-width: 0px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px} a:link { color: #000066; text-decoration: underline} a:hover { color: #0000FF; text-decoration: underline} a:visited { color: #660066; text-decoration: underline} li { color: #000000; list-style-type: circle; position: relative; left: -15px; clip: rect( )} .NewsDate { color: #000000; font-weight: bold} td { font-size: 10pt} th { font-size: 10pt} .Annotation { font-size: 10px} .header { font-size: 16pt; color: #000000} .SectionHeader { font-size: 14px; color: #000000; font-weight: bold} pre { color: #000066; font-size: 12px} --> </style> <title>Creating OGRE Project Files</title> <meta name="generator" content="Deppo's HTML Editor v2.1 BETA 2"> <meta name="keywords" content=""> <meta name="description" content=""> <meta name="author" content="Nicholas"> <meta http-equiv="reply-to" content="vastrim@hotmail.com"> <meta name="creation_date" content="Sat, 13 Jul, 2002 12:32:59 p GMT"> </head> <body bgcolor="#ffffff" text="#000000"> <p align="center" class="header">OGRE (Object-Oriented Graphics Rendering Engine)</p> <p align="center" class="header"> Creating project files for OGRE </p> <p align="left" class="MainHeader"> </p> <p align="left" class="SectionHeader"> Files</p> <p align="left"> In these tutorials I will assume that the projects being created are located in their own folder in OgreNew\Samples. I will use APPNAME as a place holder for where you type in the name of the application. So in the example of where the project files should be stored it would be OgreNew\Samples\APPNAME. </p> <p align="left"> NB: In a moments time we will embark on creating a small application called "Space", based on some of the examples supplied with Ogre. I suggest that if you plan on doing that tutorial that you use Space as the APPNAME. </p> <p align="left" class="SectionHeader"> Visual C++ 7</p> <p align="left"> The first thing you need to do is create a blank Win32 Project. Make sure that you create a C++ project and that you have ticked the "Empty Project" tick box.<br> Now right click on the project in the solution explorer and change the following properties:<br> </p> <pre><table border="0" cellspacing="2" cellpadding="1"> <tbody><tr> <td>Debug - Working Directory</td> <td>=</td> <td>..\Common\Bin\Debug</td> </tr> <tr> <td>C/C++ - Preprocessor Defines</td> <td>=</td> <td>_WINDOWS,_STLP_USE_DYNAMIC_LIB,OGRE_LIBRARY_IMPORTS,_DEBUG,WIN32</td> </tr> <tr> <td>C/C++ - Additional Include Directories</td> <td>=</td> <td>..\Common\Include ..\..\OgreMain\include<br></td> </tr> <tr> <td>Linker - Output File</td> <td>=</td> <td>..\Common\Bin\Debug\APPNAME.EXE</td> </tr> <tr> <td>Linker - Additional Library Directories</td> <td>=</td> <td>..\..\OgreMain\Lib\Debug</td> </tr> <tr> <td>Linker - Additional Dependencies</td> <td>=</td> <td>OGREMain.LIB</td> </tr> </tbody></table> </pre> <p align="left"> Copy Samples\Skyplane\Src\SkyPlane.CPP and Samples\Skyplane\Include\SkyPlane.H into the directory with your project. Right click on the project in the solution explorer and select "Add Existing Item". Highlight the two files you just copied and then rebuild your solution. Now run it in debug mode. Everything should work. </p> <p align="left"> Now remove those two files from your project and delete them from your projects directory. </p> <p align="left"> The last step that we need to take in setting up the project is to create the main program loop. This is simpler than it sounds because if we are following the Ogre Example Framework then all it means we do is create an instance of our Application object and call it's go() method. In Visual C++ it will look like this: </p> <pre>/* APPNAME.CPP */<br><br>#include "Ogre.h"<br>#include "APPNAMEApplication.h"<br><br>#define WIN32_LEAN_AND_MEAN<br>#include "windows.h"<br><br>INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )<br>{<br> // Create application object<br> APPNAMEApplication app;<br><br> try {<br> app.go();<br> } catch( Ogre::Exception& e ) {<br> MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL );<br> }<br><br> return 0;<br>}<br><br></pre> <p align="left"> This doesn't compile does it? No, because we have not written APPNAMEApplication.h yet. That will be discussed in the next section. </p> <p align="left" class="SectionHeader"> Visual C++ 6</p> <p align="left"> Under construction. </p> <p align="left" class="SectionHeader"> Linux</p> <p align="left"> Under construction. </p> <p align="left" class="SectionHeader"> Borland</p> <p align="left"> Under construction. </p> <p align="left" class="SectionHeader">Mac OSX</p> <p align="left">The first thing you need to do is to download a sample <a href="MacOSX/Makefile">Makefile</a> to build your app. Put this in the Ogrenew/Samples/Space directory. Copy Samples/Skyplane/Src/SkyPlane.CPP and Samples/Skyplane/Include/SkyPlane.H into this same directory (ie. there should now be 3 files in this directory). </p> <p align="left"> Let's take a look at portions of the Makefile that you would need to amend:</p> <pre align="left"># TOPDIR points to the main directory where you installed Ogre <br> TOPDIR = /source/ogrenew</pre> <p align="left">Amend this path to reflect the path of your Ogre installation</p> <p></p> <pre align="left"># DEVIL_LIBS points to src path for DevIL <br> DEVIL_LIBS = -L/source/DevIL/src-Il/src</pre> <p align="left">Amend this path to reflect the path to the DevIL 'src' directory.</p> <p align="left"> </p> <p align="left">In the Terminal, 'cd' into Ogrenew/Samples/Space and do a 'make'. To run this built application, 'cd' into Ogrenew/Samples/Common/bin and do a './mySkyPlane'. Everything should work.</p> <p align="left"> Now remove those two files (.cpp & .h) from your directory.</p> <p align="left">You will now need to edit the Makefile to reflect your new source files as follows</p> <pre align="left"># SRCFILES points to all files to be compiled<br> SRCFILES = APPNAMEApplication.cpp<br></pre> <p align="left">Amend the source file name to the name of your new .cpp file</p> <pre align="left"># APPNAME is the filename of the generated executable <br> APPNAME = $(TOPDIR)/Samples/Common/bin/APPNAMEApplication</pre> <p align="left">Edit this to reflect the location and name of your executable. For this project, place it in the Ogrenew/Samples/Common/bin directory for simipliity.</p> <pre align="left"># INCLUDES points to additional include directories <br> INCLUDES = -I. -I$(TOPDIR)/Samples/APPNAME/include ...</pre> <p align="left">If you are storing you .h file in a 'include' subdirectory, add its path here so that it could be located</p> <p align="left"> The last step that we need to take in setting up the project is to create the main program loop. This is simpler than it sounds because if we are following the Ogre Example Framework then all it means we do is create an instance of our Application object and call it's go() method. In Visual C++ it will look like this: </p> <pre align="left">/* APPNAME.CPP */<br>#include "Ogre.h" #include "APPNAMEApplication.h"<br><br>#if OGRE_PLATFORM == PLATFORM_WIN32<br>#define WIN32_LEAN_AND_MEAN<br>#include "windows.h"<br>INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )<br>#else<br>int main(int argc, char *argv[])<br>#endif<br>{<br> // Create application object<br> APPNAMEApplication app;<br> try {<br> app.go();<br> } catch( Ogre::Exception& e ) {<br><br>#if OGRE_PLATFORM == PLATFORM_WIN32<br> MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL );<br>#else<br> std::cerr << "An exception has occured: " <<<br> e.getFullDescription().c_str() << std::endl;<br>#endif<br> }<br><br> return 0;<br>}</pre> <p>Note that this source differs from the one provided. It includes codes for platforms other than Windows. The source for the .cpp file remains unchanged. Now run 'make' agin in the Terminal. This doesn't compile does it? No, because we have not written APPNAMEApplication.h yet. That will be discussed in the next section.</p> <table width="100%" border="0" cellspacing="2" cellpadding="0"> <tbody> <tr> <td width="14%"><a href="Index.html">Back to Index</a></td> <td width="39%"> </td> <td width="22%"><< Previous section</td> <td width="25%"><a href="SettingUpTheScene.html">Next section >></a></td> </tr> </tbody> </table> <p> </p> <p> </p> <p> </p> <p class="SectionHeader"> </p> </body> </html>