• <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
            97精品伊人久久久大香线蕉| 亚洲婷婷国产精品电影人久久| 开心久久婷婷综合中文字幕| 亚洲国产成人精品无码久久久久久综合 | 一本久久a久久精品亚洲| 欧美亚洲色综久久精品国产| www久久久天天com| 亚洲精品成人久久久| 99久久综合狠狠综合久久止| 久久国产视屏| 国产精品视频久久| 99精品久久精品一区二区| 曰曰摸天天摸人人看久久久| 亚洲AV无码久久寂寞少妇| 99久久伊人精品综合观看| 77777亚洲午夜久久多人| 久久久久一级精品亚洲国产成人综合AV区 | 一本久久综合亚洲鲁鲁五月天| 精品免费久久久久久久| 亚洲午夜无码久久久久小说| 99久久综合国产精品二区| 国产亚洲精久久久久久无码| 欧美色综合久久久久久| 国产精品欧美亚洲韩国日本久久 | 国内精品久久久久久久97牛牛| 日本精品久久久久久久久免费| 久久美女人爽女人爽| 久久99精品久久久久久hb无码| 久久久久久精品免费看SSS| 久久成人18免费网站| 亚洲精品国产成人99久久| 97久久久精品综合88久久| 久久婷婷五月综合国产尤物app | 亚洲欧美成人综合久久久| 久久午夜夜伦鲁鲁片免费无码影视| 国产精品免费久久| 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 国产69精品久久久久777| 国产精品一久久香蕉国产线看观看 | 久久精品国产一区二区三区| 国产999精品久久久久久|