General ======= (performance note): VPU currently supports only 32bit data. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - Might not be supported. If not then saperate: 1) glClear(GL_COLOR_BUFFER_BIT); 2) glClear(GL_DEPTH_BUFFER_BIT); Vertex Arrays ============= 1) Activate (enable) up to six arrays, each to store a different type of data: vertex coordinates, RGBA colors, color indices, surface normals, texture coordinates, or polygon edge flags. void glEnableClientState(GLenum array); void glDisableClientState(GLenum array); array: GL_COLOR_ARRAY, GL_EDGE_FLAG_ARRAY, GL_INDEX_ARRAY, GL_NORMAL_ARRAY, GL_TEXTURE_COORD_ARRAY, GL_VERTEX_ARRAY 2) Put data into the array or arrays. The arrays are accessed by the addresses of (that is, pointers to) their memory locations. In the client-server model, this data is stored in the client's address space. void glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); void glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); void glIndexPointer (/* 1 */ GLenum type, GLsizei stride, const GLvoid *pointer); void glNormalPointer (/* 3 */ GLenum type, GLsizei stride, const GLvoid *pointer); void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); void glEdgeFlagPointer(/* 1 */ /*bool*/ GLsizei stride, const GLboolean *pointer); 3) Draw geometry with the data. OpenGL obtains the data from all activated arrays by dereferencing the pointers. In the client-server model, the data is transferred to the server's address space. There are three ways to do this: 3.1) Accessing individual array elements (randomly hopping around). void glArrayElement(GLint index); // Call between glBegin and glEnd 3.2) Creating a list of individual array elements (methodically hopping around). void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); 3.3) Processing sequential array elements. void glInterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer); format: GL_V2F, GL_V3F, GL_C4UB_V2F, GL_C4UB_V3F, GL_C3F_V3F, GL_N3F_V3F, GL_C4F_N3F_V3F, GL_T2F_V3F, GL_T4F_V4F, GL_T2F_C4UB_V3F, GL_T2F_C3F_V3F, GL_T2F_N3F_V3F, GL_T2F_C4F_N3F_V3F, GL_T4F_C4F_N3F_V4F * It's a definishion method. Use glArrayElements/glDrawElements to render. Vertex Transformation ===================== Vertex -> Modelview Matrix -> Projection Matrix -> Prespective Division -> Viewport Transformation Global coordinate system: Oposite direction of the transformation code. Color and Light =============== Lighting Calculations -> Shading Model Light(L) and Material(M) ======================== Light source 1: (LR1, LG1, LB1) Light source 2: (LR2, LG2, LB2) Material: (MR, MG, MB) Result: ((LR1+LR2)*MR, (LG1_LG2)*MG, (LB1+LB2)*MB) 1) Define normal vectors for each vertex of all the objects. 2) Create, select, and position one or more light sources. 3) Create and select a lighting model. 4) Define material properties for the objects in the scene. Texture Maping ============== (performance note): Specify textures in a 4-component BGRA format for maximum. general flow: 1. specify textures in texture objects 2. set texture filter 3. set texture function 4. set texture wrap mode 5. set optional perspective correction hint 6. bind texture object 7. enable texturing 8. supply/generate texture coordinates for vertex Part 1: glPixelStorei - Pixel alignment in the memory glGenTextures - Generates textures glBindTexture - Binds to a texture for the first time (determines the dimensionality of the texture: 1D/2D) glTexParameteri - Texture maping parameters (min/mag filters, wraping) glTexImage2D - Specifies the texture image glCopyTexImage2D - Specifies the texture image glTexSubImage2D - Specifies the texture image glCopyTexSubImage2D - Specifies the texture image gluBuild2DMipmaps - Generates mipmaps Part 2: glTexEnvf - Sets the maping type (modulate/blend/decal/replace) glBindTexture - Binds to a texture glTexCoord2f - Specifies the texture coordinates (drawing) part 3: glTexGenf - Generates texture coordinates (object linear/eye linear/sphere maping) (Advanced Graphics Programming Techniques Using OpenGL p136) Bitmaps ======= (performance note): Use bitmaps in display lists. (performance note): Render fonts and widgets as textures. Blending ======== (performance note): Fog and blending are not supported in hardware (ATI). Using them results in fall back to software rendering. Display Lists ============= * Routines that depend upon the client state when they are executed can't be stored in a display list. Usage: 1) Matrix operations. 2) Raster bitmaps and images. 3) Lights, material properties, and lighting models. 4) Textures. 5) Polygon stipple patterns. Pixel Drawing ============= Elements -> Fragments -> Pixels Improving Rates: 1) Set all pixel-transfer parameters to their default values, and set pixel zoom to (1.0,1.0). 2) Disable all fragment operations applied to pixels as they are drawn into the framebuffer. 3) Disable texturing and lighting. 4) It's faster to draw a large pixel rectangle than to draw several small ones. 5) Use small data types (like GL_UNSIGNED_BYTE) and fewer components (like GL_LUMINANCE_ALPHA). 6) Pixel-transfer operations may decrease performance. Fragment Testing (before the framebuffer) ================ 1) Scissor test 2) Alpha test 3) Stencil test 4) Depth test 5) Blending 6) Dithering 7) Logical operation