Lab Image
Today's goal: Review Object-Oriented programming and understand the C++ abstraction in our OpenGL programs into a 'cleaner' rendering system. Second task is to draw two triangles.


Last lab we rendered a colored triangle and a square to the screen. As a recap:

  • We created a colored traingle
  • We created a perspective camera
  • We learned about uniforms

Today we are going to really think about what is going on in our program, and abstract our render. This will help you understand object-oriented programming in C++ as well as think about what code is executing on the CPU and the GPU.

The good news: I have already done the abstraction.

  • Your task will be to read and comment why it works (make these edits in the github).
  • Draw two triangles (only a few lines of code!)

Your Task(s)

  1. Half Lecture with Mike: Slides
  2. Find your partner in the spreadsheet here. It is your responsibility for the two of you to complete the lab by the beginning of the next lab
    • Note: If your partner is missing, you will be reassigned, and your partner will have to complete the lab individually.
    • Note: If you know you will miss class, arrange to have your lab checked off before the next lab is out!
  3. Download the files given in the next section titled "Files Given/Starter Code".
  4. Complete the "Code Review" Section
  5. Complete the "C++ Refresh" section
  6. (Optional) Complete any optional "Going Further" suggested tasks.

Files Provided/Starter Code

  • Clicking the following link gives you immediate access to your personal private github repository.
    • You may use your personal or Northeastern github account. I do not care, but please be consistent with what you choose.
    • I do look at your repositories, make sure you commit and push your final changes to repositories!
    • Please do not click until class starts. Occasionally I make changes until a few minutes before class (usually spelling corrections and other small typos).
    • Click now to get the lab starter code: Github Repository

Code Review

During your co-ops, internships, and jobs you will often do a code review. Today you will review my code for understanding the design, and to help connect the concepts that we have learned so far. The slides should help, but being able to dive into the code is a valuable skill to have. Once again start with the headers to see how the code works.

C++ Refresh

While this is not a C++ course, each lab I am going to provide an additional C++ code snippet so you can get up to speed (or perhaps just learn something cool and relevant to the course).
  • Code Sample 1
  • Type out(i.e. DO NOT just copy and paste) the file so you learn the commands. Then save it with an appropriate name (e.g. example.cpp)
  • Compile and run with the following on the terminal:
    • Linux Option 1: clang++ -std=c++14 example.cpp -o example
    • Linux Option 2: g++ -std=c++14 example.cpp -o example
    • Mac Option 1:   clang++ -std=c++14 example.cpp -o example
    • Mac Option 2:   g++ -std=c++14 example.cpp -o example
    • Mac Option 3:   Create a console-based XCode project
    • Windows Option 1: Create a console-based Visual Studio C++ project
  • Finally, add this C++ code snippet to your repository to practice working with git.

Going Further

What is that, you finished Early? Did you enjoy this lab? Here are some (optional) ways to further this assignment.
  • Move each of the triangles
  • Implement a 'rotate' or 'scale' transformation


  • You and your partner will receive the same grade from a scale of 0-2.
    • 0 for no work completed.
    • 1 for some work completed, but something is not working properly
    • 2 for a completed assignment (with possible 'going further' options completed)
  • You must complete this lab by next class. You will run your lab in front of me at the start of the next lab when class starts.

More Resources

Some additional resources to help you through this lab assignment

Found a bug?

If you found a mistake (big or small, including spelling mistakes) in this lab, kindly send me an e-mail. It is not seen as nitpicky, but appreciated! (Or rather, future generations of students will appreciate it!)
  • Fun fact: The famous computer scientist Donald Knuth would pay folks one $2.56 for errors in his published works. [source]
  • Unfortunately, there is no monetary reward in this course :)