Skip to content

stetre/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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy