-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSphere.cpp
More file actions
52 lines (45 loc) · 1.04 KB
/
Sphere.cpp
File metadata and controls
52 lines (45 loc) · 1.04 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
#include <GL/glut.h>
GLfloat xRotate, yRotate;
GLdouble radius=1;
void display(void);
void reshape(int x, int y);
void idle(void)
{
xRotate += 0.1;
yRotate += 0.1;
display();
}
int main (int argc, char **argv)
{
glutInit(&argc, argv);
glutInitWindowSize(500,500);
glutCreateWindow("Solid Sphere");
xRotate = yRotate = 30.0;
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutIdleFunc(idle);
glutMainLoop();
return 0;
}
void display(void)
{
glMatrixMode(GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0,0.0,-6.0);
glColor3f(0.6, 0.7, 0.9);
glRotatef(xRotate,1.0,0.0,0.0);
glRotatef(yRotate,0.0,1.0,0.0);
glScalef(1.0,1.0,1.0);
glutWireSphere(radius,20,25);
glFlush();
}
void reshape(int x, int y)
{
if (y == 0 || x == 0) return;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(39.0,(GLdouble)x/(GLdouble)y,0.6,21.0);
glMatrixMode(GL_MODELVIEW);
glViewport(0,0,x,y);
}