Here's a cool ting I managed to do for #gamedev in #vala with #sdl3
-
Here's a cool ting I managed to do for #gamedev in #vala with #sdl3
Here's a screenshot of a simple SDL3 hello world. I know it doesn't look like much but the cool thing is that I managed to this from Vala, emitting C code, and then compiling with emcc.
Now, there are caveats:
1. Used "profile=libc" so it strips glib.h from the code.
2. Used -DSDL_MAIN_USE_CALLBACKS when compiling, the SDL3 callback structure. This allows me to avoid empcripten binding (you could create one tho) -
Here's a cool ting I managed to do for #gamedev in #vala with #sdl3
Here's a screenshot of a simple SDL3 hello world. I know it doesn't look like much but the cool thing is that I managed to this from Vala, emitting C code, and then compiling with emcc.
Now, there are caveats:
1. Used "profile=libc" so it strips glib.h from the code.
2. Used -DSDL_MAIN_USE_CALLBACKS when compiling, the SDL3 callback structure. This allows me to avoid empcripten binding (you could create one tho)The biggest consequence here is GLIB (and thus GObject). I know that the GNOME GLib project is not interested in porting GLib to WASM at all.
So my solutions are:
1. Hack it so it work on WASM. I'm not sure about this one, I know it can be done, but I'm not convinced on it, also due to licensing it can become a problem for thing like console development for example.
2. Write my own replacement for GLIB. That would be insane. But. I'm not using all GLib, and I'm avoiding GObject stuff as well.
-
The biggest consequence here is GLIB (and thus GObject). I know that the GNOME GLib project is not interested in porting GLib to WASM at all.
So my solutions are:
1. Hack it so it work on WASM. I'm not sure about this one, I know it can be done, but I'm not convinced on it, also due to licensing it can become a problem for thing like console development for example.
2. Write my own replacement for GLIB. That would be insane. But. I'm not using all GLib, and I'm avoiding GObject stuff as well.
I would need:
1. A math library, SDL3 ports a bunch of c-std math stuff (and more) so that can be used. More advanced stuff can be brought from another library like c-glm.
2. A container library. I know of good C ones that I could create vala bindings for and supply whats missing from GLIB. Mostly hashmaps and lists.
3. An IO library, most likely. I thing SDL also does this? Or I can find some library for Files as well.
Oh well, it is just a temporary thing to verify that it can be done.
-
I would need:
1. A math library, SDL3 ports a bunch of c-std math stuff (and more) so that can be used. More advanced stuff can be brought from another library like c-glm.
2. A container library. I know of good C ones that I could create vala bindings for and supply whats missing from GLIB. Mostly hashmaps and lists.
3. An IO library, most likely. I thing SDL also does this? Or I can find some library for Files as well.
Oh well, it is just a temporary thing to verify that it can be done.
@glitchypixel SDL has stuff for IO. I've never used it, so I can't vouch for it, but here's the docs https://wiki.libsdl.org/SDL3/CategoryIOStream
for math, I think your best bet would be to write vala bindings for the libc stuff you need.
containers is probably the trickiest one. there's probably a good C library I don't know about. otherwise you could probably lift implementations from https://github.com/electronicarts/EASTL and wrap them for VALA
-
@glitchypixel SDL has stuff for IO. I've never used it, so I can't vouch for it, but here's the docs https://wiki.libsdl.org/SDL3/CategoryIOStream
for math, I think your best bet would be to write vala bindings for the libc stuff you need.
containers is probably the trickiest one. there's probably a good C library I don't know about. otherwise you could probably lift implementations from https://github.com/electronicarts/EASTL and wrap them for VALA
@glitchypixel I'm very interested to see where you go with this. I got really excited about VALA about ~15 years ago, and the unportability of glib to even things like wasm was one of the reasons I eventually fell off of it. I'd been hoping someone might come along and produce a middle ground between gobject and glib. It seems like that never shaked out, but patching over the deficits with a few choice libraries might actually work out really well.
