brson / rust-sdl

SDL bindings for Rust
MIT License
179 stars 52 forks source link

Complete more bindings and make API follow Rust idioms #33

Closed z0w0 closed 11 years ago

z0w0 commented 11 years ago

I don't think it's necessary to prefix all the key variants with "SDLK" for example. I've experimented with a more "rusty" looking API here: https://github.com/z0w0/rust-sdl/tree/revamp

Another example is the KeyboardEvent structs. If you take a look at how I did it, I just make one KeyEvent variant with a state boolean as to whether it was down or up, instead of both a keydown and keyup variant. I think this works nicely and gets rid of the need for an extra struct.

Secondly, these bindings still needs a lot of work to actually have all the SDL functions mirrored. I'll do my best to add what I can.

AngryLawyer commented 11 years ago

Wow, you've been busy. Much of Rust-SDL was written quite a long time ago, and I've always been a bit afraid of rewriting the earlier stuff as I'm not that good at Rust.

Should we think about merging your bits in when you're done? One thing to keep an eye on is the magical Start dance that @pcwalton did for the existing bindings, as otherwise OSX just doesn't work at all.

AngryLawyer commented 11 years ago

Would you like me to make pull requests against your in-progress stuff to help you finish it? I only get like an hour at lunch some weekdays to do Rusty things so I'd like to help where possible.

z0w0 commented 11 years ago

Yeah, I just ripped out all the old code because it was a temporary thing so I could just get my game working as quickly as possible (it needed the internals to work different to how they currently work). When I started trying to fix these bindings, I realised a completely rewrite is probably more in order because these bindings use old idioms.

Well, I'm working on merging these changes now and it shouldn't take too long, so I wouldn't worry about it. I'll have a pull request open in the next few days.

AngryLawyer commented 11 years ago

Cool stuff, thanks for all your help.

AngryLawyer commented 11 years ago

Merged in now