General

Please note that you must upload the exercises before the submission deadline. The submission system will be announced in the course. Exercises that are not submitted on time will be graded with 0 points. Submissions that do not compile also receive 0 points. Sample inputs and outputs are often available, which you can use to test your programs. Submissions that do not process these samples correctly will receive only few points. Please do not add additional output to your program unless explicitly requested. Submit your solution as a single zip file named using the following scheme: a1_Firstname_Lastname.zip.

Compress all files you have modified into one archive. If the exercises include theoretical parts, please also include a text file, scan, or photo with your answers.

For example: A complete first assignment consists of a zip file containing only the main.cpp file.

Setting Up the Development Environment

To set up your environment for the exercises, please follow these instructions:

For Windows users:

Download the latest Visual Studio IDE (not Visual Studio Code).

Select "Desktop development with C++" during installation.

For Mac users:

Install Xcode and additionally install GLEW and GLFW.

For Linux users:

Install the required tools using:

sudo apt install build-essential libglew-dev libglfw3-dev

Download the Framework and Exercise Code

The code framework to start the exercises is provided via a GitHub repository at github. On Linux or macOS systems, you can open a terminal window and type:

git clone https://github.com/JensDerKrueger/AIS
You can read the documentation of the framework here.

Sheet 01: Hello OpenGL

Exercise: Hello OpenGL (20 points)

This and the following exercises use OpenGL to render the scene. All OpenGL tasks must be implemented using OpenGL 3.2 Core Profile or higher. OpenGL 3 is the foundation of modern OpenGL — the Fixed Function Pipeline and Immediate Mode commands are deprecated.

For more information on OpenGL, see the literature list from the first lecture. The OpenGL Red Book and the Real-Time Rendering compendium are especially recommended. A quick overview of all OpenGL and GLSL commands from version 3.2 onwards is provided by the Quick Reference Cards (PDF). HTML documentation is available in the OpenGL reference pages.

You can check whether your system supports OpenGL 3.2 or higher using the tool OpenGL Extensions Viewer.

The sample program Hello OpenGL initially renders a simple white triangle (see the left image in Figure triangles). Extend the program so that it matches exactly the right image: Two colored triangles form a rectangle on a dark cyan background.

To complete this task:

  • Familiarize yourself with shaders, VBOs, and VAOs.
  • Adjust the data in the triangle array so that one of the triangles is displayed correctly.
  • Add additional geometry for the second triangle.
  • To color the two triangles differently, create a second shader program with a different fragment shader.

The colors are given as normalized RGB values:

orange:     (0.9, 0.5, 0.2)
green:      (0.2, 0.9, 0.2)
background: (0.1, 0.15, 0.15)

After every OpenGL command, use the call glGetError to detect invalid commands or arguments immediately. According to the specification, OpenGL behaves undefined in case of an invalid state, which can lead to hard-to-trace platform differences.

White Triangle
Loading

Top – Initial example with one white triangle. Bottom – Target result with two colored triangles on a dark background.

Text description and demo controls

The reference image shows a rectangle centered in the viewport, from -0.5 to 0.5 in both horizontal and vertical coordinates. Two triangles share the diagonal from the top left to the bottom right; one is orange and the other green. The background is dark cyan.

The normalized RGB values are orange (0.9, 0.5, 0.2), green (0.2, 0.9, 0.2), and background (0.1, 0.15, 0.15). The rectangle has no gap or overlap along the shared edge.

This reference is a static rendering; no animation controls are required.