CH 3
CH 3
They can be anything from 2-D primitives such as points, lines and
glBegin(GL_POINTS);
glVertex2f(100.0, 200.0);
glVertex2f(150.0, 200.0);
glVertex2f(150.0, 250.0);
glEnd();
Note that when we specify 2-D points, OpenGL will actually create
3-D points with the third coordinate (the z-coordinate) equal to
zero.
intervals.
Find successive pixel positions by adding on (δx, δy) and rounding to the
nearest integer, i.e.
xk+1 = xk + δx
yk+1 = yk + δy
These improvements arise from the observation that for any given line,
point on the line, we know the next line point must be either pixel A or
pixel B.
First, we denote by dupper and dlower to the distances between the centres
calculated as:
and define pk as
Finally
Lines are drawn separately and any extra vertices (i.e. a start-point
with no end-point) are ignored.
GL_LINE_STRIP will create a connected polyline, in which each vertex
is joined to the one before it and after it.
The first and last vertices are only joined to one other vertex
glRecti (x1, y1, x2, y2), where (x1,y1) and (x2,y2) define opposite
corners of the rectangle.
Actually when we call the glRect* routine, OpenGL will construct a
polygon with vertices defined in the following order: (x1,y1), (x2,y1),
(x2,y2), (x1,y2) eg:- glRecti(200,100,50,250);
computer graphice 12/19/2024 26
Cont…
GL_POLYGON
The GL_POLYGON symbolic constant defines a single convex polygon.
GL_TRIANGLES
The GL_TRIANGLES symbolic constant causes the glBegin … glEnd pair
to treat the vertex list as groups of three 3 vertices, each of which
defines a triangle.
GL_TRIANGLE_STRIP
To form polygonal meshes it is often convenient to define a number of
triangles using a single glBegin … glEnd pair.
GL_QUADS
Using the GL_QUADS primitive, the vertex list is treated as groups of
four vertices, each of which forms a quadrilateral.
If the number of vertices specified is not a multiple of four, then the
extra vertices are ignored.
GL_QUAD_STRIP
GL_QUAD_STRIP allows us to define a strip of quadrilaterals.
The first four vertices form the first quadrilateral, and each subsequent
pair of vertices is combined with the two before them to form another
quadrilateral.
computer graphice 12/19/2024 28
Next class