All Projects → Playermet → luajit-glfw

Playermet / luajit-glfw

Licence: other
GLFW bindings for LuaJIT

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to luajit-glfw

Lwjgl3
LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL, Vulkan), audio (OpenAL), parallel computing (OpenCL, CUDA) and XR (OpenVR, LibOVR) applications.
Stars: ✭ 3,540 (+6841.18%)
Mutual labels:  vulkan, glfw
Bgfx
Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
Stars: ✭ 10,252 (+20001.96%)
Mutual labels:  vulkan, glfw
Magnum
Lightweight and modular C++11 graphics middleware for games and data visualization
Stars: ✭ 3,728 (+7209.8%)
Mutual labels:  vulkan, glfw
glfwJS
The N-API bindings for GLFW
Stars: ✭ 49 (-3.92%)
Mutual labels:  vulkan, glfw
Berserk
[WIP] High performance 3D graphics game engine
Stars: ✭ 31 (-39.22%)
Mutual labels:  vulkan, glfw
glfw-d
D translation of GLFW, a multi-platform library for OpenGL, OpenGL ES, Vulkan, window and input
Stars: ✭ 14 (-72.55%)
Mutual labels:  vulkan, glfw
Silk.net
The high-speed OpenAL, OpenGL, Vulkan, and GLFW bindings library your mother warned you about.
Stars: ✭ 534 (+947.06%)
Mutual labels:  vulkan, glfw
zig-vulkan-triangle
simple triangle displayed using vulkan, glfw, and zig
Stars: ✭ 55 (+7.84%)
Mutual labels:  vulkan, glfw
Nimgl
NimGL is a Nim library that offers bindings for popular libraries used in computer graphics
Stars: ✭ 218 (+327.45%)
Mutual labels:  vulkan, glfw
Flextgl
OpenGL and Vulkan header and loader generator.
Stars: ✭ 180 (+252.94%)
Mutual labels:  vulkan, glfw
scop vulkan
A 3D model viewer written C++20 and Vulkan
Stars: ✭ 133 (+160.78%)
Mutual labels:  vulkan, glfw
nuklear-glfw-vulkan
A nuklear adapter that does Vulkan rendering
Stars: ✭ 52 (+1.96%)
Mutual labels:  vulkan, glfw
Oreon Engine
OpenGL/Vulkan Java 3D Engine
Stars: ✭ 431 (+745.1%)
Mutual labels:  vulkan, glfw
Demos
Vulkan API crossplatform demos in Go
Stars: ✭ 103 (+101.96%)
Mutual labels:  vulkan, glfw
GLFW3.NET
Automatic generated bindings of GLFW3 for .NET
Stars: ✭ 28 (-45.1%)
Mutual labels:  vulkan, glfw
virtualGizmo3D
Virtual GIZMO - 3D object manipulator / orientator, via mouse, with pan and dolly/zoom features
Stars: ✭ 36 (-29.41%)
Mutual labels:  vulkan, glfw
glm
OpenGL Mathematics (GLM)
Stars: ✭ 6,667 (+12972.55%)
Mutual labels:  vulkan
blynk-library-lua
Blynk library for Lua. Works with Lua 5.1+, LuaJIT, NodeMCU.
Stars: ✭ 35 (-31.37%)
Mutual labels:  luajit
nautilus
another graphics engine
Stars: ✭ 16 (-68.63%)
Mutual labels:  vulkan
harfang3d
HARFANG 3D source code public repository
Stars: ✭ 173 (+239.22%)
Mutual labels:  vulkan

Features

  • Full support of 3.3.0 API (except native functions)
  • Supports both Luajit and Lua with luaffi
  • Additional OO style for monitors, windows, and cursors
 glfw.ShowWindow(window)
 -- or
 window:Show()
  • Constants can be used in two ways
 glfw.GetKey(window, GLFW.KEY_SPACE)
 -- or
 glfw.GetKey(window, 'KEY_SPACE')

Differences from the C API

Binding is so close to the original API as possible, but some things still differ.

  1. Names lost 'glfw' prefix.
  2. Arrays of chars replaced by lua string (except joystick buttons).
  3. Arrays of structs and strings replaced by lua tables.
  4. Values returned by reference replaced by returning table or multiple results.
  5. Video mode returned as table. This may change in future if necessary.
  6. Some OO methods have shortened names.

Start using

Before calling glfw functions you need to initialize binding with library name or path. Luajit uses dynamic library loading API directly, so behaviour may be different on each OS. Filename and location of glfw library may also vary. Several examples:

-- Windows
local glfw = require 'glfw' ('glfw3')
local glfw = require 'glfw' ('../some/path/glfw3.dll')
-- Linux
local glfw = require 'glfw' ('./libglfw3.so')
local glfw = require 'glfw' ('/usr/local/lib/libglfw3.so')
-- Mac OS X
local glfw = require 'glfw' ('/opt/local/lib/libglfw.3.1.dylib')

For statically linked glfw, just skip argument.

-- Any OS
local glfw = require 'glfw' ()

Constants stored in const table. It is recommended to save it in variable with GLFW name.

local GLFW = glfw.const

If you need vulkan-related functions, then specify 'bind_vulkan' option. Vulkan types MUST be declared (manually or with other binding) before this.

local glfw = require 'glfw' { 'glfw3',
  bind_vulkan = true
}

If you use or want to support Lua+luaffi, then compare pointers with NULL only in this way:

pointer == GLFW.NULL

Quick example

local glfw = require 'glfw' ('glfw3')
local GLFW = glfw.const

-- Initialize the library
if glfw.Init() == 0 then
  return
end

-- Create a windowed mode window and its OpenGL context
local window = glfw.CreateWindow(640, 480, "Hello World")
if window == GLFW.NULL then
  glfw.Terminate()
  return
end

-- Make the window's context current
glfw.MakeContextCurrent(window)

-- Loop until the user closes the window
while glfw.WindowShouldClose(window) == 0 do
  -- Render here

  -- Swap front and back buffers
  glfw.SwapBuffers(window)

  -- Poll for and process events
  glfw.PollEvents()
end

glfw.Terminate()

Quick example with OO style

local glfw = require 'glfw' ('glfw3')
local GLFW = glfw.const

-- Initialize the library
if glfw.Init() == 0 then
  return
end

-- Create a windowed mode window and its OpenGL context
local window = glfw.CreateWindow(640, 480, "Hello World")
if window == GLFW.NULL then
  glfw.Terminate()
  return
end

-- Make the window's context current
window:MakeContextCurrent()

-- Loop until the user closes the window
while window:ShouldClose() == 0 do
  -- Render here

  -- Swap front and back buffers
  window:SwapBuffers()

  -- Poll for and process events
  glfw.PollEvents()
end

glfw.Terminate()

Other examples

  local version = glfw.GetVersion()
  print(version.major, version.minor, version.rev)

  local monitors = glfw.GetMonitors()
  for i = 1, #monitors do ... end

  local x,y = glfw.GetMonitorPos(monitor)
  local x,y = monitor:GetPos()

  local w,h = glfw.GetMonitorPhysicalSize(monitor)
  local w,h = monitor:GetPhysicalSize()

  local modes = glfw.GetVideoModes(monitor)
  local modes = monitor:GetVideoModes()
  for i = 1, #modes do ... end

  local mode = glfw.GetVideoMode(monitor)
  local mode = monitor:GetVideoMode()
  for k,v in pairs(mode) do
    print(k,v)
  end

  local x,y = glfw.GetWindowPos(window)
  local x,y = window:GetPos()

  local fsize = glfw.GetWindowFrameSize(window)
  local fsize = window:GetFrameSize()
  print(fsize.left, fsize.top, fsize.right, fsize.bottom)

  local axes = glfw.GetJoystickAxes(joy)
  for i = 1, #axes do ... end

Acknowledgements

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].