Lua bindings for GLFW
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
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
README.md Minor editorial changes in README Jan 11, 2018

README.md

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

License

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

Documentation

See the Reference Manual.

Getting and installing

Setup the build environment as described here, then:

$ git clone https://github.com/stetre/moonglfw
$ cd moonglfw
moonglfw$ make
moonglfw$ make install # or 'sudo make install' (Ubuntu)

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

Example

-- 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) 
end

-- 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
   glfw.poll_events()
end

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.