GitHunt
YU

YueranCao2001/computer_graphics

Two OpenGL-based computer graphics projects demonstrating 2D modelling, 3D scene construction, geometric transformations, animation, texture mapping, and interactive controls. Includes a 2D greeting-card scene and a hierarchical 3D world with lighting and motion.

๐ŸŽจ Computer Graphics Projects

This repository contains two OpenGL-based Computer Graphics coursework projects developed for Computer Graphics.
Both assignments implement core rendering techniques, geometric modelling, transformations, animation, and interactive controls.


๐Ÿ“˜ Project Overview

๐Ÿ–ผ CW1 โ€“ 2D Greeting Card (OpenGL + GLUT)

A colourful interactive 2D greeting-card scene celebrating XJTLUโ€™s anniversary.
The program showcases polygon rendering, parametric curves, geometric transformation, and animation.

โœจ Key Features

  • Custom background using multicolored polygons, with gradient achieved by color interpolation
  • Text rendering supporting Chinese & English characters
  • Billboard drawing using GL_FRONT / GL_BACK / GL_FILL / GL_LINE
  • Circles & ellipses drawn via parametric equations
    • Circle: x = r cos(360t), y = r sin(360t)
    • Ellipse: x = a cos(360t), y = b sin(360t)
  • Clouds, trees, balloons constructed from ellipses + circles
  • Rainbow using glutSolidTorus() (showing half via translation)
  • Geometric transformations: scaling, translation using glPushMatrix() & glPopMatrix()

๐ŸŽฎ Keyboard Controls

  • q โ€“ Quit program
  • f โ€“ Toggle between fill mode and line mode
  • r โ€“ Reset animations
  • o โ€“ Reverse direction of clouds & balloons
  • t โ€“ Stop movement
  • b / s โ€“ Scale objects bigger / smaller
  • c โ€“ Restore original size

๐Ÿ–ฑ Mouse Interaction

  • Left click: decelerate movement (if positive direction)
  • Right click: accelerate movement

๐Ÿงฑ CW2 โ€“ 3D Modelling Project (OpenGL + GLUT)

A hierarchical 3D scene including buildings, ground, trees, UFO animation, boat movement, and textured surfaces.
Demonstrates modelling, lighting, projection, and interactive navigation.

โœจ Key Features

  • Hierarchical modelling: ground, buildings, components built in structured layers
  • Geometry creation using cubes, trapezoidal prisms, and glutSolidSphere
  • Transformations for positioning, rotation, scaling of models
  • Orthographic projection using glOrtho()
  • Lighting & materials: ambient, diffuse, specular, shininess
  • Texture mapping on roofs, grass, carpets
  • Animation: UFO rotation/movement, boat navigation

๐ŸŽฎ Keyboard Controls

  • q โ€“ Quit
  • b / l / c โ€“ Scale trees bigger / smaller / reset
  • w, a, s, d, h โ€“ Control boat movement
  • t / r โ€“ Stop / reset UFO animation

โคด๏ธ Special Keys

  • Arrow keys โ† โ†‘ โ†“ โ†’: rotate the entire model view
  • PgUp, PgDn: zoom in / out

๐Ÿ–ฑ Mouse Interaction

  • Left click: slow down if direction is positive, speed up if negative
  • Right click: speed up if direction is positive, slow down if negative

๐Ÿ“‚ Repository Structure

computer_graphics/
โ”‚
โ”œโ”€โ”€ CW1/ # 2D Greeting Card project
โ”œโ”€โ”€ CW2/ # 3D Modelling & Animation project
โ”œโ”€โ”€ LICENSE
โ””โ”€โ”€ .gitattributes

๐Ÿ›  Build & Run Instructions

Both CW1 and CW2 require:

  • OpenGL
  • GLUT / FreeGLUT
  • A C++ compiler supporting OpenGL linking

General compilation:

g++ main.cpp -lopengl32 -lglu32 -lfreeglut -o graphics_project
./graphics_project

(Modify filenames accordingly.)

๐ŸŽฏ Learning Outcomes

These projects demonstrate:

  • Low-level 2D/3D rendering using OpenGL

  • Parametric modelling & geometric construction

  • Hierarchical and scene-based modelling

  • Transformations, lighting, and texture mapping

  • Interactive graphics programming