-
Notifications
You must be signed in to change notification settings - Fork 0
/
3D_Shapes.c
73 lines (61 loc) · 1.4 KB
/
3D_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
#include <windows.h>
#include<GL/glut.h>
#include<math.h>
#include<stdio.h>
int r,h,k;
void init() {
glEnable(GL_DEPTH_TEST);
glOrtho(-100.0,100.0,-100.0,100.0,-100.0,100.0);
}
void sphere() {
printf("\nEnter the radius of sphere: ");
scanf("%d",&r);
glColor3f(1.0f,1.0f,1.0f);
glutWireSphere(r, 50, 50);
glFlush();
}
void cone() {
printf("\nEnter the base radius of cone: ");
scanf("%d",&r);
printf("\nEnter the height of cone: ");
scanf("%d",&h);
glColor3f(1.0f,1.0f,1.0f);
glutWireCone(r,h, 50, 50);
glFlush();
}
void cube() {
printf("\nEnter the side of cube: ");
scanf("%d",&r);
glColor3f(0.0f,0.0f,1.0f);
glutSolidCube(r);
glFlush();
}
void teapot() {
}
void display(void) {
glRotatef( 20, 1.0, 0.0, 0.0 );
glRotatef( -20, 0.0, 1.0, 0.0 );
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if(k == 1)
sphere();
else if(k == 2)
cone();
else if(k == 3)
cube();
else
teapot();
}
int main(int argc, char** argv) {
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
printf("1.Sphere\n2.Cone\n3.Cube\n4.Teapot");
printf("\nEnter Your Choice : ");
scanf("%d",&k);
glutInitWindowSize(500,500);
glutInitWindowPosition(200,200);
glutCreateWindow("3D-Shapes");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}