CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <GL/glut.h>
void init(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0); // set the background to white
glMatrixMode(GL_PROJECTION); // set projection parameters
glLoadIdentity();
gluOrtho2D(0.0, 400.0, 0.0, 400.0);
}
void lineSegment(void)
{
// GUAD ONE
glClear(GL_COLOR_BUFFER_BIT); // Clear display window
glColor3f(0.6f, 0.6f, 0.6f); // set the drawing color to GREY
glBegin(GL_QUADS); // start drawing in 'GUAD' mode
glVertex2i(240, 340); // specify the lines geometry
glVertex2i(240, 270);
glVertex2i(340, 270);
glVertex2i(340, 340);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(0.0f, 0.0f, 0.0f);
glVertex2i(240, 340);
glVertex2i(240, 270);
glVertex2i(340, 270);
glVertex2i(340, 340);
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run