• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            [原創]Ogre向導教程(1)

            我這個人記性不好,學過的東西老是愛忘,學得越多忘得越快,腦子和我可憐的硬盤一樣容量比較小,所以我發現我不得不把有些東西記錄下來。其實學一樣東西關鍵在于多學多用,有道是書讀百遍其意自現,對于我這種比較笨又沒天賦的人來說可謂金玉良言了。
            以上算前言吧,下邊才是正文。

            Ogre這個引擎的效率不知道實際應用起來如何,但是聽說結構倒是比較好的。選擇它來學習主要是因為它開源,而且是C++和Dx寫的,關鍵還有資料比較多,國內研究的也比較多,也有一些教程,不過Ogre不斷推出新版本,許多教程都有點過期了。要了解最新的使用方法還得看官方的教程。我也是直接看官方的教程,但是英文一般,每次打開大片英文頁面看著的確比較迷糊,所以我打算把里面一些重要的關鍵部分節選出來以備參考,有時候可以快速的重溫,比如這篇要介紹的如何配置Ogre,需要記嗎?程序員記不了那么多啦,用的時候再查。當然Ogre也在持續更新,如果我個人還在持續學習使用Ogre,那么我也會持續更新這些教程的,如果你是Ogre的使用者記得來我的Blog:http://www.shnenglu.com/singohgod 看看吧,希望能對大家有點幫助。

            首先安裝SDK,可以編譯里面帶的示例看看一些效果展示。編譯源碼就得下載源碼吧,記得還要下一個Dependencies,解壓到源碼目錄就可以了,編譯應該能通過的,我這里沒有遇到問題。

            不要被繁多的目錄和文件嚇著了,其實運行Ogre程序只需要下列庫和文件:
            OGRE Libraries & Files

            • OGRE libraries (OgreMain[_d].dll, OgrePlatform[_d].dll or libOgreMain.so, libOgrePlatform.so for linux).
            • plugins.cfg - Text file specifying the rendering libraries available to Ogre (ie DX9, OpenGL).
            • All the plugin libraries listed in plugins.cfg (you can remove items from plugins.cfg if you don't wish to use them).
            • resources.cfg - If using the ExampleApplication, a text file specifing paths to materials, textures, models, etc.
            • OgreCore.zip - Ensure resources.cfg has the proper path to this file if you plan to use the OGRE debug panel or profiler.
            • Other Resources used in your program (*.zip; *.png; *.particle; *.mesh; ...).

            還需要其他的第三方庫:
            These are required:

            • Zlib: zlib1.dll; libz.so (debian: zlib1g, zlib1g-dev)
            • DevIL: devil.dll, ilu.dll, ilut.dll; libIL.so, libILU.so (debian: libdevil1, libdevil-dev)

            These are optional:

            • CEGUI: OgreGUIRenderer[_d].dll, CEGUIBase[_d].dll, CEGUITaharezLook[_d].dll, CEGUIWindowsLook[_d].dll, xerces-c_2_5_0.dll
            • CEGUI: libCEGUIBase.so, libCEGUIOgreRenderer.so, libxerces-c.so (debian: libcegui-mk2-0, libcegui-mk2-dev, libxerces26, libxerces26-dev)
            • Cg: cg.dll; libCg.so (debian: nvidia-cg-toolkit)
            • OpenEXR: openexr.dll??; (debian: libopenexr-dev libopenexr2 )
            • ReferenceApp: ReferenceAppLayer.dll

            不同的編譯器還需要有:
            Extras for Microsoft Visual C++ 6 (SP3+)

            • stlport_vc6[_stldebug]46.dll
            • msvcp60[D].dll
            • msvcrt[D].dll
            Extras for Microsoft Visual C++.Net 2002
            • stlport_vc7[_stldebug]46.dll
            • msvcp70[d].dll
            • msvcr70[d].dll
            Extras for Microsoft Visual C++.Net 2003
            • msvcp71[d].dll
            • msvcr71[d].dll
            Extras for Mingw + STLPort
            • libstlport[stlg].5.0.dll
            • mingwm10.dll


            設置環境變量:
            If you downloaded and installed the precompiled OGRE SDK, you should already have an environment variable called 'OGRE_HOME' registered already, pointing at the folder where you installed. If it isn't there you probably installed under a different user, so define OGRE_HOME manually

          1. If you downloaded the source distribution, you should register a new environment variable OGRE_SRC pointing at the 'ogrenew' folder from the OGRE source

            Ogre源碼項目的目錄結構:
            work_dir
                include
                   *.h
                src
                   *.cpp
                scripts
                   *.vcproj

            新建項目也依據這個結構,你的項目應該有這些文件夾:'bin', 'include', 'media', 'testsolution', 'scripts', and 'src'

            修改新項目的屬性:
            Debugging : Working Directory                       = ..\bin\Debug
            C/C++ : Preprocessor : Preprocessor Definitions += _STLP_DEBUG (only in Debug mode, not needed for .Net 2003 and 2005)
            C/C++ : Code Generation : Use runtime library = Multithreaded Debug DLL (Multithreaded DLL in Release)
            Linker : General : Output File                            = ..\bin\Debug\[appname].exe
            Linker : Input : Additional Dependencies                += OgreMain_d.lib (OgreMain.lib in Release)

            如果你是安裝SDK:

            C/C++ : General : Additional Include Directories 	 = ..\include;$(OGRE_HOME)\include;$(OGRE_HOME)\samples\include
            Linker : General : Additional Library Directories         = $(OGRE_HOME)\lib
            

            如果你是編譯源碼:

            C/C++ : General : Additional Include Directories 	 = ..\include;$(OGRE_SRC)\OgreMain\include;$(OGRE_SRC)\Samples\Common\Include
            Linker : General : Additional Library Directories         = $(OGRE_SRC)\OgreMain\Lib\Debug

            這些設置好以后你就可以新建一個SampleApp.cpp文件,然后拷貝如下代碼:




            #include "ExampleApplication.h"

            // Declare a subclass of the ExampleFrameListener class
            class MyListener : public ExampleFrameListener
            {
            public:
                MyListener(RenderWindow
            * win, Camera* cam) : ExampleFrameListener(win, cam)
                
            {
                }


                
            bool frameStarted(const FrameEvent& evt)
                
            {
                    
            return ExampleFrameListener::frameStarted(evt);        
                }


                
            bool frameEnded(const FrameEvent& evt)
                
            {
                    
            return ExampleFrameListener::frameEnded(evt);        
                }

            }
            ;

            // Declare a subclass of the ExampleApplication class
            class SampleApp : public ExampleApplication 
            {
            public:
               SampleApp() 
               
            {
               }


            protected:
               
            // Define what is in the scene
               void createScene(void)
               
            {
                   
            // put your scene creation in here
               }

              
               
            // Create new frame listener
               void createFrameListener(void)
               
            {
                   mFrameListener 
            = new MyListener(mWindow, mCamera);
                   mRoot
            ->addFrameListener(mFrameListener);
               }

            }
            ;

            #ifdef __cplusplus
            extern "C" {
            #endif

            #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 
            #define WIN32_LEAN_AND_MEAN 
            #include 
            "windows.h" 
            INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT) 
            #else 
            int main(int argc, char **argv) 
            #endif 
            {
                
            // Instantiate our subclass
                SampleApp myApp;

                
            try {
                    
            // ExampleApplication provides a go method, which starts the rendering.
                    myApp.go();
                }

                
            catch (Ogre::Exception& e) {
            #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 
                    MessageBoxA(NULL, e.getFullDescription().c_str(), 
            "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
            #else
                    std::cerr 
            << "Exception:\n";
                    std::cerr 
            << e.getFullDescription().c_str() << "\n";
            #endif
                    
            return 1;
                }


            return 0;
            }


            #ifdef __cplusplus
            }

            #endif

            未完!
          2. posted on 2010-04-21 22:32 avatar 閱讀(332) 評論(0)  編輯 收藏 引用 所屬分類: 游戲開發

            <2010年4月>
            28293031123
            45678910
            11121314151617
            18192021222324
            2526272829301
            2345678

            導航

            統計

            常用鏈接

            留言簿(2)

            隨筆分類

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            精品久久久噜噜噜久久久| 青青草原精品99久久精品66| 久久Av无码精品人妻系列| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 欧美一区二区久久精品| 国产成人精品久久一区二区三区av| 亚洲精品国产字幕久久不卡| 精品国产日韩久久亚洲| 久久99精品久久久久久野外| 久久99国产精品一区二区| 久久精品18| 999久久久国产精品| 亚洲国产精品久久久久久| 久久久久综合网久久| 91精品国产高清久久久久久io| 熟妇人妻久久中文字幕| 无遮挡粉嫩小泬久久久久久久| 国产69精品久久久久9999APGF| 久久久久久伊人高潮影院| 精品久久久无码21p发布| 久久香综合精品久久伊人| 久久人人爽人人人人片av| 亚洲AV乱码久久精品蜜桃| 亚洲国产另类久久久精品小说 | 亚洲va国产va天堂va久久| 欧美va久久久噜噜噜久久| 久久久精品国产sm调教网站 | 久久综合综合久久97色| 国产2021久久精品| 欧美精品丝袜久久久中文字幕 | 99久久这里只有精品| 伊人久久综在合线亚洲2019| 久久伊人色| 亚洲乱码中文字幕久久孕妇黑人 | 免费精品99久久国产综合精品| 国产精品九九久久免费视频 | 77777亚洲午夜久久多喷| 国产精品美女久久久m| 精品人妻伦一二三区久久| 日韩欧美亚洲综合久久| 国产精品一区二区久久国产|