-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriangle_Circle_Square.cpp
More file actions
71 lines (60 loc) · 1.75 KB
/
Triangle_Circle_Square.cpp
File metadata and controls
71 lines (60 loc) · 1.75 KB
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
#include <GL/glut.h>
#include <math.h>
void line_join(float x1 , float y1 , float x2 , float y2){
glBegin(GL_LINES);
glVertex2f(x1,y1);
glVertex2f(x2,y2);
glEnd();
glFlush();
}
void drawHollowCircle(GLfloat x, GLfloat y, GLfloat radius){
int i;
int lineAmount = 100; //# of triangles used to draw circle
//GLfloat radius = 0.8f; //radius
GLfloat twicePi = 2.0f * 3.14;
glBegin(GL_LINE_LOOP);
for(i = 0; i <= lineAmount;i++) {
glVertex2f(
x + (radius * cos(i * twicePi / lineAmount)),
y + (radius* sin(i * twicePi / lineAmount))
);
}
glEnd();
glFlush();
}
void displayMe(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glColor3f(0.6,0.7,0.9);
line_join(-1.0, 0.0, -0.8, 0.4);
line_join(-1.0, 0.0, -0.6, 0.0);
line_join(-0.6, 0.0, -0.8, 0.4);
line_join(-0.6, 0.0, -0.6, 0.0);
line_join(-0.6, 0.0, -0.6, -0.4);
line_join(-0.2, -0.4, -0.6, -0.4);
line_join(-0.2, -0.4, -0.2, 0.0);
line_join(-0.2, 0.0, -0.6, 0.0);
line_join(-0.2, 0.0, 0.0, 0.4);
line_join(0.2, 0.0, 0.0, 0.4);
line_join(-0.2, 0.0, 0.2, 0.0);
line_join(0.2, 0.0, 0.2, -0.4);
line_join(0.6, -0.4, 0.2, -0.4);
line_join(0.6, -0.4, 0.6, 0.0);
line_join(0.2, 0.0, 0.6, 0.0);
line_join(0.8, 0.4, 0.6, 0.0);
line_join(0.8, 0.4, 1.0, 0.0);
line_join(0.6, 0.0, 1.0, 0.0);
drawHollowCircle(-0.4, -0.2, 0.2);
drawHollowCircle(0.4, -0.2, 0.2);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB);
glutInitWindowSize(550, 550);
glutCreateWindow("Rakshit");
glutDisplayFunc(displayMe);
glutMainLoop();
return 0;
}