{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture04-1

0j 00 00 10 gltranslatef 30 00 00 drawbolt

Info icon This 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: system draw_wheel( ); for (j=0; j<5; j++) { glPushMatrix (); glRotatef(72.0*j, 0.0, 0.0, 1.0); glTranslatef (3.0, 0.0, 0.0); draw_bolt ( ); glPopMatrix ( ); R RT RTv Global – Bottom Up Start Trans Rot Matrix Manipulation – Example Matrix Local coordinate system draw_wheel( ); for (j=0; j<5; j++) { glPushMatrix (); glRotatef(72.0*j, 0.0, 0.0, 1.0); glTranslatef (3.0, 0.0, 0.0); draw_bolt ( ); glPopMatrix ( ); R RT RTv Local – Top Down Start Rot Trans OpenGL: Conventions Functions in OpenGL start with gl gl Functions • Most functions just gl (e.g., glColor()) Most glColor() • Functions starting with glu are utility functions (e.g., Functions glu gluLookAt()) gluLookAt() • Functions starting with glx are for interfacing with the X Functions glx Windows system (e.g., in gfx.c) Windows OpenGL: Conventions Function names indicate argument type and number • Functions ending with f take floats Functions • Functions ending with i take ints Functions • Functions ending with b take bytes Functions • Functions ending with ub take unsigned bytes Functions ub • Functions that end with v take an array. Functions Examples • glColor3f() takes 3 floats • glColor4fv() takes an array of 4 floats glColor4fv() takes OpenGL: Conventions Variables written in CAPITAL letters • Example: GLUT_SINGLE, GLUT_RGB • usually constants • use the bitwise or command (x | y) to combine constants OpenGL: Simple Use Open a window and attach OpenGL to it Set projection parameters (e.g., field of view) Setup lighting, if any Main rendering loop • Set camera pose with gluLookAt() Set – Camera position specified in world coordinates • Render polygons of model – Simplest case: vertices of polygons in world coordinates OpenGL: Simple Use Open a window and attach OpenGL to it • glutCreateWindow() or FLTK window method OpenGL: Perspective Projection Set projection parameters (e.g., field of view) Typically, we use a perspective projection perspective • Distant objects appear smaller than near objects Distant • Vanishing point at center of screen • Defined by a view frustum (draw it) Defined view Other projections: orthographic, isometric Other orthographic isometric Setting up Camera glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt( eyeX, eyeY, eyeZ, eyeX, lookX, lookY, lookZ, upX, upY, upZ); upX, • eye[XYZ]: camera position in world coordinates • look[XYZ]: a point centered in camera’s view • up[XYZ]: a vector defining the cam...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern