GLUT and OpenGL bindings for Lua
C Lua C++ R
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


   luaglut version 0.5


   luaglut is a set of libraries providing OpenGL and GLUT bindings for
   Lua 5. The bindings are in separate libraries, so you don't have to
   load the GLUT bindings if you only need OpenGL. The GLUT bindings
   also include some GLU functions. These will be eventually moved to
   a separate library. luaglut is currently used actively on Lua 5.0.2
   but it also works with Lua 5.1 release candidates. The currently
   supported operating systems are Linux, Mac OS X and Microsoft Windows
   2000/XP (Mingw required for compilation on Windows).

   The design of the libraries is a little bit different from the

      gllua ( only supports
      Lua 3.1 and is not developed any more.

      Doris ( suppots Lua 5.0 but rather
      than being a standalone library, it includes Lua 5.0 inside it. It
      also provides binding to the GLUI user interface toolkit.

      LuaGL ( is another binding for Lua
      5.0 which also has a limited coverage of OpenGL and GLUT and comes
      with its own interpreter.

   luaglut, on the other hand, is a set of standalone libraries which
   can be loaded by a stock Lua distribution and have a much more
   complete coverage of the OpenGL and GLUT APIs. I also try to stick
   semantically to the OpenGL and GLUT API as closely as possible.

   Also, rather than providing custom solutions for creation of memory
   buffers (needed for texture mapping and framebuffer operations)
   luaglut accepts lightuserdata when a pointer to a raw memory area
   is required. It is up to the programmer (i.e. You) to decide which
   mechanism for raw memory access you want to use. The current luaglut
   distribution includes a simple example of such a library (memarray)
   and one of the demo programs uses it to load and display a texture
   from a ppm file.

   NOTE: memarray was inspired from the LuaMem library written by
         Nodir Temirhodzhaev. While a remarkable piece of work, LuaMem
         requires some changes to Lua internals which seem to be unsafe
         (details on the lua-l list)

   Building Instructions

   luaglut supports both Lua 5.0.2 and Lua 5.1. When being built,
   luaglut will use include files from the respective Lua version. For
   this reason you cannot use the same library with both Lua versions -
   it will only run with the Lua version with which it was compiled. If
   you need both, you will need to compile two different libraries and
   use the respective one with each Lua version.

   On the supported platforms, luaglut is built with the 'make'
   command. Before giving instructions about building on a particular
   platform, let me mention that there are a number of variables that
   you can specify on the make command line in order to customize your
   USE_OPENGLUT, USE_OPENGLEAN). I will give some examples below which
   will clarify their use.

   First of all, it is assumed that Lua headers are installed in
   a standard place (like /usr/include). If not, you will need to
   specify their location explicitly. Suppose that the headers are in
   ../lua-5.1/include, then you should issue the following command:

      make DEFS=-I../lua-5.1/include

   You can also optimize your build by providing extra flags as in

      make CFLAGS="-O2 -march=pentium4"

   if your cpu is a pentium4 and you want to the C compiler to optimize
   at level O2, for example.

   luaglut no longer explicitly links to the lua core libraries. Please
   read for more information.

   1. Building on Linux

   Just unpack and run 'make'. This should generate,

   2. Building on Mac OS X

   If you have Mac OS X version 10.3.x or greater, you will need to
   issue the following command before compiling:


   If you have Mac OS X version 10.2.x or less, you will need to
   link explicitly to the Lua libraries. If your libraries are in
   /usr/local/lib, for example, the following line might work:

      make \
         GCC_OPT_SHARED=-bundle \
         LIBS="-L/usr/local/lib -llua -llualib"

   The make process should generate luagl.bundle, luaglut.bundle and
   memarray.bundle. Many thanks to Anders F. Björklund for providing
   patches for Mac OS X/9 support.

   For versions earlier than Mac OS X 10.3, you will need 'dlcompat':

   Lua 5.1 is well supported on Mac OS X. For Lua 5.0.2, you will need
   to compile Lua with support for dynamic loading. Here are some
   instructions that worked for me:

      * Get lua-5.0.2.tar.gz and unpack it
      * Apply the following patch:
      * Don't forget to uncomment the lines for dynamic loading in config
      * Issuing the following commands works for me:
         make dylib
         make dylibbin
         make install
         make dylibinstall

   3. Building on Mac OS 9 / X (Carbon) / CodeWarrior

   You can download Lua for Mac OS 9/X (Carbon) from: You will need to convert all the line
   endings to Macintosh format and set the type/creator codes so that
   the OS can read the files.

   4. Building on Windows

   You need Mingw for compilation ( You will have to
   explicitly define the lua dll files when linking. For example, if Lua
   5.0.2 is installed in /usr/local/ then you can issue the following

      make \
        DEFS=-I/usr/local/include \
        LIBS="/usr/local/bin/lua.dll /usr/local/bin/lualib.dll"

   Another example where Lua 5.1 is installed in /usr/lua-5.1 will be:

      make \
         DEFS=-I/usr/lua-5.1/include \

   This should generate luagl.dll, luaglut.dll and memarray.dll.

   Using alternative GLUT implementations

   Besides using GLUT proper, luaglut can build with alternative
   GLUT implementations (freeglut, openglut or openglean). Just add
   command. Besides linking with the proper library, luaglut will also
   activate the extra API functions that may come with the respective

   Running Instructions

   Example programs can be run on any platform by issuing the following
   commands: "lua glut_demo1.lua" and/or "lua glut_demo2.lua"

   Hopefully I'll write some documentation when I have time. Meanwhile,
   you can look at the sources and the two examples that are provided.

   List of files

   Main Sources:
      README         - this file
      LICENCE        - the licence
      Makefile       - the makefile
      luagl.c        - the C source for the OpenGL bindings
      luaglut.c      - the C source for the GLUT (and some GLU) bindings
      memarray.c     - the C source for the memarray library
      macros.h       - macros used in the compilation of above C sources
      macros.lua     - this lua file can be used to generates macros.h
      menus.h        - menus.lua in an embeded form (included in luaglut.c)
      menus.lua      - menu support code for GLUT

   Helpers for library loading: (not necessary with Lua 5.1)
      luagl.lua      - helper file for loading the dynamic library
      luaglut.lua    - helper file for loading the dynamic library
      memarray.lua   - helper file for loading the dynamic library

      glut_test1.lua - simple example
      glut_test2.lua - same as above, but with texture mapping
      lua.ppm        - texture loaded by glut_test2.lua

   CodeWarrior / Carbon support files:
      luagl.exp            - library export information
      luaglut.exp          - library export information
      memarray.exp         - library export information
      luaglut.prefix.h     - Carbon support
      Carbon.r             - Needed to launch in OS X
      luaglut.mcp.xml.gz   - project file for importing in the CodeWarrior IDE

   Varol Kaptan <>