Computer graphics is how a computer turns numbers into pictures. Most of the classical algorithms in the subject, line drawing, clipping, transformations, hidden surfaces and shading, are still the pipeline that every GPU runs, only now done in hardware, billions of times a second. This article revisits the five units of the JNTUK course.
Unit 1: Introduction and 2D output primitives
Display basics
A modern screen is a raster display: a grid of pixels, each holding a colour stored in the frame buffer. Resolution is the pixel count (1920 × 1080); colour depth is bits per pixel (24 bits gives about 16.7 million colours); refresh rate is how often the screen is redrawn. Older vector (random-scan) displays drew lines directly. Hardware in the syllabus: CRT, LCD, LED, plasma, and input devices such as mouse, tablet and scanner.
Drawing lines and circles
Because pixels are discrete, a line must be approximated.
| Algorithm | Idea |
|---|---|
| DDA | Step along the longer axis one pixel at a time, adding the slope; uses floating-point and rounding |
| Bresenham’s line | Uses only integer arithmetic and an error term to decide between two candidate pixels; faster and more accurate |
| Midpoint circle | Draw one octant using a decision parameter, then use eight-way symmetry |
| Midpoint ellipse | Same idea with four-way symmetry and two regions |
Filling and anti-aliasing
- Scan-line fill finds where each horizontal line crosses the polygon edges and fills between pairs.
- Boundary fill and flood fill start from a seed point and spread (4-connected or 8-connected).
- Aliasing is the staircase effect on diagonal edges. Anti-aliasing reduces it by blending edge pixels or by sampling more than once per pixel (supersampling, MSAA).
Today: Bresenham-style integer logic is baked into GPU rasterizers. Anti-aliasing is a setting in every game, and the same sampling idea is used in font rendering.
Unit 2: 2D transformations, viewing and clipping
Transformations
A point (x, y) is moved by translation, scaling, rotation, reflection and shear. Using homogeneous coordinates (x, y, 1), every one of these becomes a single 3 × 3 matrix multiplication, so a sequence of transformations is combined by multiplying matrices.
| Transformation | Effect |
|---|---|
| Translation (tx, ty) | x′ = x + tx, y′ = y + ty |
| Scaling (sx, sy) | x′ = sx · x, y′ = sy · y |
| Rotation by θ | x′ = x cos θ − y sin θ, y′ = x sin θ + y cos θ |
| Reflection | Mirror across an axis or line |
| Shear | Slant: x′ = x + sh · y |
Order matters: rotating then translating is not the same as translating then rotating. To rotate about an arbitrary point, translate it to the origin, rotate, and translate back.
Windowing and clipping
The window is the part of the world you want to see; the viewport is where it appears on screen. The window-to-viewport transformation scales and shifts between them. Clipping discards what lies outside.
| Algorithm | Clips | Idea |
|---|---|---|
| Cohen-Sutherland | Lines | A 4-bit region code per endpoint decides quick accept, quick reject, or calculating an intersection |
| Liang-Barsky | Lines | Parametric clipping, fewer intersection calculations |
| Sutherland-Hodgman | Polygons | Clip against one window edge at a time |
| Weiler-Atherton | Polygons | Handles concave polygons and holes |
Today: the matrix idea scales directly to 3D: your phone’s UI animations, CSS
transform, SVG and game engines multiply transformation matrices. Clipping is performed by the GPU before drawing.
Unit 3: 3D concepts and projection
3D transformations
3D points use 4 × 4 matrices with (x, y, z, 1). Translation, scaling and rotation about the x, y and z axes work as in 2D. A 3D object is represented as a polygon mesh (vertices, edges and faces, mostly triangles), by wireframe, or by solid modelling (constructive solid geometry, octrees).
Projection
Projection maps 3D onto the 2D screen.
| Type | Behaviour | Use |
|---|---|---|
| Parallel (orthographic) | Projection lines are parallel; sizes stay true | Engineering drawings, CAD |
| Oblique | Parallel, but at an angle (cavalier, cabinet) | Quick illustrations |
| Perspective | Lines meet at a vanishing point; far objects look smaller | Realistic images, games |
The viewing pipeline takes an object through a chain of coordinate systems:
- Model space (the object’s own coordinates)
- World space (the scene)
- View (camera) space
- Clip space after the projection matrix
- Screen space (pixels)
Today: this model, view and projection matrix chain is the “MVP matrix” in every 3D engine and shader. WebGL, Vulkan, DirectX and Metal all implement it.
Unit 4: Curves, surfaces and fractals
Smooth shapes are described by a few control points instead of thousands of line segments.
| Curve | Property |
|---|---|
| Bézier curve | Starts and ends at the first and last control points; shape pulled toward the others; any change affects the whole curve. Built with the Bernstein polynomials or by repeated interpolation (de Casteljau) |
| B-spline | Local control: moving one point changes only part of the curve |
| NURBS | Rational B-splines; can represent exact circles and are standard in CAD |
Continuity describes how two curve pieces join: C⁰ (meet), C¹ (same direction), C² (same curvature). Surfaces such as Bézier patches extend the idea to two parameters. Fractals build self-similar shapes by repeating a rule: the Koch curve, the Sierpinski triangle and the Mandelbrot set. They model natural forms such as coastlines and trees.
Today: fonts (TrueType, PostScript) and SVG paths are made of Bézier curves, and CSS animation easing is a cubic Bézier. Vector tools like Illustrator and Figma use the same control-point idea.
Unit 5: Visible surfaces, illumination, shading and animation
Hidden-surface removal
When objects overlap, only the nearest should appear.
| Method | Idea |
|---|---|
| Back-face culling | Skip faces that point away from the viewer |
| Z-buffer (depth buffer) | Store a depth for every pixel; draw a fragment only if it is closer than what is stored |
| Painter’s algorithm | Sort polygons far to near and draw in that order |
| Scan-line and area subdivision | Resolve visibility line by line or region by region |
| Ray casting | Shoot a ray per pixel and take the first hit |
Illumination and shading
The Phong illumination model adds three parts: ambient (constant background light), diffuse (depends on the angle between the surface normal and the light, Lambert’s law) and specular (the shiny highlight, depends on the viewer’s angle).
| Shading | How it is computed | Result |
|---|---|---|
| Flat | One colour per polygon | Faceted look, fastest |
| Gouraud | Compute colour at vertices, interpolate across the face | Smooth, may miss highlights |
| Phong shading | Interpolate normals, compute lighting per pixel | Best highlights, most work |
Ray tracing follows light rays backwards from the eye, with reflection, refraction and shadows, for realistic images. Texture mapping wraps an image onto a surface; bump mapping fakes fine detail.
Colour models and animation
RGB (additive, for screens), CMY/CMYK (subtractive, for print) and HSV (hue, saturation, value; intuitive for picking colours). Animation is a sequence of frames shown at 24 to 60 or more per second. Methods: keyframing with interpolation between frames, morphing, path animation and motion capture. Principles such as squash and stretch and timing make motion look natural.
Today: the Z-buffer, Phong-style lighting and texture mapping are still the core of real-time graphics. Modern GPUs add programmable shaders and hardware ray tracing. Render farms, game engines and video effects all rely on these ideas, and the same GPUs run machine-learning workloads.
One-minute recap
| Unit | Key idea | You meet it in |
|---|---|---|
| 1. Output primitives | Raster display, Bresenham, fill, anti-aliasing | GPU rasterizers, font rendering |
| 2. 2D transformations and clipping | Homogeneous matrices; Cohen-Sutherland | CSS transforms, UI animation |
| 3. 3D and projection | 4 × 4 matrices, perspective, viewing pipeline | MVP matrix in every 3D engine |
| 4. Curves and surfaces | Bézier, B-spline, NURBS, fractals | Fonts, SVG, CAD, easing curves |
| 5. Visibility, shading, animation | Z-buffer, Phong, ray tracing, keyframes | Games, film effects, GPU shaders |
Next in Engineering Revisited: Environmental Studies.
Written by Claude, Anthropic’s AI assistant, as part of Engineering Revisited, a quick refresher of the B.Tech subjects one at a time.