• <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
            色婷婷综合久久久久中文字幕| 久久久久久午夜成人影院| 久久精品国产精品亜洲毛片| 久久精品亚洲福利| 午夜人妻久久久久久久久| Xx性欧美肥妇精品久久久久久 | 国内精品久久久久影院免费| 国产精品成人久久久久三级午夜电影 | 欧美伊人久久大香线蕉综合| 99久久精品国内| 欧美久久亚洲精品| 精品无码久久久久久尤物| 久久婷婷五月综合97色直播| 久久精品中文騷妇女内射| 久久精品一区二区三区中文字幕| 99蜜桃臀久久久欧美精品网站| 欧美激情精品久久久久| 亚洲AV无码久久精品成人| 久久乐国产精品亚洲综合| 久久精品国产半推半就| 久久久精品人妻一区二区三区蜜桃| 久久福利片| 国产农村妇女毛片精品久久| 久久久久久久久无码精品亚洲日韩 | 四虎国产精品成人免费久久| 老司机国内精品久久久久| WWW婷婷AV久久久影片| 亚洲香蕉网久久综合影视| 欧美激情精品久久久久久久九九九 | 久久福利资源国产精品999| 国产精品免费久久| 久久综合九色综合97_久久久| 精品久久无码中文字幕| 中文无码久久精品| 亚洲国产精品久久久天堂| 久久天天婷婷五月俺也去| 无码人妻少妇久久中文字幕| 久久久久亚洲精品中文字幕| 久久综合久久鬼色| 亚洲一级Av无码毛片久久精品| 国内精品伊人久久久久妇|