-
Notifications
You must be signed in to change notification settings - Fork 0
/
Geometrical_Shapes.c
77 lines (67 loc) · 1.86 KB
/
Geometrical_Shapes.c
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <windows.h>
#include <GL/glut.h>
#include <stdio.h>
void initGL() {
glClearColor(0.0, 0.0, 0.0, 0.0);
glOrtho(-12.0, 12.0, -12.0, 12.0, -12.0, 12.0); // 12 x 12 graph
}
void display() {
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_QUADS);
glColor3f(1.0, 0.0, 0.0); // Red
glVertex2f(-8.0, 3.0);
glVertex2f(-2.0, 3.0);
glVertex2f(-2.0, 7.0);
glVertex2f(-8.0, 7.0);
glEnd();
glBegin(GL_LINES);
glColor3f(0.0, 0.0, 1.0); // Blue
glVertex2f(-7.0, -9.0);
glVertex2f(-1.0, -9.0);
glEnd();
glBegin(GL_TRIANGLES);
glColor3f(0.0, 1.0, 0.0); // Green
glVertex2f(3.0, -10.0);
glVertex2f(9.0, -10.0);
glVertex2f(6.0, -6.0);
glEnd();
glBegin(GL_TRIANGLE_STRIP);
glColor3f(0.0, 1.0, 1.0); // Light Blue
glVertex2f(-9.0, -4.0);
glVertex2f(-9.0, 2.0);
glVertex2f(-6.0, -3.0);
glVertex2f(-6.0, 2.0);
glVertex2f(-0.3, -1.0);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1.0, 1.0, 1.0); // White
glVertex2f(8.0, 4.0);
glVertex2f(10.0, 4.0);
glVertex2f(11.0, 6.0);
glVertex2f(10.0, 8.0);
glVertex2f(8.0, 8.0);
glVertex2f(7.0, 6.0);
glEnd();
glBegin(GL_QUAD_STRIP);
glColor3f(1.0, 1.0, 0.0); // Yellow
glVertex2f(1.0, 3.0);
glVertex2f(1.0, -3.0);
glVertex2f(3.0, 3.0);
glVertex2f(3.0, -3.0);
glVertex2f(3.0, 5.0);
glVertex2f(3.0, -5.0);
glVertex2f(7.0, 5.0);
glVertex2f(7.0, -5.0);
glEnd();
glFlush();
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutCreateWindow("EXP 2");
glutInitWindowSize(1000, 1000);
glutInitWindowPosition(500, 500);
glutDisplayFunc(display);
initGL();
glutMainLoop();
return 0;
}