1. # Introduction

• ## Why OpenGL?

• ### Stanford-centric history:

• Invented "Geometry Engine" in 1981 at Stanford in CSL
• Stanford Professor Jim Clark started SGI with 7 Stanford colleagues (he also founded Netscape, Healtheon, myCFO, and others)
• "Graphics Library" (IRIS GL) was created as a software interface to SGI hardware
• OpenGL specification was written by Mark Segal and Kurt Akeley (Stanford student) in 1992, and it was inspired by IRIS GL
• Today, OpenGL is governed by the OpenGL Architecture Review Board (ARB)

• ## Overview of libraries

(From diagram in OpenGL course notes from Siggraph 97)

3. # OpenGL overview

• ## Function names prefixed with "gl"

• ### Function names may have suffixes indicating the data types

•  Number of Components Data Type Vector 2 - (x, y) b - byte omit "v" for scalar form 3 - (x, y, z) ub - unsigned byte (e.g. glVertex2f(x, y); ) 4 - (x, y, z, w) s - unsigned short us - unsigned short i - int ui - unsigned int f - float d - double

(Table from Siggraph 97 OpenGL Course Notes.)

5. # Rendering in OpenGL 3D

## Transformation model

### => viewport transformation (size and position of image)

=> screen coordinates.

#### glMatrixMode - chooses between modelview and projection matrix stacks.

Note: matrix m[4][4] - C array.  Then m[i][j] - ith column and jth row of OGL transformation matrix.  C stores arrays in row-major order, while OpenGL expect column-major matrices.

## Z buffer (hidden surface removal)

glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);

## glEnable (GL_DEPTH_TEST), glDepthFunc

#### Specify geometry with normals - glNormal3f.

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);

6. # Performance considerations

1. ## Triangle strips - good

glBegin(GL_TRIANGLE_STRIP);

## Vertex arrays - often good

### glDrawElements, glDrawRangeElements

glBegin(GL_TRIANGLES);
glArrayElement(2);
glArrayElement(3);
glArrayElement(4);
glEnd();

## Display lists - sometimes good

glNewList(1, GL_COMPILE);
/* Draw the model */
glEndList();

/* Later on... */
glCallList(1);