lecture04-1

triangle 2 is v2 v3 v4 triangle 3 is v4 v3 v5 again

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: glVertex3fv(v0); glVertex3fv(v1); glVertex3fv(v2); v2 v0 v4 glVertex3fv(v3); v5 glVertex3fv(v4); glVertex3fv(v5); glEnd(); v1 • triangle 0 is v0, v1, v2 • triangle 1 is v2, v1, v3 (why not v1, v2, v3?) • triangle 2 is v2, v3, v4 • triangle 3 is v4, v3, v5 (again, not v3, v4, v5) triangle not v3 Double Buffering Avoids displaying partially rendered frame buffer OpenGL generates one raster image while another OpenGL raster image is displayed on monitor raster glxSwapBuffers (Display *dpy, Window, w) glutSwapBuffers (void) Learn OpenGL by example robot.c from the OpenGL Programming Guide Learn OpenGL by example Two bodies • Upper arm • Lower arm Major tasks • Position • Orientation Learn OpenGL by example Both bodies originally at origin Learn OpenGL by example Headers #include <GL/gl.h> #include #include <GL/glu.h> #include <GL/glut.h> Learn OpenGL by example int main(int argc, char** argv) { int glutInit(&argc, argv); glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); glutInitDisplayMode glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutInitWindowPosition glutCreateWindow (argv[0]); init (); glutDisplayFunc(display); glutReshapeFunc(reshape); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; } return Learn OpenGL by example void init(void) { void glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_FLAT); } Learn OpenGL by example void display(void){ void glClear (GL_COLOR_BUFFER_BIT); glPushMatrix(); glTranslatef (-1.0, 0.0, 0.0); glRotatef ((GLfloat) shoulder, 0.0, 0.0, 1.0); glTranslatef (1.0, 0.0, 0.0); glPushMatrix(); glScalef (2.0, 0.4, 1.0); glutWireCube (1.0); glPopMatrix(); Continued… Continued… Learn OpenGL by example glTranslatef (1.0, 0.0, 0.0); glTranslatef glRotatef ((GLfloat) elbow, 0.0, 0.0, 1.0); glTranslatef (1.0, 0.0, 0.0); glPushMatrix(); glScalef (2.0, 0.4, 1.0); glutWireCube (1.0); glPopMatrix(); glPopMatrix(); glutSwapBuffers(); glutSwapBuffers(); }...
View Full Document

Ask a homework question - tutors are online