A luajit set of ffi wrappers for the excellent sokol framework,
Go to file
2024-11-06 13:17:28 +10:30
bin Added new build tools. This will allow packaging sokol-luajit apps. 2024-11-03 22:17:04 +10:30
builds/cube_sapp Fixed tdump util. 2024-11-04 00:47:38 +10:30
examples Fixed tdump util. 2024-11-04 00:47:38 +10:30
ffi Minor fixes. 2024-10-30 01:00:03 +10:30
jit Added new build tools. This will allow packaging sokol-luajit apps. 2024-11-03 22:17:04 +10:30
lua Adding gui components and vfs 2024-11-06 13:17:28 +10:30
media Updated screenshot 2024-10-31 15:13:04 +10:30
tools Adding gui components and vfs 2024-11-06 13:17:28 +10:30
LICENSE Initial commit 2024-10-08 17:54:53 +10:30
README.md More readme updates 2024-10-31 16:08:27 +10:30

sokol-luajit

A luajit set of ffi wrappers for the excellent sokol framework,

  • Win64 Binaries - samples and remotery working
  • Linux64 Binaries - samples and remotery working
  • MacOS Binaries - incomplete. Testing and Fixing ongoing. Expected completion soon.

For all things, Sokol, luajit and sokol-luajit feel free to drop in the Discord

Discord - https://discord.gg/KMDeFebk

Sokol

The repo is based entirely on the brilliant framework here: https://github.com/floooh/sokol

sdf exmample alt text

Some of the source files have been modified to support shared libraries a little better and make the binding of ffi a little easier. There are only small changes, but this is kept in this location - do not use as a source for sokol itself. https://github.com/dlannan/sokol

The build process builds Win, Linux, Mac OSX, IOS but not Android atm. I need to build a shared library mechansim for this to work well. Thus, the build for it currently fails.

Luajit Sokol

The only provided main luajit binaries are for win64. To run other platforms, please build luajit for your platform and place in the bin/ directory. You will also need to modify the paths at the top of the samples lua scripts to match. I will update this to be more friendly in the future (by using ffi.os).

The Wasm part of sokol might not be able to be utilized in this manner. However I do have plans to compile Luajit->wasm and embed sokol generated bytecode. It should be possible, but that is along term goal.

Examples

I have ported examples from sokol, and will be adding more. These show how the ffi interface can be used.

How to use the example. Open a command window or powershell in the repo folder (Win64 powershell shown below)

PS sokol-luajit> cd .\examples\
PS sokol-luajit\examples> .\run_sample.bat cube_sapp

Use the run_sample bat file with one of the following parameters:

Command Description
cimgui_sapp Imgui Demo example
cube_sapp Simple spinning cube
shadow_sapp Shadowed cube with moving light
shapes_sapp Primitive shapes spinning
triangle_sapp Classic triangle
offscreen_sapp Sphere with render texture torii? spinning on its surface.
nuklear_sapp Nuklear GUI demo
nuklear_png_sapp Nuklear example with images
nuklear_multifont Nuklear examples with multiple fonts and font awesome icons
sdf_sapp SDF from the Sokol samples
remotery_cube A spinning cube with Remotery backend. Open /tools/remotery/vis/index.html in your browser.

Some notes:

  • There are a number of objects that must be created as pointers. In ffi the easiest way to do this is to make an array object of size 1 and this way the handle in lua is a pointer and the object access uses the array indexing.
  • No performance considerations have been taken into account. These are almost direct 1 to 1 mappings of the sokol C samples to luajit samples.
  • pathing is not yet made friendly (31/10/2024 - It has been improved dramatically. Little more to do.)

Feel free to contribute or post issues/ideas comment. I put this together yesterday, and its very rudimentary atm.

Screenshots:

cimgui example alt text

nuklear example alt text

offscreen example alt text

shadow example

shapes example