• <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>
            隨筆 - 5, 文章 - 0, 評論 - 24, 引用 - 0
            數據加載中……

            Ogre在游戲開發中逐幀更新

            最新的Ogre穩定版本是1.6.0RC1[shoggoth],在1.6.0版本中OgreFrameListener.h中的類FrameListener多出了一個叫virtual bool frameRenderingQueued( const FrameEvent& evt ) { return true; }的函數。這個函數和virtual bool frameStarted( const FrameEvent& evt ) { return true; }有明顯的區別。
            在源代碼中對frameStarted的注釋是:
                    /** Called when a frame is about to begin rendering.
              @remarks
               This event happens before any render targets have begun updating.
                        @return
                            True to go ahead, false to abort rendering and drop
                            out of the rendering loop.
                    */
            大體翻譯是:
            當一幀將要開始渲染的時候被調用。
            這個事件發生在所有渲染目標已經開始更新之前。
            而在源代碼中對frameRenderingQueued的注釋是:
              /** Called after all render targets have had their rendering commands
               issued, but before render windows have been asked to flip their
               buffers over.
              @remarks
               The usefulness of this event comes from the fact that rendering
               commands are queued for the GPU to process. These can take a little
               while to finish, and so while that is happening the CPU can be doing
               useful things. Once the request to 'flip buffers' happens, the thread
               requesting it will block until the GPU is ready, which can waste CPU
               cycles. Therefore, it is often a good idea to use this callback to
               perform per-frame processing. Of course because the frame's rendering
               commands have already been issued, any changes you make will only
               take effect from the next frame, but in most cases that's not noticeable.
              @return
               True to continue rendering, false to drop out of the rendering loop.
              */
            翻譯為:
            在所有渲染目標已經傳出他們的渲染命令之后,并且在渲染窗口被要求去釋放他們的幀之前。
            這個事件的用途其實是為了把GPU處理的渲染命令推入隊列,這些只花費一點功夫去完成,
            而就這一段時間cpu可以被用來處理一些有用的事情。一旦釋放幀這個時間發生,這條線程請求將要被
            堵塞直到GPU準備好了,這可能浪費了cpu的渲染時間,然而,作為回調函數去逐幀處理也是一個好注意。
            當然因為幀的渲染命令已經被放出,任何你做的改變只對下一幀有效,但是大多數情況下這不是很明顯的。

            加入了這個函數也說明了Ogre1.6.0對gpu重視了。
            在ogre自帶的例子中,幾乎都是用examplelistener來處理游戲循環。這明顯不符合比較大點的游戲開發。而如果
            你想要在大型游戲中應用這個游戲循環。我感覺首先應該有一個單件的幀監聽系統通過游戲主應用程序來初始化。然后就是用設計模式中的Bridge的將聲明和執行分開的功能來處理這個方法。
            偽代碼:

            //一個部件的類
            class BrilyfWidgets
            {
                
            bool frameRenderingQueued( const FrameEvent& evt ); 
                
            }
            ;


            //類的前向聲明
            class BrilyfApplication;

            class BrilyfListenSystem : public Singleton<BrilyfListenSystem>public FrameListener
            {
                
            bool frameRenderingQueued( const FrameEvent& evt ) 
                
            {
                    
            //一些系統缺省的設置
                    
                    
            //關鍵部分
                    BrilyfApplication::getSingletonPtr()->frameRenderQueued( const FrameEvent& evt );
                    BrilyfApplication::getSingletonPtr()
            ->frameEnded( const FrameEvent& evt );
                }

                
            bool frameEnded( const FrameEvent& evt );    
            }
            ;

            //所有的其他一些部件的初始化都要通過BrilyfApplication,它就是游戲的主管道,控制著所有部件的生命周期,提供了
            //frameRenderingQueued和frameEnded的接口供其他的部件來填充。
            class BrilyfApplication : public Singleton<BrilyfApplication>
            {
                
            //一些對于單件初始化的處理
                
                
                
            //對應的事件
                bool frameRenderingQueued( const FrameEvent& evt ) 
                

                    
            for ( int i = 0; i < 16; i++ )
                        BrilyfWidgets.frameRenderingQueued(  );
                }

                
            bool frameEnded( const FrameEvent& evt );

                BrilyfWidgets mWidgets[
            16];
            }
            ;

            posted on 2008-09-24 22:11 brilyf 閱讀(2219) 評論(2)  編輯 收藏 引用

            評論

            # re: Ogre在游戲開發中逐幀更新  回復  更多評論   

            這是開了兩個線程嗎?
            一個做DP和flip
            另一個回調frameRenderingQueued
            2008-09-25 08:49 | LOGOS

            # re: Ogre在游戲開發中逐幀更新  回復  更多評論   

            呵呵,ogre系統好象是這樣的.
            2008-09-25 10:35 | brilyf
            久久久久av无码免费网| 久久久无码人妻精品无码| 久久99精品综合国产首页| 久久噜噜电影你懂的| 久久激情五月丁香伊人| 伊人久久大香线蕉av不变影院| av无码久久久久不卡免费网站| 国产精品久久久天天影视香蕉 | 亚洲午夜久久久| 国产成年无码久久久久毛片| 亚洲午夜无码AV毛片久久| 久久精品草草草| 久久久久久久精品妇女99| 日本久久久精品中文字幕| 伊人久久大香线蕉综合Av| 久久性生大片免费观看性| 久久噜噜电影你懂的| 久久精品人人做人人爽电影蜜月| 久久天天躁狠狠躁夜夜不卡| 99久久精品国产麻豆| 7777久久久国产精品消防器材| 91麻豆精品国产91久久久久久| 精品久久久久久99人妻| 国产精品久久久久影院色| 婷婷久久综合九色综合绿巨人| 久久91亚洲人成电影网站| 2021久久精品免费观看| 精品免费tv久久久久久久| 三级三级久久三级久久| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 久久黄视频| 久久亚洲国产最新网站| 亚洲国产精品无码成人片久久| 国内精品九九久久久精品| 亚洲国产精品无码久久一线 | 精品久久久久久无码专区| 精品久久久久久中文字幕| 色综合久久88色综合天天 | 久久久免费精品re6| 国产精品美女久久福利网站| 91秦先生久久久久久久|