Ogre 3D. A series of training articles. Issue 1

    In the topic, a request was made 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 new goodies are only in trunk.
    I will briefly describe the assembly and installation from the source.
    You will need:
    Sources of ogre svn.ogre3d.org/svnroot/ogre/trunk
    Dependencies: swing away Microsoft Visual C ++ Dependencies Package (as you have understood, I will describe the work under ++ the VC)
    Cmake (perhaps you've used for other projects): http: / /cmake.org/
    DirectX SDK (if you want to use DirectX 3D as a render, OpenGL is not required): http://msdn.microsoft.com/directx
    Unpack the dependency archive into the folder where the source checkout was done (in my case D: / TestGameEngine / ogre_trunk /) and collect the dependencies (the project for the studio is in \ ogre_trunk \ Dependencies \ src \ select the project for your version of the studio)

    Now we can start assembly of the ogre itself.
    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 collect.
    Perhaps the log will be full of errors about dependencies not found, then in the Ogre → OGRE_DEPENDENCIES_DIR parameter we will specify the / ogre_trunk / Dependencies folder, after which Cmake will write the paths to lib and include files of different libraries. As you can see, there are some dependencies that are not required, but are needed for some feature in the engine. For example, you can specify the path to doxygen to generate documentation, although it can be viewed here.

    I changed the build options a bit (for example, I don’t need OpenGL render and projects for building examples).
    If you changed the options, click Configure, and if there are no errors, click Generate.

    Now we open the generated project in the studio, I have it \ ogre_build \ OGRE.sln
    You can build any single component or immediately build ALL_BUILD. The Package project does not need to be assembled, it is an installer assembly.

    When we install the SDKs, the paths of the inclusions and lib files are registered in the studio automatically, when assembling from source, this must be done by hand.
    We write the paths of inclusions in the studio settings: Library files: Also, later we will not forget to specify OgreMain.lib in the linker options of the project. On this assembly of the ogre can be considered complete.
    \ogre_trunk\OgreMain\include
    \ogre_build\include
    \ogre_trunk\Dependencies\include


    \ogre_build\lib\[Release|Debug](надо указать оба путя, но я использую только Release версию, поэтому указал только ее)





    Creating a simple application


    Now create a simple project on Ogre.
    Create a Win32 Console Application.
    Add “Ogre.h” to the #include code
    and add the main function code
    1. Ogre::Root* mRoot = new Ogre::Root(); //создаем главный объект огра
    2. mRoot->showConfigDialog(); //Показываем диалог конфигурации огра, выбор настроек.
    3. Ogre::RenderWindow* mWindow = mRoot->initialise(true); //создаем окно рендеринга, параметр true говорит, о том, что нужно создать это окно, иначе его нужно создать вручную
    4. Ogre::SceneManager* mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC); //создаем сцену со стандартным менеджером сцены.
    5. while (1)
    6. {
    7.   MSG msg;
    8.   while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
    9.   {
    10.     TranslateMessage(&msg);
    11.     DispatchMessage(&msg);
    12.   }
    13.   if (!mRoot->_fireFrameStarted())
    14.     break;
    15.   mRoot->_updateAllRenderTargets();
    16.   if (!mRoot->_fireFrameEnded())
    17.     break;
    18.   if (mWindow->isClosed())
    19.     break;
    20. }
    21.   window->destroy();
    22.   root->shutdown();

    We copy the OgreMain.dll files into the folder with the exe file, and the system render file, for example RenderSystem_Direct3D9.dll
    , we also create plugins.cfg, in which we indicate this, 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 sources and a compiled example: Source Compiled binaries (the program itself + OgreMain.dll + RenderSystem_Direct3D9.dll) In the next article I will talk about creating the simplest scene in ogre.
    PluginFolder=.
    Plugin=RenderSystem_Direct3D9









    Also popular now: