OpenGL Function Format glVertex3fv( v ) Number of components 2 - (x, y) 3 - (x, y, z) 4 - (x, y, z, w) Data Type b - byte ub - unsigned byte s - short us - unsigned short i - int ui - unsigned int f - float d - double Vector omit “v” for scalar form glVertex2f( x, y )
Optimize Shared Vertex Data Triangle Strip § Describe a triangle with less than 3 vertices § Specify vertices in order of v0 , v1 , v2 , … vn-1 § Maintain the counter-clockwise order (for back face culling), the internal vertex order is something like: 0-1-2, 1-3-2, 2-3-4, 3-5-4,… (instead of 0-1-2, 1-2-3, 2-3-4,…)
Vertex Attributes § Besides the position of vertices (specified by glVertex), there are several other attributes you can associate each vertex with: § glColor*() // shading § glNormal*() // lighting and shading § glTexCoord*() // texturing § You can put some other OpenGL instructions between glBegin and glEnd too. § Also you can put CPU instructions too, like for loop
Points, Lines, and Polygons There are some display state variables and drawing properties you can play with, like: § Point size: glPointSize() § Line width: glLinewidth() § Dash or dotted line: GL_LINE_STIPPLE, glLineStipple() § Polygon pattern: GL_POLYGON_STIPPLE, glPolygonStipple()
Reading Draw OpenGL Geometric Primitives between glBegin() and glEnd() § Required reading: Red Book (pdf): Ch2 p36 – p39 § What kinds of OpenGL instructions can appear between glBegin() and glEnd()? § What functionality do they each provide? To specify polygon filling pattern § Required reading: Red Book (pdf): Chapter 2 p44 § Also, read Red Book: example 2-6. § Suggested reading: Hearn Baker: chapter 3 (bitmap function: p. 143 – 144 & fill pattern function: p. 206 – 207) Shading § Required reading: Red Book (pdf): Chapter 4 p123-p125 § Also example 4-1, about smooth shading (Gouraud shading)