In this recipe, we will learn to draw four different shapes: a square, a triangle, points, and a line.
The following are the steps to make different graphical shapes:
- Initialize GLUT, define the window size, create the window, and set the position of the window.
- Define the callback function that will be automatically invoked after displaying the window.
- To draw a square, first, define its color.
- Draw a square by defining its four vertices and enclosing them within glBegin and glEnd statements along with the GL_QUADS keyword.
- To draw a line, set the width and color of the line.
- Group a pair of vertices within glBegin and glEnd with the GL_LINES keyword to draw a line.
- To draw the...