43 static const int FPS = 20;
52 glViewport(0, 0, w, h);
53 GLfloat aspect = (GLfloat)w / (GLfloat)h;
54 glMatrixMode(GL_PROJECTION);
59 glOrtho(-50.0, 50.0, -50.0 / aspect, 50.0 / aspect, -1.0, 1.0);
66 glOrtho(-10.0 * aspect, 10.0 * aspect, -10.0, 10.0, -1.0, 1.0);
72 glClear(GL_COLOR_BUFFER_BIT);
73 glMatrixMode(GL_MODELVIEW);
76 glColor3f(1.0, 1.0, 1.0);
78 glutWireTorus(0.5, 3, 15, 30);
115 glutTimerFunc(1000 /
FPS,
timer, v);
122 void mouse(
int button,
int state,
int x,
int y) {
123 if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
125 }
else if (button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN) {
131 glClearColor(0.0, 0.0, 0.0, 1.0);
132 glColor3f(1.0, 1.0, 1.0);
134 glMatrixMode(GL_PROJECTION);
136 gluPerspective(60.0, 4.0 / 3.0, 1, 40);
138 glMatrixMode(GL_MODELVIEW);
140 gluLookAt(4, 6, 5, 0, 0, 0, 0, 1, 0);
143 int main(
int argc,
char **argv) {
144 glutInit(&argc, argv);
145 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
148 glutInitWindowPosition(80, 80);
149 glutInitWindowSize(1000, 800);
150 glutCreateWindow(
"A Torus on a Plane");
157 glutTimerFunc(100,
timer, 0);
158 glutMouseFunc(
mouse);
void reshape(GLint w, GLint h)
static GLfloat current_rot
int main(int argc, char **argv)
void mouse(int button, int state, int x, int y)