Created
January 2, 2014 11:21
-
-
Save Skrylar/8217841 to your computer and use it in GitHub Desktop.
Finally getting a zero-copy event dispatch working with SDL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern mod sdl; | |
use std::rc::Rc; | |
struct Foof; | |
impl sdl::MouseDelegate for Foof { | |
fn mouse_did_move(_info: &sdl::MouseMotionEventInfo) { | |
println!("Mouse position: {}x{}", _info.x(), _info.y()) | |
} | |
fn mouse_did_click(_info: &sdl::MouseButtonEventInfo) { | |
} | |
fn mouse_did_scroll(_info: &sdl::MouseWheelEventInfo) { | |
} | |
} | |
fn main() { | |
do sdl::start(sdl::init::Video) { | |
let win = sdl::Window::create("Foof wob", 32, 32, 800, 600, 0).ok().unwrap(); | |
let mut ep = sdl::EventPump::new(); | |
let delegate = Rc::from_send(~Foof as ~sdl::MouseDelegate); | |
let mut x = win.borrow_mut(); | |
x.get().set_mouse_delegate(&delegate); | |
'core : loop { | |
ep.do_all(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment