• <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í),不斷的思考,才能不斷的進步.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. 

            頂點和基本圖元

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

            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()函數(shù),因為本文中只繪制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)作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責(zé)任的權(quán)利。
            原文鏈接:http://www.cnblogs.com/phinecos/archive/2008/11/05/1327343.html
            亚洲精品美女久久久久99| 亚洲伊人久久综合影院| 久久久久久久91精品免费观看| 国产精品禁18久久久夂久 | 亚洲精品乱码久久久久久| 久久久久国产精品三级网| 国产一区二区三精品久久久无广告 | 久久国产乱子伦精品免费强| 亚洲乱码精品久久久久..| 久久久久久综合网天天| 国产精品久久新婚兰兰| 久久久久波多野结衣高潮| 中文字幕无码久久久| 无码AV中文字幕久久专区| 久久精品国产亚洲AV高清热| 久久久无码精品亚洲日韩蜜臀浪潮| 亚洲精品乱码久久久久久| 久久精品国产免费一区| 久久精品国产亚洲精品| 久久久久久精品免费看SSS| 亚洲精品无码专区久久久 | 久久香蕉国产线看观看乱码| 久久综合综合久久97色| 无码任你躁久久久久久老妇| 中文字幕久久波多野结衣av| 久久久久亚洲AV无码麻豆| 亚洲天堂久久精品| 亚洲国产精品综合久久一线| 亚洲乱码精品久久久久..| 久久99亚洲综合精品首页| 久久综合九色综合欧美就去吻| 久久婷婷五月综合97色直播| 99久久er这里只有精品18| 久久99精品国产麻豆蜜芽| 影音先锋女人AV鲁色资源网久久 | 99久久国产亚洲综合精品| 日韩精品久久无码人妻中文字幕 | 久久电影网一区| 国产精品一区二区久久精品涩爱| 情人伊人久久综合亚洲| 色欲综合久久中文字幕网|