In 2009 I took a Computer Animation course at @RIT I created an object-oriented C++ wrapper for GLUT. The idea was to create a set of classes that could be reused for each of the separate project submissions. The main class wraps around the GLUT C-style functions and provides a class that can be inherited from, to provide application specific functionality.

The idea was to make the boiler plate code disappear and make it easier for novice programmers to get an animated graphics window in as few lines as possible. Only four lines of code are needed to get the window running at 60 frames per second. You can subclass the framework and implement your own OpenGL animation or game project.

Edit (8/22/10): You don’t need to use pointers, I’ve updated the code example with working code.

// main.cpp
#include "GlutFramework.h"
using namespace glutFramework;
int main(int argc, char *argv[]) {
	GlutFramework framework;
	framework.startFramework(argc, argv);
        return 0;
}

The code uses a cross-platform (Windows/Mac tested) timer to create a constant frame-rate, which is necessary for animation projects. It’s under the MIT License, so feel free to use it as you see fit.

http://github.com/PaulSolt/GLUT-Object-Oriented-Framework

An Xcode 3.1 and Visual Studio 2010 project is hosted on github to support Mac and Windows. There is no setup on the Mac, but Windows users will need to configure GLUT. I plan on posted tutorials on how to get setup on both platforms. For now, look at the resources section below.

Animated teapot

Resources:

6 Responses to GLUT Object Oriented Framework on Github

  1. Sebastian says:

    hey Awsome, script learning glut and openGl this is gonne be great reference for a Object oriented approach, thanks!

  2. Sebastian says:

    Amazing work :) I was about to do just about the same thing and I stumbled upon your work when I googled for the issues with setting up GLUT’s callback functions that I had put inside my graphics class. So instead of building my own OOP design around GLUT and OpenGL I can use yours right away =)

    Cheers!

  3. Paul Solt says:

    @Sebastian I’m glad it helped you get started!

  4. Evan says:

    Thank you! After struggling for hours on this problem, I finally stumbled upon your code. Quite helpful to get mine working. I had significant trouble with specifying the callback functions for glut, without actually writing them in the class.

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">