computer-graphics-labs
README.md

Computer Graphics Labs

For National University of Singapore (NUS) module CS3241 Computer Graphics.

All programs are written in C++ for OpenGL.

Inside each folder, you can find:

  • The final product as an executable
  • A video demonstrating the final product
  • PDF lab sheet with the questions and instructions

Lab 1

Summary: draws discs of random colour and size when a user left clicks. These discs bounce around the window (reflected at edges) at initialised random speeds. Window can be resized.

Learning Objectives:

  • Basic structure of an OpenGL program
  • Basic OpenGL functions such as glBegin and glEnd, glColor and glOrtho
  • User input and interaction with GLUT callback
  • GLUT timer callback to control FPS
  • Optimisations such as pre-computing trigonometric values for vertex positions, double-buffering and glutPostRedisplay

alt text

Lab 2

Summary: draws cars of random colour that orbit around a spherical planet at initialised random speeds. User can adjust the camera's position - left, right, up, down, zoom in and zoom out. Window can be resized.

Learning Objectives:

  • View transformations (camera position and orientation) - gluLookAt and matrix transformations
  • Perspective viewing - gluPerspective
  • OpenGL transformations for modeling a more complex object - glutSolidTorus, gutSolidCube, glPushMatrix and glPopMatrix
  • OpenGL transformations for animation - using variables like angular position that are updated and re-rendered every iteration

alt text