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

            剪裁區域

                 In OpenGL when you create a window to draw in we must specify the coordinate system we want to use and how to map the specified coordinates into physical screen coordinates. We would be using the 2D Cartesian coordinate system with the origin 0,0 at the centre of the screen. Before we can start plotting points, lines and shapes in a window we must also specify how to translate coordinate pairs into screen coordinates, by specifying the clipping area i.e the region of Cartesian space that occupies the window. 

            視口

            The clipping area height and width will rarely match the width and height of the window in pixels. The coordinate system must therefore be mapped from logical Cartesian coordinates to physical screen coordinates. This mapping is specified by a setting known as the viewport, which is the region within the window's client area that is used for drawing the clipping area. 

            頂點和基本圖元

            A vertex is nothing more than a coordinate in 2D or 3D space. In both 2D and 3D, when we draw an object we compose it with several smaller shapes called primitives which as 1 or 2 dimensional entities such as points, lines, and polygons. Each corner of an object composed of primitives is a vertex

            基本圖形繪制程序

            1,CCY457OpenGLView.h中加入下列變量:

            BOOL m_bPoint;        //Status of Point
                BOOL m_bLine;        //Status of Line
                BOOL m_bPolygon;    //Status of Polygon
                BOOL m_bTriangle;    //Status of Triangle

            2,并且加入四個菜單項及其對應的事件處理程序。

            void CCY457OpenGLView::OnShapesPoint() 
            {
            //畫點
                m_bPoint = TRUE;
                m_bLine 
            = FALSE;
                m_bPolygon 
            = FALSE;
                m_bTriangle 
            = FALSE;
                InvalidateRect(NULL,FALSE);    
            }
            void CCY457OpenGLView::OnShapesLine() 
            {
            //畫線
                m_bPoint = FALSE;
                m_bLine 
            = TRUE;
                m_bPolygon 
            = FALSE;
                m_bTriangle 
            = FALSE;        
                InvalidateRect(NULL,FALSE);    
            }
            void CCY457OpenGLView::OnShapesPolygon() 
            {
            //畫多邊形
                m_bPoint = FALSE;
                m_bLine     
            = FALSE;
                m_bPolygon 
            = TRUE;
                m_bTriangle 
            = FALSE;        
                InvalidateRect(NULL,FALSE);    
            }
            void CCY457OpenGLView::OnShapesTriangle() 
            {
            //畫三角形
                m_bPoint = FALSE;
                m_bLine     
            = FALSE;
                m_bPolygon 
            = FALSE;
                m_bTriangle 
            = TRUE;        
                InvalidateRect(NULL,FALSE);    
            }

            3,修改第二篇文章中的OnSize()函數,因為本文中只繪制2維圖形.

            void CCY457OpenGLView::OnSize(UINT nType, int cx, int cy) 
            {
                CView::OnSize(nType, cx, cy);
                GLdouble aspect_ratio; 
            // width/height ratio
                if ( 0 >= cx || 0 >= cy )
                {
                    
            return;
                }
                
            // select the full client area
                ::glViewport(00, cx, cy);
                
            // compute the aspect ratio
                
            // this will keep all dimension scales equal
                aspect_ratio = (GLdouble)cx/(GLdouble)cy;
                
            // select the projection matrix and clear it
                ::glMatrixMode(GL_PROJECTION);
                ::glLoadIdentity();
                
            // select the viewing volume
                
            //::gluPerspective(45.0f, aspect_ratio, .01f, 200.0f);
                ::gluOrtho2D(-10.0f10.0f-10.0f10.0f);    
                
            // switch back to the modelview matrix and clear it
                ::glMatrixMode(GL_MODELVIEW);
                ::glLoadIdentity();
            }

            4,RenderScene中加入具體的繪制代碼:

            void CCY457OpenGLView::RenderScene ()
            {
            //繪制函數
                if(m_bPoint==TRUE)
                {
                    glPointSize(
            3.0f);
                    glBegin(GL_POINTS);
                        glVertex2f(
            0.0f,0.0f);
                        glVertex2f(
            1.0f,0.0f);
                        glVertex2f(
            0.0f,1.0f);
                    glEnd();
                }
                
            else if(m_bLine==TRUE)
                {
                    glBegin(GL_LINES);
                        glVertex2f(
            0.0f,0.0f);
                        glVertex2f(
            1.0f,0.0f);
                    glEnd();
                }
                
            else if(m_bTriangle==TRUE)
                {
                    glBegin(GL_TRIANGLES);
                        glVertex2f(
            0.0f,0.0f);
                        glVertex2f(
            2.0f,0.0f);
                        glVertex2f(
            0.0f,2.0f);
                    glEnd();
                }
                
            else if(m_bPolygon==TRUE)
                {
                    glBegin(GL_POLYGON);
                        glVertex2f(
            0.0f,0.0f);
                        glVertex2f(
            3.0f,0.0f);
                        glVertex2f(
            4.0f,3.0f);
                        glVertex2f(
            1.5f,6.0f);
                        glVertex2f(
            -1.0f,3.0f);
                    glEnd();
                }
            }

             

            作者:洞庭散人

            出處:http://phinecos.cnblogs.com/    

            本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。
            原文鏈接:http://www.cnblogs.com/phinecos/archive/2008/11/05/1327343.html
            色婷婷综合久久久久中文| 久久精品国产WWW456C0M| 国产一区二区精品久久岳| 国内精品久久久久久中文字幕| 亚洲狠狠久久综合一区77777| 久久久久高潮综合影院| 国产成人精品久久综合| 久久综合综合久久综合| 免费观看久久精彩视频 | 国产精品久久久久久搜索| 久久久久久久综合综合狠狠| 久久国产AVJUST麻豆| 久久不见久久见免费影院www日本| 久久国产成人精品国产成人亚洲| 久久国产免费直播| 四虎影视久久久免费观看| 欧美激情精品久久久久| 麻豆久久久9性大片| 欧美激情精品久久久久久久| 88久久精品无码一区二区毛片 | 久久久久久国产精品无码下载| 国内精品久久久久| 久久国产热精品波多野结衣AV| 亚洲国产欧美国产综合久久| 久久人人爽人人爽人人av东京热| 久久青青草原精品影院| 精品久久无码中文字幕| 久久久久亚洲Av无码专| 一本综合久久国产二区| 亚洲精品美女久久久久99| 亚洲Av无码国产情品久久| 狠狠人妻久久久久久综合| 精品少妇人妻av无码久久| 国产人久久人人人人爽| 婷婷五月深深久久精品| 人妻无码中文久久久久专区| 亚洲欧美日韩中文久久| 亚洲午夜久久久久久久久久| 久久中文娱乐网| 婷婷综合久久狠狠色99h| …久久精品99久久香蕉国产|