Origin looking down z axis up vector aligned with y

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: era’s vertical up[XYZ]: vector Creates a matrix that transforms points in world coordinates to camera coordinates Creates camera • Camera at origin • Looking down -Z axis • Up vector aligned with Y axis OpenGL: Perspective Projection In OpenGL: In • Projections implemented by projection matrix Projections projection • gluPerspective() creates a perspective projection matrix: projection glSetMatrix(GL_PROJECTION); glLoadIdentity(); //load an identity matrix gluPerspective(vfov, aspect, near, far); Parameters to gluPerspective(): Parameters gluPerspective() • vfov: vertical field of view • aspect: window width/height • near, far: distance to near & far clipping planes far OpenGL: Lighting Setup lighting, if any Simplest option: change the current color between Simplest current polygons or vertices polygons • glColor() sets the current color Or OpenGL provides a simple lighting model: • Set parameters for light(s) – Intensity, position, direction & falloff (if applicable) Intensity, • Set material parameters to describe how light reflects from the Set material surface surface Won’t go into details now; check the red book if Won’t interested interested OpenGL: Specifying Geometry Geometry in OpenGL consists of a list of vertices in Geometry between calls to glBegin() and glEnd() glBegin() glEnd() • A simple example: telling GL to render a triangle glBegin(GL_POLYGON); glVertex3f(x1, y1, z1); glVertex3f(x2, y2, z2); glVertex3f(x3, y3, z3); glEnd(); • Usage: glBegin(geomtype) where geomtype is: Usage: glBegin( – Points, lines, polygons, triangles, quadrilaterals, etc... Primitive Types GL_POINTS GL_LINE • {S | _STRIP | _LOOP} GL_TRIANGLE • {S | _STRIP | _FAN} GL_QUAD • {S | _STRIP} GL_POLYGON GL_POLYGON List of vertices defines polygon edges Polygon must be convex Non-planar Polygons Imagine polygon with non-planar vertices Some perspectives will be rendered as concave Some polygons polygons These concave polygons may not rasterize These correctly correctly OpenGL: More Examples Example: GL supports quadrilaterals: glBegin(GL_QUADS); glVertex3f(-1, 1, 0); glVertex3f(-1, glVertex3f(-1, -1, 0); glVertex3f(-1, glVertex3f(1, -1, 0); glVertex3f(1, 1, 0); glEnd(); • This type of operation is called immediate-mode rendering; This immediate-mode each command h...
View Full Document

Ask a homework question - tutors are online