Obj Library (Download)

Contents

  1. Contents
  2. Overview
  3. Design Goals
  4. Zip Files
  5. Source Code
  6. Sample Programs
  7. Extensions
  8. Miscellaneous
  9. Bottom of Page

Overview

Last updated December 13, 2016.

A C++ library to load and display OBJ models using fixed pipeline OpenGL. The library was intended to have both source and head files placed in a folder named ObjLibrary (included). This folder is included in the ZIP, so you can just unzip in your source folder. The ObjLibrary is theoretically cross-platform (being built on C++, OpenGL, and GLUT which all are), but I have not tested this for a while. The contents of the library are all in a namespace name .

I am assuming that you are using FreeGLUT, which is a replacement for the (now-defunct) GLUT. FreeGLUT is annoying to get working because the developers assume that you will download their mess of files and compile them into a useable form yourself (they include a Linux makefile). Here is a copy that you can just unzip and put with your source files. I think FreeGLUT comes with Mac and Linux computers, but I am not sure about this.

The ObjLibrary also includes the SpriteFont class for drawing text on the screen using a sprite font (a.k.a. a font sheet). Oddly, Wikipedia doesn't have a page on this.

Design Goals

  1. The ObjLibrary should load and display OBJ models on the screen with OpenGL, of course. It would be kind of useless without that.
  2. ObjLibrary shall be easy to use. Ideally, it shall be usable by people with no prior graphics programming experiance.
  3. ObjLibrary shall be fast.
  4. The code for ObjLibrary shall be (relatively) easy to understand. This means no clever programming tricks and definately nothing that would qualify as magic.
  5. The ObjLibrary shall be well-documented. This includes documentation for every function, even obvious ones and ones with file scope. Any confusing pieces of code should have an explanation with them. Documentation is not needed for most code.
  6. The ObjLibrary shall use anonymous namespaces to enforce file scope instead of static variables and functions.
  7. Variable and function names shall be self-documenting whenever possible. Long descriptive names are prefered to short ones (except as loop counters).
The ObjLibrary is not (and is not intended to be) suitable for advanced projects. Those should use things like shaders, storing data on the graphics card, and newer OpenGL standards. I do have an extension for shader rendering, but it is quite limited and rather slow.

I also have a development log.

ZIP Files

The complete library as a zip file.

Some sprite fonts that can be used with the SpriteFont class.

Source Code

These files have Windows-style line endings. A cross-platform file that to #include the OpenGL and FreeGLUT libraries: A general options file: Classes to represent (mathematical) vectors of 2 and 3 double elements: A class to display text in a graphical window: Assorted files needed to load OBJ models: A wrapper class to encapsulate OpenGL display lists:

Sample Programs

The version of the ObjLibrary used in these may not always be entirely up-to-date. TODO: Make a page for each program?

ObjLibrary Extensions

These are additional files that can be added to the ObjLibrary to give it additional functionality. These may use code that I didn't write. TODO: A page or subsection for each?

Miscellaneous

The Game Maker version 6 data file that generates the font sheets. To use this, change the loaded font and the constants. This was written for Game Maker version 6 (also loads in 7) which is sadly no longer available. There is a newer Game Maker, but it is not free and the designers have made a buch of design changes I don't like, so I am still using the old one. I do not know if the save file is compatible, but I doubt it.

The ObjLibrary grew out of my model-loading code for my (as-yet-unnamed) 3D Spaceship Game. It was adapted into a library on the request of Dr. Howard Hamilton at the University of Regina (who is my father). I also used it in Spiderworld Crystal Hunt.

Back to resources page
Back to home page