• <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
            數(shù)據(jù)加載中……

            Ogre在游戲開發(fā)中逐幀更新

            最新的Ogre穩(wěn)定版本是1.6.0RC1[shoggoth],在1.6.0版本中OgreFrameListener.h中的類FrameListener多出了一個(gè)叫virtual bool frameRenderingQueued( const FrameEvent& evt ) { return true; }的函數(shù)。這個(gè)函數(shù)和virtual bool frameStarted( const FrameEvent& evt ) { return true; }有明顯的區(qū)別。
            在源代碼中對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.
                    */
            大體翻譯是:
            當(dāng)一幀將要開始渲染的時(shí)候被調(diào)用。
            這個(gè)事件發(fā)生在所有渲染目標(biāo)已經(jīng)開始更新之前。
            而在源代碼中對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.
              */
            翻譯為:
            在所有渲染目標(biāo)已經(jīng)傳出他們的渲染命令之后,并且在渲染窗口被要求去釋放他們的幀之前。
            這個(gè)事件的用途其實(shí)是為了把GPU處理的渲染命令推入隊(duì)列,這些只花費(fèi)一點(diǎn)功夫去完成,
            而就這一段時(shí)間cpu可以被用來處理一些有用的事情。一旦釋放幀這個(gè)時(shí)間發(fā)生,這條線程請求將要被
            堵塞直到GPU準(zhǔn)備好了,這可能浪費(fèi)了cpu的渲染時(shí)間,然而,作為回調(diào)函數(shù)去逐幀處理也是一個(gè)好注意。
            當(dāng)然因?yàn)閹匿秩久钜呀?jīng)被放出,任何你做的改變只對下一幀有效,但是大多數(shù)情況下這不是很明顯的。

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

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


            //類的前向聲明
            class BrilyfApplication;

            class BrilyfListenSystem : public Singleton<BrilyfListenSystem>public FrameListener
            {
                
            bool frameRenderingQueued( const FrameEvent& evt ) 
                
            {
                    
            //一些系統(tǒng)缺省的設(shè)置
                    
                    
            //關(guān)鍵部分
                    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>
            {
                
            //一些對于單件初始化的處理
                
                
                
            //對應(yīng)的事件
                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 閱讀(2202) 評論(2)  編輯 收藏 引用

            評論

            # re: Ogre在游戲開發(fā)中逐幀更新  回復(fù)  更多評論   

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

            # re: Ogre在游戲開發(fā)中逐幀更新  回復(fù)  更多評論   

            呵呵,ogre系統(tǒng)好象是這樣的.
            2008-09-25 10:35 | brilyf

            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久精品视频免费| 久久A级毛片免费观看| 亚洲伊人久久综合影院| 国产精品久久新婚兰兰| 国产成人久久激情91| 伊人久久大香线蕉综合网站 | 99久久免费国产特黄| 国产精品一区二区久久精品无码 | 久久亚洲AV无码西西人体| 伊人久久精品无码av一区 | 亚洲乱码中文字幕久久孕妇黑人| 99久久综合狠狠综合久久止| 欧洲性大片xxxxx久久久| 久久成人精品视频| 亚洲愉拍99热成人精品热久久 | 天天综合久久久网| 亚洲中文字幕无码久久综合网| 91久久精品国产成人久久| 人妻无码久久一区二区三区免费| 久久久精品久久久久特色影视| 精品久久久久香蕉网| 久久久久久精品成人免费图片| 四虎影视久久久免费观看| 久久高清一级毛片| 国产ww久久久久久久久久| 久久被窝电影亚洲爽爽爽| 久久综合给合久久狠狠狠97色| 久久人人爽人人爽人人爽| 久久亚洲精品国产精品婷婷| 亚洲国产成人久久一区WWW| 国产精品99久久久久久猫咪| 99久久免费国产精品| 久久精品国产精品青草| 久久美女人爽女人爽| 狠狠色丁香久久综合五月| 亚洲国产成人久久精品动漫| 精品精品国产自在久久高清| 精品久久久久久中文字幕| 久久精品国产亚洲沈樵| 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲 | 国产精品久久国产精麻豆99网站|