LookAt and Projections

Wednesday | Friday
More 3D Frames


Examples updates

Last week we configured the examples repo to work with two remotes. Let's fetch this week's upstream changes.

$ cd ~/cs40/examples
$ git fetch upstream
$ git merge -X ours upstream/master

After this step, you will need to manually edit the top level CMakeLists.txt to add the new subdirectories.

$ tail ~/cs40/examples/CMakeLists.txt

#add this w05 line

Before compiling, you will need to add a symlink in your w05-projection source folder.

cd ~/cs40/examples/w05-projection
ln -s /usr/local/doc/textures data
cd ..

If everything went well, you should be able to go into your build directory and run make -j8 to compile the week 05 examples.

cd build
make -j8
cd w05-projection

The o key toggles between an orthographic and perspective projection matrix. The code also uses the lookAt method to construct a view matrix. Note the order of matrix operations in the vertex shader.

uniform mat4 model;   /* move object in world */
uniform mat4 view;    /* transform to eye coordinates */
uniform mat4 project; /* project to clip volume */
gl_Position = project * view * model * vPosition;