# LookAt and Projections

More 3D Frames

• A Camera Interface from LearnOpenGL. This article has nice diagrams, but the variable names it chooses are sometimes goofy. It also uses glm syntax, and we will need to use Qt.
• I like the math and variable names in this article on LookAt better, but there are no figures.
• Read the overview of the Ortho and Perspective transforms on Learn OpenGL. For a recap of some of the math we will be discussing in class, read the detailed explanation by Song Ho Ahn.

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



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
./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;