MicroGLUT

MicroGlut is not GLUT!


MicroGlut is a stripped-down portable API for window and event handling in OpenGL applications. As the name implies, the API is based on the de facto standard GLUT (OpenGL Utility Library) and its more current free clone FreeGLUT. (GLUT is abandoned but FreeGLUT is updated and perfectly usable.) The code is, however, not based on neither and it has no intention of being a complete clone.


MicroGlut is based on the following ideas:


1) It should be small, few files, suitable for inclusion in your projects as source, ready for editing any time you like.


2) Don't change what's good. GLUT is a great API, so let's follow that as closely as possible. The callback system is highly portable between languages, easy to learn and imposes code structure that is very good, not least for lab use.


3) Ditch all that is bad, outdated, of minor importance or not relevant for the scope of the code.


It is notable that GLUT's geometry calls, like glutSolidSphere and the Utah Teapot, are not included, neither is the text rendering in GLUT. They were outdated, and are beside the point, MicroGlut is about OS interfacing, which means windows and events, not geometry nor text. You can find many shapes (more than in GLUT) in the GLUGG package, my OpenGL Utilities for Geometry Generation. Text can be rendered by SimpleFont or SimpleGUI.


4) It should focus on modern OpenGL. It is usable from OpenGL 2, but the focus is on OpenGL 3.2 and up.


5) It is implemented as separate implementations for each platform. This makes it harder to keep in synch, but it makes each implementation very tight and thereby more accessible.


6) Add new features that it needs. So far, a few new calls are introduced. New features not avaiable in GLUT:


    * glutKeyIsDown. MicroGlut keeps a bitmap for all keys telling whether they are up or down. This is very convenient when writing games.

    * glutRepeatingTimer. Instead of calling a callback, this just fires a new update.

    * glutInitContextVersion. This is inherited from FreeGLUT.

    * glutCheckLoop, also from FreeGlut (I think) allows one-shot calls into the main loop. This fixes a common complaint about GLUT, that glutMain never returns. (This doesn't currently work so consider it planned.)

    * glutToggleFullScreen. Now that is convenient!


This means that MicroGlut CAN:


    * create a window with OpenGL context.

    * handle window updates and resizing

    * handle timers

    * handle keyboard and mouse input.

    * handle pop-up menus (Mac only)

    * run full-screen (Mac, so-so on Linux)


but it can NOT


    * draw the Utah Teapot, spheres, toruses etc without you loading an external model

    * draw ugly GLUT-style text

    * handle exotic external devices

    * handle multiple windows (yet)


These lists will change a bit over time but my ambition is to keep it tight, much tighter than the alternatives.


As part of that ambition, I question whether the pop-up menus are important at all. I think I prefer visible controls, which can be done without OS dependencies (like my new SimpleGUI).


Mac version

The Mac version was the first one I made. It is based on NSOpenGL, written in Objective C. It is the most complete version, although the Linux version is catching up.


Linux version

The Linux version lacks menu support but is otherwise pretty usable. Most of my courses have Linux as course OS so this is important.


Windows version

The Windows version was available since august 2015. It was the ugly duckling for a long time, but in 2021, I managed to switch my Windows support to MinGW, which made it a lot better, and in the fall 2021, I had a course which had to have Windows as course OS, so it got a lot os testing and worked very well. So it has been catching up.


Downloads

The latest MicroGlut is part of my "common" archive for my computer graphics lab:


common.tar.gz


License and such legal stuff

Considering all the problems with GLUT not having a licence that allowed people to distribute changes (which is why it died when the author abandoned it), what is the license for MicroGlut? Well, at this early stage I havn't bothered much about it. It is a small package, does it need a license? If it gets popular it will get one, and I promise that it won't be restrictive. You will be allowed to redistribute changes (as long as the source is clearly stated), and you will be able to use it in commercial projects. I consider Public Domain or something like LGPL. Probably Public Domain.

This page is maintained by Ingemar Ragnemalm.