• <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
            久久只有这里有精品4| 欧美久久精品一级c片片| 伊人久久大香线蕉综合5g| 亚洲精品国产自在久久| 狠狠综合久久综合88亚洲| 久久亚洲精品中文字幕| 久久综合久久综合九色| 人妻无码精品久久亚瑟影视 | 欧美久久一区二区三区| 久久强奷乱码老熟女网站| 青青草国产精品久久| 热99RE久久精品这里都是精品免费| 久久久久亚洲av无码专区| 亚洲国产成人久久笫一页| 久久97精品久久久久久久不卡| 久久久久久久波多野结衣高潮 | 一级a性色生活片久久无少妇一级婬片免费放 | 精品久久久久一区二区三区| 久久精品无码一区二区WWW| 国产99久久久久久免费看| 久久天天躁狠狠躁夜夜网站| 女人高潮久久久叫人喷水| segui久久国产精品| 国产一区二区精品久久| 久久婷婷五月综合97色| 亚洲中文字幕无码久久综合网 | 99久久香蕉国产线看观香| 久久久无码精品亚洲日韩软件| 久久香蕉国产线看观看99| 日韩精品无码久久久久久| 久久久久久精品免费看SSS| 国产精品久久新婚兰兰| 性欧美大战久久久久久久| 性做久久久久久久久老女人| 午夜精品久久久久9999高清| 午夜视频久久久久一区| 久久久久久亚洲精品无码| 精品水蜜桃久久久久久久| 久久久久久极精品久久久 | 国产精品久久久久乳精品爆 | 久久这里只精品国产99热|