/* * cube.c * This program demonstrates a single modeling transformation, * glScalef() and a single viewing transformation, gluLookAt(). * A wireframe cube is rendered. */ #include "glut.h" #include void init(void) { glClearColor (0.0F, 0.0F, 0.7F, 1.0F); } void display(void) { glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); /* modeling transformation */ glLoadIdentity (); /* clear the matrix */ gluLookAt (3.0, 5.0, 6.0, // eye 1.0, 1.0, 1.0, // ref 0.0, 1.0, 0.0); // up /* desenha um elipsoide */ glTranslatef(1.0F, 1.0F, 1.0F); glScalef (0.3F, 0.4F, 0.5F); glColor3f (1.0F, 1.0F, 0.0F); glutWireSphere (1.0,8,8); glFlush (); } void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); glFrustum (-0.4, 0.4, -0.4, 0.4, 1.5, 20.0); glMatrixMode (GL_MODELVIEW); } void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: exit(0); break; } } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); init (); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; }