• <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>

            Shuffy

            不斷的學習,不斷的思考,才能不斷的進步.Let's do better together!
            posts - 102, comments - 43, trackbacks - 0, articles - 19

                  本文對11篇文章進行修改,使用顯示列表來存儲渲染命令。

            顯示列表

            OpenGL provides a facility to create a preprocessed set of OpenGL commands called a display list. Creating a display list is a straight forward process. We just have to delimit the display list code with glNewList and glEndList. The display list is named by an integer and this name is used to call the list to be executed later on. Display lists are very useful for scenes which have lot of geometry that don't change in from frame to frame. If we have to rerender something that doesn't change it is not worth going through all the calculations required once again - it is better to store them somewhere in memory and reuse it. This is exactly what the display list lets us achieve. Thus if we are going to repeatedly execute the same sequence of OpenGL commands we can create and store a display list and then have this cached sequence of calls repeated with minimal overhead, since all the vertices, lighting calculations, textures and matrix operations are calculated only when the list is created and not when it is replayed. Only the results of the calculations end up being stored in display lists. This means we cannot modify the list once we create it.

            1,CY457OpenGLView類中加入一個變量來保存顯示列表名稱

                GLuint m_sceneList;

            2,創建顯示列表

            void CCY457OpenGLView::CreateSceneList()
            {
            //創建顯示列表
                m_sceneList = glGenLists(1);
                glNewList(m_sceneList, GL_COMPILE);
                    SetupLighting();
                    glEnable(GL_TEXTURE_2D);
                    glBindTexture(GL_TEXTURE_2D,m_Texture[
            0]);
                    
            //Front Face
                    glBegin(GL_POLYGON);
                        glTexCoord2f(
            0,0);
                        glVertex3f(
            -1.0f,-1.0f,0.0f);
                        glTexCoord2f(
            1,0);
                        glVertex3f( 
            1.0f,-1.0f,0.0f);
                        glTexCoord2f(
            1,1);
                        glVertex3f( 
            1.0f1.0f,0.0f);
                        glTexCoord2f(
            0,1);
                        glVertex3f(
            -1.0f1.0f,0.0f);
                    glEnd();
                    
            //Back Face
                    glBegin(GL_POLYGON);
                        glTexCoord2f(
            1,0);
                        glVertex3f(
            -1.0f,-1.0f,-1.0f);
                        glTexCoord2f(
            1,1);
                        glVertex3f(
            -1.0f1.0f,-1.0f);
                        glTexCoord2f(
            0,1);
                        glVertex3f( 
            1.0f1.0f,-1.0f);
                        glTexCoord2f(
            0,0);
                        glVertex3f( 
            1.0f,-1.0f,-1.0f);
                    glEnd();
                    glBindTexture(GL_TEXTURE_2D,m_Texture[
            1]);
                    
                    
            //Left Face
                    glBegin(GL_POLYGON);
                        glTexCoord2f(
            1,0);
                        glVertex3f(
            -1.0f,-1.0f0.0f);
                        glTexCoord2f(
            1,1);
                        glVertex3f(
            -1.0f1.0f0.0f);
                        glTexCoord2f(
            0,1);
                        glVertex3f(
            -1.0f1.0f,-1.0f);
                        glTexCoord2f(
            0,0);
                        glVertex3f(
            -1.0f,-1.0f,-1.0f);
                    glEnd();
                    
            //Right Face
                    glBegin(GL_POLYGON);
                        glTexCoord2f(
            0,0);
                        glVertex3f(
            1.0f,-1.0f0.0f);
                        glTexCoord2f(
            1,0);
                        glVertex3f(
            1.0f,-1.0f,-1.0f);
                        glTexCoord2f(
            1,1);
                        glVertex3f(
            1.0f1.0f,-1.0f);
                        glTexCoord2f(
            0,1);
                        glVertex3f(
            1.0f1.0f0.0f);
                    glEnd();
                    glBindTexture(GL_TEXTURE_2D,m_Texture[
            2]);
                    
            //Top Face
                    glBegin(GL_POLYGON);
                        glTexCoord2f(
            0,0);
                        glVertex3f(
            -1.0f1.0f,  0.0f);
                        glTexCoord2f(
            0,1);
                        glVertex3f( 
            1.0f1.0f,  0.0f);
                        glTexCoord2f(
            1,1);
                        glVertex3f( 
            1.0f1.0f-1.0f);
                        glTexCoord2f(
            1,0);
                        glVertex3f(
            -1.0f1.0f-1.0f);
                    glEnd();
                    
            //Botton Face
                    glBegin(GL_POLYGON);
                        glTexCoord2f(
            0,1);
                        glVertex3f(
            -1.0f-1.0f,  0.0f);
                        glTexCoord2f(
            0,0);
                        glVertex3f(
            -1.0f-1.0f-1.0f);
                        glTexCoord2f(
            1,0);
                        glVertex3f( 
            1.0f-1.0f-1.0f);
                        glTexCoord2f(
            1,1);
                        glVertex3f( 
            1.0f-1.0f,  0.0f);
                    glEnd();
                    glDisable(GL_TEXTURE_2D);
                glEndList();
            }

            3,在InitializeOpenGL函數中加入對上述函數的調用:

                //創建顯示列表
                CreateSceneList();

            4,修改RenderScene的繪制代碼

            void CCY457OpenGLView::RenderScene ()
            {
            //繪制函數
                    glTranslatef(0.0f,0.0f,-5.0f);
                    glRotatef(m_xRot,
            1.0f,0.0f,0.0f);
                    glRotatef(m_yRot,
            0.0f,1.0f,0.0f);
                    glCallList(m_sceneList);
            }

             

            作者:洞庭散人

            出處:http://phinecos.cnblogs.com/    

            本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。
            原文鏈接:http://www.cnblogs.com/phinecos/archive/2008/11/06/1328204.html
            午夜天堂av天堂久久久| 亚洲欧美久久久久9999 | 一级做a爰片久久毛片毛片| 一级做a爱片久久毛片| 狠狠色噜噜狠狠狠狠狠色综合久久| av色综合久久天堂av色综合在| 久久强奷乱码老熟女| 国产免费久久久久久无码| 精品久久人人爽天天玩人人妻| 99久久国产免费福利| 伊人久久综合热线大杳蕉下载| 久久国产精品国产自线拍免费| 97久久精品无码一区二区天美| 狠狠色婷婷久久一区二区三区| 国内精品伊人久久久久av一坑| 精品久久久久久久久中文字幕| 99久久国产综合精品麻豆| 欧美亚洲国产精品久久蜜芽| a级毛片无码兔费真人久久| 久久99精品国产99久久6| 亚洲国产成人精品女人久久久 | 91精品国产色综合久久| a高清免费毛片久久| 国内精品久久久久久久亚洲| 国产精品久久久久久久app| 香蕉久久av一区二区三区| 欧美精品一本久久男人的天堂| 久久久久久国产精品美女| 亚洲AV日韩精品久久久久久久| 久久久久久久综合日本亚洲 | 国产偷久久久精品专区| 国内精品伊人久久久久AV影院| 国产99久久久国产精免费| 久久伊人五月丁香狠狠色| 97精品国产91久久久久久| 久久综合日本熟妇| 久久精品国产影库免费看| 久久亚洲AV无码精品色午夜 | 精产国品久久一二三产区区别| 2022年国产精品久久久久| 久久夜色精品国产亚洲|