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

            不斷的學(xué)習(xí),不斷的思考,才能不斷的進(jìn)步.Let's do better together!
            posts - 102, comments - 43, trackbacks - 0, articles - 19

                  本文對(duì)11篇文章進(jìn)行修改,使用顯示列表來(lái)存儲(chǔ)渲染命令。

            顯示列表

            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類中加入一個(gè)變量來(lái)保存顯示列表名稱

                GLuint m_sceneList;

            2,創(chuàng)建顯示列表

            void CCY457OpenGLView::CreateSceneList()
            {
            //創(chuàng)建顯示列表
                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函數(shù)中加入對(duì)上述函數(shù)的調(diào)用:

                //創(chuàng)建顯示列表
                CreateSceneList();

            4,修改RenderScene的繪制代碼

            void CCY457OpenGLView::RenderScene ()
            {
            //繪制函數(shù)
                    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/    

            本文版權(quán)歸作者和博客園共有,歡迎轉(zhuǎn)載,但未經(jīng)作者同意必須保留此段聲明,且在文章頁(yè)面明顯位置給出原文連接,否則保留追究法律責(zé)任的權(quán)利。
            原文鏈接:http://www.cnblogs.com/phinecos/archive/2008/11/06/1328204.html
            久久最新精品国产| 久久99精品国产麻豆| 国产91色综合久久免费| 无码久久精品国产亚洲Av影片| 香港aa三级久久三级老师2021国产三级精品三级在 | 亚洲欧美日韩久久精品第一区| 亚洲国产成人精品无码久久久久久综合 | 精品久久综合1区2区3区激情| 国产精品成人无码久久久久久| 国产精品日韩深夜福利久久| 久久夜色精品国产| 久久人人爽人人爽人人片AV东京热| 欧美日韩精品久久免费| 亚洲国产精品无码久久一线 | 国产欧美久久久精品| 精品熟女少妇aⅴ免费久久| 一本久久免费视频| 999久久久免费精品国产| 久久精品国产精品亜洲毛片| 亚洲精品国产自在久久| 日产精品99久久久久久| 免费观看久久精彩视频| 亚洲伊人久久综合中文成人网| 久久精品日日躁夜夜躁欧美| 99久久精品影院老鸭窝| 亚洲国产香蕉人人爽成AV片久久| 欧洲人妻丰满av无码久久不卡| 亚洲国产精品久久久久| 亚洲精品WWW久久久久久| 国产精品久久久久影院嫩草| 伊人久久大香线蕉成人| 久久久精品免费国产四虎| 久久91精品国产91久| 日韩精品国产自在久久现线拍| 久久久久久久免费视频| 一级做a爱片久久毛片| 中文字幕乱码人妻无码久久| 狠狠精品干练久久久无码中文字幕| 久久成人国产精品免费软件| 久久久这里有精品中文字幕| 青青草国产精品久久|