• <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  評論-23  文章-0  trackbacks-0

            glut是opengl輔助庫.

            現通過它實現一個位于z=0平面的正方形 并繞z軸旋轉.

            /**  

               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;

            /*
            *顯示回調函數
            */

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

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

                
            //畫一個正方形
                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();
                
            //雙緩存 顯示一幀,下一幀已經在緩沖區畫好,交換出來就好
                
            //本身帶有一個強制的glFlush();
                glutSwapBuffers();
            }

            /*
            *空閑時間回調函數
            */

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

            /*
            *win32 main函數
            */

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








            posted on 2009-07-04 18:36 米游 閱讀(405) 評論(0)  編輯 收藏 引用 所屬分類: OpenGL/OSG
            色8激情欧美成人久久综合电| 狠狠久久综合伊人不卡| 欧美激情一区二区久久久| 亚洲国产精品成人久久| 久久久久久久91精品免费观看| 久久人人爽人人爽人人爽| 97精品国产91久久久久久| 精品久久久久中文字幕一区| 中文无码久久精品| 日本一区精品久久久久影院| 国色天香久久久久久久小说| 久久精品免费观看| 色综合久久中文字幕综合网| 少妇内射兰兰久久| 精品综合久久久久久88小说| 亚洲精品无码成人片久久| 久久不见久久见免费影院www日本| 欧美日韩精品久久久久| 久久艹国产| 国产精品99久久不卡| 久久久久久九九99精品| 久久亚洲日韩看片无码| 久久天天日天天操综合伊人av| 久久精品亚洲日本波多野结衣 | 久久国产成人精品麻豆| 久久精品桃花综合| 色婷婷噜噜久久国产精品12p| 久久综合狠狠综合久久激情 | 国内精品九九久久精品| 久久人人爽人人爽人人片AV东京热| 久久99国产精品久久99| 国产成人综合久久综合| 久久精品无码专区免费青青| 久久综合亚洲色一区二区三区| 久久精品国产亚洲一区二区三区| 国产精品欧美亚洲韩国日本久久| 久久99国产综合精品| 久久亚洲精品无码AV红樱桃| 午夜精品久久久久久中宇| 亚洲中文字幕无码久久综合网| 狠狠色丁香久久婷婷综合|