Repository navigation
Consider "C#'ing" the Main Callbacks. #133
Replies: 4 comments
|
Thanks for the suggestion. I agree this is a good direction, but I want to split it into two layers so we do not hide too much of SDL's startup behavior at once. Current plan:
So I think this is feasible, but I would not start with a generator-only implementation. The managed runner should define and test the real C# API surface first; the generator can then be a convenience layer on top of that. |
|
This has now been implemented and merged for the upcoming SDL3-CS 3.4.12.5 release. SDL3-CS now provides Tracking issue: #232 Thanks again for the proposal! |
|
Implemented and released in SDL3-CS 3.4.14.0. The release includes |
|
Thanks for getting around to this. I'll take a look at it as soon as I can |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi, I'm coming from the SDL3 bindings for Rust where the main callbacks (along with most of the SDL library) have been wrapped in more idiomatic Rust code to make it more natural to use in Rust. For the main callbacks this is done by converting them into a macro you can apply to your type which enforces the various app callbacks to be implemented and then creates a main function for you. For an example see here: https://docs.rs/sdl3-main/latest/sdl3_main/attr.app_impl.html
I think it would be beneficial to do the same thing and convert the raw callbacks into something that is idiomatic C#. I think one of the best ways would be to use a source code generator and interface. So that your Pseudo-code might look a bit like this:
And then a user would implement it in their code:
And then a source code generator would generate the
Mainfucntion as well as marshalling all the needed C types. I think this would be more natural to write as a C# developer as you can avoid all the pointers and use more C# like types, e.g. thestring[]variable for command line args isntead of the C-style argc + argvEdit: remove the
ref T appStateparameter since as an interface it will just have access to that. MadeAppInitstatic and abstract so that you can callMyApp.AppInit()directly without having to first constructMyAppAll reactions