teaching machines

CS 491 Lecture 21 – OpenGL

December 4, 2012 by . Filed under cs491 mobile, fall 2012, lectures.

Before class


Before we meet:


Before we meet:

In class

With your partner, build off the base renderer we constructed in class to load in a torus, light it, and shade it. Given the complexity and newness of OpenGL to most of you, I’ve sprinkled TODOs in places where changes need to be made. I suggest you follow these steps:

  1. Create and start an AVD with GPU emulation on.
  2. Import the base project, which is very similar to what we wrote in class. It’s zipped up as labgl.zip in the class directory on the W drive.
  3. The geometry file is in res/raw/torus2.w3d. Look at the file. The vertices start with v. The faces with f. New is a section for normals right after the vertices, each starting with vn. There is a normal defined for each vertex. Read these into a FloatBuffer. The project won’t run until you do this. After reading these in, test.
  4. Add a projection and look matrix as discussed. Transform the vertices in the vertex shader. Test.
  5. Add shading using the vertices’ normals. Uploading them will be quite similar to uploading the position attribute. Test.
  6. Support rotation. Test.