Skip to content

Derailedzack/moongl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MoonGL: Lua bindings for OpenGL

MoonGL is a Lua binding library for OpenGL.

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

Authored by: 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/moongl
$ cd moongl
moongl$ make
moongl$ make install # or 'sudo make install' (Ubuntu and MacOS)

Example

Below is an "Hello, World!" example, using MoonGLFW as windowing library.

Other examples can be found in the examples/ directory contained in the release package.

-- Script: hello.lua

gl = require("moongl")
glfw = require("moonglfw")

glfw.window_hint('context version major', 3)
glfw.window_hint('context version minor', 3)
glfw.window_hint('opengl profile', 'core')

window = glfw.create_window(600, 400, "Hello, World!")
glfw.make_context_current(window)
gl.init() -- this is actually glewInit()

function reshape(_, w, h) 
   print("window reshaped to "..w.."x"..h)
   gl.viewport(0, 0, w, h)
end

glfw.set_window_size_callback(window, reshape)

while not glfw.window_should_close(window) do
   glfw.poll_events()
   -- ... rendering code goes here ...
   gl.clear_color(1.0, 0.5, 0.2, 1.0) -- GLFW orange
   gl.clear("color", "depth")
   glfw.swap_buffers(window)
end

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

$ lua hello.lua

See also

About

Lua bindings for OpenGL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 94.3%
  • Lua 5.2%
  • Makefile 0.5%