Common code

This page describes reusable code, not demos.


These files are needed for ALL my demos! (Well, at least some parts are used over and over.) They are also the base of my lab materials in my courses. What I wanted to do here is a package that is transparent, easy to read and modify. No big do-everything packages spread over hundreds of files. Just a small number of to-the-point solutions of the most common problems.


This package includes:

MicroGlut, a single file GLUT replacement with the essentials and no old OpenGL dependencies, available for Linux, OSX and Windows.

VectorUtils3, a fairly capable vector/matrix package.

loadobj, a model loader that loads a subset of the Wavefront OBJ format. (Parts written by Mikael Kalms.) This file will be replaced by LittleObjLoader.c!

LittleOBJLoader, a model loader that loads a substantial subset of the Wavefront OBJ format. (Parts written by Mikael Kalms.) Replaces loadobj.c!

GL_Utilities, shader loader and more.

LoadTGA, loader for TGA images (simple lab-friendly image format). LoadTexture, below, is more capable, but LoadTGA will remain as a separate file for keeping the core core brief and understandable.


“Common” came, for a while, in two versions, one “classic”, mostly suited for C, and one “cpp” which is more C++ friendly. Several of the modules in the C++ version are now in header only format. By 2024 I stop updating the old material so all are “cpp” even without the extension.


2024: From now on I only upload the C++ friendly version.


Download:


common.zip (updated 2024-08-14)

Tested some more. Almost no changes.


common-april-24.zip (updated 2024-04-22)

Recent fixes: A security flaw in LittleOBJLoader, corrected and extended glutMouseIsDown().


Older versions:


common-apr24.tar.xz (updated 2024-04-18)

common-apr24.zip (updated 2024-04-18)


common-cpp-may-23.tar.gz (updated 2023-05-09)

common-may-23.tar.gz (updated 2023-05-09)


Additional files:


The following two files are enhanced versions of loadobj and LoadTGA, both written 2019.


Little OBJ loader is a largely rewritten new version of loadobj, simplified, easier to read, but most importantly much more capable than the old one! It can now load multi-part models with .mat files! I have tested it on a considerable number of OBJ files and it performs a lot better than loadobj, loading most models correctly complete with the .mat files.


LoadTexture is a simpler, but as far as I can tell also useful package, combining four image loaders so you can load PPM, TGA, PNG and JPG with one single call, with minimal dependencies.http://example.com

This page is maintained by Ingemar Ragnemalm.