YGL Graphics Library


YGL is a project that I started when I took the undergraduate Compute Graphics course. My goal was to implement the entire OpenGL 1.1 pipeline. I picked up the project again in my graduate Compute Graphics course.


YGL implements most rendering related interfaces in OpenGL 1.1 specification:


The sequence below describes the YGL pipeline (optionally denoted with the underlying algorithms):

  1. Specify Vertices
  2. Apply Model-view matrix which transform vertices and normals to Camera Space
  3. Per-vertex lighting
  4. Apply Perspective matrix to transform vertices to Homogeneous Space (also as Clip Space later)
  5. Primitive assembling (group vertices to lines, triangles, quads or polygons)
  6. Clipping (line clipping: Liang-Barsky, polygon-clipping: Sutherland-Hodgman)
  7. Perspective division and viewport transform (now vertices are in Window Coordinates Space)
  8. Backface culling
  9. Rasterization and texturing (line: Bresenham, polygon: convert to triangle-fan and use Scanline algorithm)
  10. Fogging
  11. Per-fragment operation (Scissor test-> Alpha test -> Stencil test -> Depth test -> Alpha blending -> Logical operations)
  12. Write color to frame buffer and draw onto the screen


YGL is compatible with GLUT, but remember to include ygl.h first, e.g.:

#include "ygl.h"
#include "yglu.h"
using namespace ygl;
#include <gl/glut.h>


All the tests run on Intel Core i5-2300 @ 2.80GHz; window size: 512 by 512.

FPS: 104 (smooth shading, 1 light, texture, perspective correction, bilinear filter, fogging)
FPS: 100 (faces: 5K)
FPS: 30 (faces: 18K, 2 lights)
FPS: 26 (faces: 23K, 2 lights)

The example below is from OpenGL website, and I use it to validate YGL's pipeline. It's a program showing an animation, with lighting and shadow effect. It's able to run with YGL by simply changing the display lists to C marcos in the code.

Source code



The bunny model is from Stanford 3D Scanning Repository; the killeroo model is from Princeton Shape Benchmark Repository; the head model is from Infinite Realities; the MOTH program is from OpenGL's GLUT examples archives.


  1. OpenGL 1.1~1.5 specification
  2. Blinn, James F., and Martin E. Newell. "Clipping using homogeneous coordinates." ACM SIGGRAPH Computer Graphics. Vol. 12. No. 3. ACM, 1978.
  3. Liang-Barsky Algorithm, Wikipedia
  4. Bresenham's line algorithm, Wikipedia
  5. Perspective Texture Mapping, Wikipedia
  6. Rasterization Rules, Microsoft

Last updated 12/9/2014