Trim area
In OpenGL when you create a Windows to draw in the we must specify the coordinate system we want to use and how to map the spec Ified coordinates into physical screen coordinates. We are using the 2D Cartesian coordinate system with the Origin 0,0 at the centre of the would. Before we can start plotting points, lines and shapes in a window we must also specify you to translate coordinate I nto screen coordinates, by specifying the clipping area i.e the region of Cartesian of spaces that occupies the window.
View Port
The clipping area height and width would rarely match the width and height of the window in pixels. The coordinate system must therefore is mapped from logical Cartesian, to coordinates screen physical. This mapping was specified by a setting known as the viewport, which are the region within the window ' s client area Used for drawing the clipping area.
Vertices and basic entities
A vertex is no more than a coordinate in 2D or 3D spaces. In both 2D and a, when we draw an object we compose it with several smaller shapes called primitives which as 1 or 2 dime Nsional entities such as points, lines, and polygons. Each corner of an object composed the primitives is a vertex
Basic Graphics Drawing Program
1, add the following variables to the CCY457OpenGLView.h:
2, and add four menu items and their corresponding event handlers.
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);
}