SDL3 bindings in odin

odin-sdl3

Its not free of bugs, but its a starting point. Pull requests are welcome.

Also all the sdl-c library functions are stripped in favor of the c.libc package

7 Likes

I tried to build the main.odin file but there were some issues.

There is no check for loading a lib file when OS is Windows so I had to add that in (I created the lib from the dll using ā€˜lib’ in dev cmd prompt, maybe I screwed something up).

In the main file, CreateGPUDevice requires GPUShaderFormat as an argument which is only present as an u32 when it should be a bit_set. I added those in and then it did build but running it didn’t open a window so I don’t think it’s working, I’ll have to investigate further.

The enum fields have redundant names like PropertyType.PROPERTY_TYPE_INVALID instead of PropertyType.INVALID. I get it’s probably to be consistent with the original api but vendor:sdl2 doesn’t do this. Would it maybe be a good idea to keep it consistent with that instead?

Btw, why aren’t you using c types like c.uint instead of u32? I realize those are just aliases but it should be easier to avoid bugs with them. Is it to avoid importing a package?

Anyway, I’m not saying you need to fix these things. Maybe I’ll make a PR once I get all the issues sorted out, but that might take a while. I want to take my time and make sure that it’s mostly functional. Thanks for doing the bulk of the work by the way, it really helps!

You are absolutely correct. I can make the bindings in odin-style like the sdl2 package. I should and I would. Help is appriciated.
And also as I use linux, Ive just made the linux port. Other platform support has to be added.

1 Like

For SDL3, we’ll support official bindings when it is officially released, which I believe is January 15.

Since it is not officially released yet, just ā€œABI stableā€, I will not post the bindings yet.

17 Likes

Nice! I’ll still try to get it work on my end just as a learning experience, but I’m glad it will be officially supported.

1 Like

@gingerBill today is the day and SDL3 is finally released. The inpatient child in me can’t wait to start to use it with Odin in my next project. Any ideas when it could be possible.

Sorry for the impatience :slight_smile:

7 Likes

Since it is SDL3 and not 2, I suggest to postpone the release until March

You can watch the progress on the sdl3 branch of Odin on Github, if you want:

Looks like Bill is hard at work, so I just wouldn’t push at all. I also think this is one of those cases where it makes more sense for one person to do the work. Testing, on the other hand, is where The Many can shine.

2 Likes

PR is up: `vendor:sdl3` by gingerBill Ā· Pull Request #4790 Ā· odin-lang/Odin Ā· GitHub

2 Likes

hi, i’ve added the vendor bindings to the sdl docs: Simple DirectMedia Layer - Language Bindings. thanks for the hard work! @gingerBill

4 Likes

Does someone know how can I use sd3/ttf?

1 Like