• <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>
            隨筆-38  評(píng)論-23  文章-0  trackbacks-0

            glut是opengl輔助庫.

            現(xiàn)通過它實(shí)現(xiàn)一個(gè)位于z=0平面的正方形 并繞z軸旋轉(zhuǎn).

            /**  

               One workaround to this issue is requiring users to always link with
               the same CRT as GLUT is compiled with.  That requires users supply a
               non-standard option.  GLUT 3.7 has its own built-in workaround where
               the executable's "exit" function pointer is covertly passed to GLUT.
               GLUT then calls the executable's exit function pointer to ensure that
               any "atexit" calls registered by the application are called if GLUT
               needs to exit.

               Note that the __glut*WithExit routines should NEVER be called directly.
               To avoid the atexit workaround, #define GLUT_DISABLE_ATEXIT_HACK.

            **
            */

            /**
            ** That for why define below
            *
            */

            #define GLUT_DISABLE_ATEXIT_HACK 


            #ifdef WIN32
              #include 
            <windows.h>
            #endif

            #include
            <gl/gl.h>
            #include
            <GL/glut.h>

            GLfloat angle
            =0.0;

            /*
            *顯示回調(diào)函數(shù)
            */

            void display()
            {
                
            //clear the color buffer 即每幀清屏
                glClear(GL_COLOR_BUFFER_BIT);

                
            //設(shè)置模型視圖矩陣
                glMatrixMode(GL_MODELVIEW);
                
            //設(shè)置當(dāng)前矩陣為單位矩陣
                glLoadIdentity();
                
            //將正方形按z軸旋轉(zhuǎn) angle角度
                glRotatef(angle,0.0,0.0,1.0);

                
            //畫一個(gè)正方形
                glBegin(GL_QUADS);
                    glVertex3f(
            -0.5,-0.5,0.0);
                    glVertex3f(
            0.5,-0.5,0.0);
                    glVertex3f(
            0.5,0.5,0.0);
                    glVertex3f(
            -0.5,0.5,0.0);
                glEnd();
                
            //glFlush();
                
            //雙緩存 顯示一幀,下一幀已經(jīng)在緩沖區(qū)畫好,交換出來就好
                
            //本身帶有一個(gè)強(qiáng)制的glFlush();
                glutSwapBuffers();
            }

            /*
            *空閑時(shí)間回調(diào)函數(shù)
            */

            void idlefunc()
            {
                
            //角度自增 實(shí)現(xiàn)正方形的旋轉(zhuǎn)
                angle+=1.0;
                
            if(angle>=360.0f
                    angle
            =0.0;
                
            //使得函數(shù)執(zhí)行完成后,調(diào)用重繪函數(shù)
                glutPostRedisplay();
            }

            /*
            *win32 main函數(shù)
            */

            void main(int argc, char **argv)
            {
                
            //初始化 glut
                glutInit(&argc, argv);
                
            //初始化顯示模式為 RGB 和雙緩沖
                glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
                
            //設(shè)置窗口左上角位置
                glutInitWindowPosition(100,100);
                
            //設(shè)置窗口的初始化大小
                glutInitWindowSize(512,512);
                
            //創(chuàng)建一個(gè)窗口標(biāo)題為  "字符串"
                glutCreateWindow("3D Tech- GLUT Tutorial");
                
            //注冊(cè)顯示回調(diào)函數(shù)
                glutDisplayFunc(display);
                
            //注冊(cè)空閑時(shí)間函數(shù)
                glutIdleFunc(idlefunc);
                
            //設(shè)置多邊形繪制模式為正面,線框式
                glPolygonMode(GL_FRONT,GL_LINE);
                
            //進(jìn)入仿真循環(huán)
                glutMainLoop();
            }








            posted on 2009-07-04 18:36 米游 閱讀(406) 評(píng)論(0)  編輯 收藏 引用 所屬分類: OpenGL/OSG
            精品国产一区二区三区久久| 97久久婷婷五月综合色d啪蜜芽| 国产精品久久自在自线观看| 狠狠色丁香久久婷婷综合五月| 潮喷大喷水系列无码久久精品| 亚洲国产天堂久久综合网站| 亚洲精品乱码久久久久久不卡| 777米奇久久最新地址| 99久久国产综合精品成人影院| 老男人久久青草av高清| 久久亚洲欧美日本精品| 久久毛片一区二区| 国产精品美女久久久网AV| 无码伊人66久久大杳蕉网站谷歌 | 2021最新久久久视精品爱| .精品久久久麻豆国产精品| 色偷偷88欧美精品久久久| 99国产精品久久| 久久久婷婷五月亚洲97号色| 久久一区二区免费播放| 久久国产亚洲精品麻豆| 久久er99热精品一区二区| 欧美成a人片免费看久久| 91精品日韩人妻无码久久不卡| 久久一日本道色综合久久| 欧美日韩精品久久久免费观看| 岛国搬运www久久| 日韩一区二区久久久久久| 国产综合久久久久久鬼色| 国产精品9999久久久久| 久久精品亚洲一区二区三区浴池 | 狠狠色噜噜狠狠狠狠狠色综合久久| 久久影院亚洲一区| 久久久精品国产亚洲成人满18免费网站| 9久久9久久精品| 久久久国产精品福利免费| 久久国产精品久久| 久久国产三级无码一区二区| 久久久久免费视频| 久久久一本精品99久久精品88| 久久久精品国产免大香伊 |