[go: up one dir, main page]

Skip to content

stetre/moonglfw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MoonGLFW: Lua bindings for GLFW

MoonGLFW is a Lua binding library for GLFW.

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

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 and MacOS)

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.