I’ve run across a number of open source libraries in C that I thought looked interesting, but would often get deterred by the hassle of setting up the projects and such. I was aware of tcc and some of the Lua efforts using it, but that also fell victim to the same hesitation.
The idea has germinated for a while, though, and since some stuff has landed in 3713 (and gotten some minor C fixes in 3719), it seemed like it would be extra-handy, given that some of the useful bits weren’t a good fit for Lua.
I took a small existing plugin and added Solar support around it. So far these are the Mac bits, but @Kan98 has also got lots of stuff working on Windows. (Both are still WIP, though.)
That’s using a build of the mob branch of TinyCC, via the libtcc.a
and the zip, in the mac
folder, although I’d like to try using the ONE_SOURCE
approach to (I hope) avoid the extra build step.
This is currently only useful on desktop, e.g. for rapid testing of libraries or plugin development. (It is actually quite common as the “debug” / development compiler in a lot of projects.) I’m hoping some practical workflows will emerge over time.
In addition to using C strings or code, existing dynamic libraries seem to work well, so it can also be used as an FFI.
(Also, I would like to test something if somebody on Mac doesn’t have Xcode or Developer Tools installed.)
Here’s my current copy of the tests (Kan might have some stuff to add):
solar2c_tests.zip (7.8 MB)
Assuming I uploaded the plugin properly, you can try them by going to main.lua and setting Choice
to the desired example. (Yes, these are tests. )
The prints
, color_mask
, stuff_3
, and stuff_3D
are the graphics examples from the above “experimental” link, ported to C. (There’s also a quick-and-dirty z-order test in the last folder.)
bitmap_test
was, as the name sort of suggests, used to test the screwy packing behavior that got fixed in 3721. (It should look odd or crash pre-3721, assuming you don’t have a rather forgiving driver.)
The other stuff (a lot of it still in idea form, or needing some porting, etc.) come from random interesting C libraries. (The licenses are all pretty lenient and probably in most of the source files, but I expect I’ll make a proper list before adding the examples to the repository itself.)
The js_and_wasm
still have problems. (I might have flushed out an actual code generation bug, although it’s odd all the other stuff seems to be fine. Haven’t reached out about this yet.) Anyhow, those use a Javascript and WASM library (i.e. they run such code, not that they’re written in them) to use some music libraries. These are ports of some code I wrote a couple years back (which does work), investigating how to bring in non-Lua libraries. (Related to mod support in SoLoud.)
The flecs
folder has a couple tests from the MANY in the ECS library of the same name. I’m curious about some of its search features.
microui
is a port of the demo for the immediate mode GUI library of the same name. Kan added input to it, though we haven’t synced it here.
jar_libs
and TinySoundFont
are some little tests for mod, xm, and soundfont audio. These don’t yet have Windows support, since we haven’t figured out some file IO stuff there. They do have support for loading from memory, so might “work”, but of course these are tests and meant to bring in all features possible.
Anything else is, as mentioned above, not yet ready.
Plenty of other ideas floating around. Random shortlist in some notes:
tbox
chips
tg (and other tidwall libraries)
More of flecs
blis, blosc2, flite
textedit, tileeditor (from stb's nothings)
Connected components, iji2grid
stencil-based z-order
stencil-based curve?
scalable-font2, wamain (from bzt on Gitlab)
RISC-V?
arc-length parametrization? (maybe not much use in C)
texture stuff
memory stuff
image processing stuff? (content-aware fill; wfc or graphcut)
other plugins… (3D: shape generator, e.g. prideout's stuff)
hash, RNG, compression tests
LuaAutoC
Nelua; vlang; Nim?
The audio examples use a little bit of raw OpenAL to do the audio, since Solar doesn’t yet have any audio integration support. (I have played with some things, but don’t have any final ideas in mind.)
Also, none of the tests really do much shutdown, so could possibly get work if your relaunch a lot.