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

            剪裁區(qū)域

                 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. 

            頂點(diǎn)和基本圖元

            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,并且加入四個(gè)菜單項(xiàng)及其對(duì)應(yīng)的事件處理程序。

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

            3,修改第二篇文章中的OnSize()函數(shù),因?yàn)楸疚闹兄焕L制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 ()
            {
            //繪制函數(shù)
                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/    

            本文版權(quán)歸作者和博客園共有,歡迎轉(zhuǎn)載,但未經(jīng)作者同意必須保留此段聲明,且在文章頁(yè)面明顯位置給出原文連接,否則保留追究法律責(zé)任的權(quán)利。
            原文鏈接:http://www.cnblogs.com/phinecos/archive/2008/11/05/1327343.html
            欧美精品丝袜久久久中文字幕| 久久久久一区二区三区| 精品久久久久中文字| 久久91综合国产91久久精品| 久久婷婷五月综合色高清| 伊人久久综合无码成人网| 人妻无码精品久久亚瑟影视| 久久久久久一区国产精品| 99久久精品久久久久久清纯| 成人a毛片久久免费播放| 99精品久久久久久久婷婷| 国产亚洲成人久久| 久久久久久久综合日本| 午夜精品久久久久久| 久久热这里只有精品在线观看| 久久人做人爽一区二区三区| 亚洲国产精品成人久久| 狠狠色婷婷久久一区二区三区| 97久久精品无码一区二区| 99久久免费国产精品| 欧美日韩精品久久久久| 久久久久亚洲AV成人网人人网站 | 香蕉久久夜色精品国产尤物| 久久频这里精品99香蕉久| 色综合久久久久综合体桃花网 | 久久精品国产亚洲网站| 国产精品一区二区久久精品无码 | 国产ww久久久久久久久久| 欧美国产精品久久高清| 色婷婷综合久久久久中文| 国产高潮国产高潮久久久| 国产精品综合久久第一页| 久久精品国产99国产精品亚洲| 久久精品国产亚洲av麻豆色欲| 伊人热人久久中文字幕| 超级97碰碰碰碰久久久久最新| 久久久久久九九99精品| 久久久网中文字幕| 嫩草伊人久久精品少妇AV| 久久久久久久亚洲精品| 色偷偷久久一区二区三区|