• <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
            亚洲中文久久精品无码| 99久久无码一区人妻a黑| 欧美一级久久久久久久大| 久久成人小视频| 成人免费网站久久久| 国产成人AV综合久久| 欧美黑人激情性久久| 狠狠色婷婷久久一区二区三区| 久久综合狠狠综合久久激情 | 久久久久国产精品熟女影院| 国产精品久久国产精品99盘 | 亚洲∧v久久久无码精品| 久久99精品久久久久婷婷| 久久高潮一级毛片免费| 欧美亚洲色综久久精品国产| 久久精品免费大片国产大片| 久久精品亚洲日本波多野结衣 | 久久AAAA片一区二区| 人妻无码中文久久久久专区| 久久精品夜色噜噜亚洲A∨| 久久久久久久亚洲Av无码| 亚洲人成电影网站久久| 婷婷综合久久中文字幕| 久久香蕉国产线看观看精品yw | 精品久久久久久久久久中文字幕 | 91麻精品国产91久久久久| 久久国产色av免费看| 欧美国产精品久久高清| 久久99精品国产99久久6| 亚洲一区二区三区日本久久九| 无码日韩人妻精品久久蜜桃| 国产精品久久久久久五月尺| 一本大道久久东京热无码AV| 久久久久97国产精华液好用吗| 国产精品岛国久久久久| 99久久99久久久精品齐齐 | 国产精品天天影视久久综合网| 香蕉久久夜色精品升级完成 | 久久精品国内一区二区三区| 2022年国产精品久久久久| 久久成人国产精品|