Lua bindings for GLFW
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
doc Minor fixes Jan 11, 2018
examples Added fullscreen example Feb 7, 2018
moonglfw Added moonglfw directory May 15, 2016
src Minor fixes Jan 11, 2018
thirdparty Initial commit Feb 20, 2016
.gitignore Added now(), since() and sleep() Aug 19, 2017
LICENSE Initial commit Feb 20, 2016
Makefile Changes in Makefile Jun 14, 2016 Minor editorial changes in README Jan 11, 2018

MoonGLFW: Lua bindings for GLFW

MoonGLFW is a Lua binding library for GLFW.

It runs on GNU/Linux and on Windows (MSYS2/MinGW) and requires Lua (>=5.3) and GLFW (>=3.1).

MoonGLFW is part of the MoonLibs collection of Lua libraries for graphics and audio programming.

Author: Stefano Trettel

Lua logo


MIT/X11 license (same as Lua). See LICENSE.


See the Reference Manual.

Getting and installing

Setup the build environment as described here, then:

$ git clone
$ cd moonglfw
moonglfw$ make
moonglfw$ make install # or 'sudo make install' (Ubuntu)

NOTE: Vulkan support requires GLFW version >= 3.2, and the Vulkan loader ( to be in the linker's search path at runtime (see MoonVulkan's installation instructions for more details).


-- Script: hello.lua

glfw = require("moonglfw")

-- Create a window:
window = glfw.create_window(640, 480, "Hello world!")

function my_callback(w, x, y) 
   assert(w == window)
   print("cursor position:", x, y) 

-- Register a callback to track the cursor's position:
glfw.set_cursor_pos_callback(window, my_callback)

-- Repeatedly poll for events:
while not glfw.window_should_close(window) do

The script can be executed at the shell prompt with the standard Lua interpreter:

$ lua hello.lua

Other examples can be found in the examples/ directory contained in the release package, and in the MoonLibs repository.