Skip to content
kieselsteiniPublic

About

A new simple raylib binding for Lua

Resources

Stars

3 stars

Watchers

1 watching

Forks

Latest commit

 

History

28 Commits

Folders and files

Repository files navigation

rayLua - a simple new Lua binding for raylib

Why?

Why yet another Lua binding for raylib if there are so many others already out there?

Well most Lua bindings I have found on GitHub were using the LuaJIT "ffi" package, which is a viable option when using LuaJIT, but not for usage with vanilla Lua. And then, all the other bindings seemed to be abandoned for years and programmed against an ancient version of raylib. I also wanted to use the real C structures for objects and not parse Lua tables on the fly when using them.

Last but not least, fun. I just discovered raylib and I enjoy Lua programming, so I thought I would be a perfect side-project for me (and the upcoming raylib game jam).

Difference to programming raylib in C99

  • there are no UnloadXXX functions as the Lua garbage collector will collect and finalize unused resources
  • all LoadXXXFromMemory functions are renamed to LoadXXXFromString which allows the user to pass a Lua byte string
  • all GetXXXWidth / GetXXXHeight functions are renamed to GetXXXSize which will return 2 values for width and height
  • all "basic" objects like Vector2, Vector3 etc. have a function named like this to create them
    • e.g. Vector2(), Vector3(), Rectangle(), Camera2D(), Camera3D()
    • or with parameters like Vector2(1, 2), Vector2(other_vector)
  • all objects with resources bound to them like Image, Texture use the corresponding raylib function to create them
  • vector objects Vector2, Vector3 take advantage of metatables so you can write simpler code
    • you can add a vector with a vector or a number etc.
    • e.g. vector = Vector2(10, 10) * 100
  • all functions which take an object as its first parameter are exposed as methods on the object itself
    • e.g. ImageColorInvert(image) can be written as image:ColorInvert()
    • e.g. DrawTextureV(texture, Vector2(10, 10), WHITE) can be written as texture:DrawV(Vector(10, 10), WHITE)
  • functions returning a FilePathList return a simple Lua array with strings instead

State of the binding

  • module: rcore 🚧
    • Window-related functions βœ… (100%)
      • GetWindowHandle ❌ (useless in Lua)
      • GetScreenWidth / GetScreenHeight πŸŒ” GetScreenSize
      • GetRenderWidth / GetRenderHeight πŸŒ” GetRenderSize
      • GetMonitorWidth / GetMonitorHeight πŸŒ” GetMonitorSize
      • GetMonitorPhysicalWidth / GetMonitorPhysicalHeight πŸŒ” GetMonitorPhysicalSize
    • Custom frame control functions βœ… (100%)
    • Cursor-related functions βœ… (100%)
    • Drawing-related functions 🚧 (64%)
      • BeginTextureMode / EndTextureMode ❌
      • BeginShaderMode / EndShaderMode ❌
      • BeginVrStereoMode / EndVrStereoMode ❌
    • VR stereo config functions for VR simulator ❌
    • Shader management functions ❌
    • Screen-space-related functions ❌
    • Timing-related functions βœ… (100%)
    • Misc. functions ❌
    • Files management functions βœ… (100%)
    • Compression/Encoding functionality βœ… (100%)
    • Input-related functions: keyboard βœ… (100%)
    • Input-related functions: gamepads βœ… (100%)
    • Input-related functions: mouse βœ… (100%)
    • Input-related functions: touch βœ… (100%)
  • module: rgestures βœ… (100%)
  • module: rcamera βœ… (100%)
  • module: rshapes βœ… (100%)
  • module: rtextures 🚧
    • Image loading functions βœ… (100%)
      • LoadImageFromMemory πŸŒ” LoadImageFromString
    • Image generation functions βœ… (100%)
    • Image manipulation functions βœ… (100%)
    • Image drawing functions βœ… (100%)
    • Texture loading functions 🚧 (25%)
      • LoadTextureFromImage ❌
      • LoadTextureCubemap ❌
      • LoadRenderTexture ❌
    • Texture configuration functions βœ… (100%)
    • Texture drawing functions βœ… (100%)
    • Color/pixel related functions 🚧
      • Fade is implemeted on the Color object
  • module: rtext 🚧
    • Font loading/unloading functions 🚧 (42%)
      • LoadFontEx ❌
      • LoadFontFromImage ❌
      • LoadFontFromMemory πŸŒ” LoadFontFromString
      • LoadFontData ❌
      • GenImageFontAtlas ❌
    • Text drawing functions βœ… (83%)
      • DrawTextCodepoints ❌
    • Text font info functions 🚧
      • GetGlyphIndex ❌
      • GetGlyphInfo ❌
      • GetGlyphAtlasRec ❌
    • Text codepoints management functions (unicode characters) ❌ use utf8. module*
    • Text strings management functions (no UTF-8 strings, only byte chars) ❌ use string. module*
  • module: rmodels ❌
  • module: raudio βœ… (AudioStream)
    • Audio device management functions βœ… (100%)
    • Wave/Sound loading/unloading functions βœ…
      • LoadWaveFromMemory πŸŒ” LoadWaveFromString
    • Music management functions βœ…
      • LoadMusicStreamFromMemory πŸŒ” LoadMusicStreamFromString
    • AudioStream management functions ❌
  • module: raygui (3.2)
    • Global gui state control functions βœ…
    • Font set/get functions βœ…
    • Style set/get functions βœ…
    • Container/separator controls, useful for controls organization βœ…
    • Basic controls set βœ…
    • Advance controls set 🚧
      • GuiListView ❌
      • GuiListViewEx ❌
      • GuiTextInputBox ❌
    • Styles loading functions βœ…
    • Icons functionality 🚧
      • GuiGetIcons ❌
      • GuiGetIconData ❌
      • GuiSetIconData ❌
  • structs (objects)
    • Vector2 βœ…
    • Vector3 βœ…
    • Vector4 ❌
    • Quaternion ❌
    • Matrix ❌
    • Color βœ…
    • Rectangle βœ…
    • Image βœ…
    • Texture βœ…
    • RenderTexture ❌
    • NPatchInfo ❌
    • GlyphInfo ❌
    • Font βœ…
    • Camera3D βœ…
    • Camera2D βœ…
    • Mesh ❌
    • Shader ❌
    • MaterialMap ❌
    • Material ❌
    • Model ❌
    • Transform ❌
    • BoneInfo ❌
    • ModelAnimation ❌
    • Ray ❌
    • RayCollision ❌
    • BoundingBox ❌
    • Wave βœ…
    • Sound βœ…
    • Music βœ…
    • AudioStream ❌
    • VrDeviceInfo ❌
    • VrStereoConfig ❌
    • FilePathList πŸŒ”
      • will be converted "in-place" to Lua tables in functions which will return this

About

A new simple raylib binding for Lua

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages