In the
topic there was a request to write some articles about Ogre 3D.
In the first article I will talk about installing Ogre and creating a simple application using Ogre.
Installation
The easiest option is to download sdk from
ogre3d.org , but sdk is only the latest stable version, and all the new goodies are only in the trunk.
I will describe in brief the assembly and installation from source.
It will take:
Ogre sources from
svn.ogre3d.org/svnroot/ogre/trunkDependencies: download the Microsoft Visual C ++ Dependencies Package from here (as you understand, I will describe the work under VC ++)
Cmake (maybe you used for other projects):
http://cmake.org/DirectX SDK (if you want to use DirectX 3D as a render, it is not required for OpenGL):
http://msdn.microsoft.com/directxUnpack the archive with dependencies in the folder where you made the checkout source (in my case D: / TestGameEngine / ogre_trunk /) and collect the dependencies (the project for the studio is in \ ogre_trunk \ Dependencies \ src \ choose the project for your version of the studio)
Now you can begin to build the ogre.
Run Cmake, in the upper field, specify the source folder, and in the lower field, where to put the project files and configuration results, then click configure and specify the compiler to build.
Perhaps the log will be full of errors about not found dependencies, then we specify the folder / ogre_trunk / Dependencies in the Ogre → OGRE_DEPENDENCIES_DIR parameter, after which Cmake will register the paths to the lib and include files of different libraries. As you can see, there are some dependencies that are not required, but are needed for any feature in the engine. For example, you can specify the path to doxygen to generate documentation, although you can see it
here.I changed the build options a bit (for example, I don't need the OpenGL render and projects to build examples)
If you changed the options, then click Configure, and if there were no errors, then click Generate.
')
Now open the generated project in the studio, I have this \ ogre_build \ OGRE.sln
You can build any individual component or build ALL_BUILD right away. You don't need to build the Package project, this is an installer assembly.
When installing the SDK, the paths of the inclodes and the lib files are automatically registered in the studio, when building from source, this should be done with your hands.
Register in the settings of the path of the Includ:
\ogre_trunk\OgreMain\include
\ogre_build\include
\ogre_trunk\Dependencies\include
Library files:
\ogre_build\lib\[Release|Debug]( , Release , )
Also, later we will not forget to specify OgreMain.lib in the linker options of the project.
At this assembly assembly can be considered complete.
Creating a simple application
Now create a simple project on Ogre.
Create a Win32 Console Application.
Add to the #include code “Ogre.h”
and add the main function code
- Ogre :: Root * mRoot = new Ogre :: Root (); // create the main object
- mRoot-> showConfigDialog (); // Show the Ogre configuration dialog, select settings.
- Ogre :: RenderWindow * mWindow = mRoot-> initialise ( true ); // create a rendering window, the true parameter says that you need to create this window, otherwise you need to create it manually
- Ogre :: SceneManager * mSceneMgr = mRoot-> createSceneManager (Ogre :: ST_GENERIC); // create a scene with a standard scene manager.
- while (1)
- {
- Msg msg;
- while (PeekMessage (& msg, NULL, 0U, 0U, PM_REMOVE))
- {
- TranslateMessage (& msg);
- DispatchMessage (& msg);
- }
- if (! mRoot -> _ fireFrameStarted ())
- break ;
- mRoot -> _ updateAllRenderTargets ();
- if (! mRoot -> _ fireFrameEnded ())
- break ;
- if (mWindow-> isClosed ())
- break ;
- }
- window-> destroy ();
- root-> shutdown ();
Copy the OgreMain.dll files and the system render file, for example RenderSystem_Direct3D9.dll, into the folder with the exe file
also create a plugins.cfg in which we specify
PluginFolder=.
Plugin=RenderSystem_Direct3D9
this will tell the ogre which additional plugins to load during initialization
After starting, we see the simplest application on the ogre, which shows an empty window.
Just in case, I will lay out the source code and the compiled example:
Source codeCompiled binaries (programs + OgreMain.dll + RenderSystem_Direct3D9.dll)
In the next article I will talk about creating the simplest scene in the ogre.