sokol-luajit/README.md

73 lines
3.5 KiB
Markdown
Raw Normal View History

2024-10-08 15:24:53 +08:00
# sokol-luajit
A luajit set of ffi wrappers for the excellent sokol framework,
2024-10-08 16:47:56 +08:00
2024-10-30 14:35:36 +08:00
- [x] Win64 Binaries - samples and remotery working
- [X] Linux64 Binaries - samples and remotery working
- [ ] MacOS Binaries - incomplete. Testing and Fixing ongoing. Expected completion soon.
2024-10-08 16:47:56 +08:00
## Sokol
The repo is based entirely on the brilliant framework here:
https://github.com/floooh/sokol
2024-10-31 12:37:55 +08:00
sdf exmample
![alt text](https://github.com/dlannan/sokol-luajit/blob/main/media/2024-10-30_11-48.png "sdf Example")
2024-10-08 16:47:56 +08:00
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/<your platform> 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 5 examples from sokol, and will be adding more. These show how the ffi interface can be used.
2024-10-08 16:53:28 +08:00
2024-10-31 12:15:39 +08:00
How to use the example. Open a command window or powershell in the repo folder (Win64 powershell shown below)
2024-10-08 16:53:28 +08:00
2024-10-31 12:15:39 +08:00
```
PS sokol-luajit> cd .\examples\
PS sokol-luajit\examples> .\run_sample.bat cube_sapp
```
2024-10-08 16:53:28 +08:00
2024-10-08 16:47:56 +08:00
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.
2024-10-31 12:20:01 +08:00
- pathing is not yet made friendly.
Use the run_sample bat file with one of the following parameters:
2024-10-31 12:37:13 +08:00
| Command | Description |
|---------|-------------|
|```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 |
|```sdf_sapp``` | SDF from the Sokol samples |
|```remotery_cube```| A spinning cube with Remotery backend. Go to /tools/remotery/vis and open index.html in your browser. |
2024-10-08 16:53:28 +08:00
2024-10-16 18:13:42 +08:00
Feel free to contribute or post issues/ideas comment. I put this together yesterday, and its very rudimentary atm.
Screenshots:
cimgui example
![alt text](https://github.com/dlannan/sokol-luajit/blob/main/media/cimgui_sapp.png "cimgui Example")
nuklear example
![alt text](https://github.com/dlannan/sokol-luajit/blob/main/media/nuklear_sapp.png "nuklear Example")
offscreen example
![alt text](https://github.com/dlannan/sokol-luajit/blob/main/media/offscreen_sappjpeg.jpeg "offscreen Example")
shadow example
<video src='https://github.com/dlannan/sokol-luajit/blob/main/media/2024-10-07%2011-31-08.mp4' width=180/>
shapes example
2024-10-30 14:35:36 +08:00
<video src='https://github.com/dlannan/sokol-luajit/blob/main/media/2024-10-07%2011-32-21.mp4' width=180/>