Update for rustc

This commit is contained in:
Pierre Krieger 2014-12-23 17:12:29 +01:00
parent 5a8982377b
commit dbb82968ba
3 changed files with 20 additions and 14 deletions

View file

@ -6,6 +6,8 @@ extern crate android_glue;
extern crate glutin; extern crate glutin;
use std::thread::Thread;
mod support; mod support;
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
@ -20,17 +22,21 @@ fn main() {
let window2 = glutin::Window::new().unwrap(); let window2 = glutin::Window::new().unwrap();
let window3 = glutin::Window::new().unwrap(); let window3 = glutin::Window::new().unwrap();
spawn(move || { let t1 = Thread::spawn(move || {
run(window1, (0.0, 1.0, 0.0, 1.0)); run(window1, (0.0, 1.0, 0.0, 1.0));
}); });
spawn(move || { let t2 = Thread::spawn(move || {
run(window2, (0.0, 0.0, 1.0, 1.0)); run(window2, (0.0, 0.0, 1.0, 1.0));
}); });
spawn(move || { let t3 = Thread::spawn(move || {
run(window3, (1.0, 0.0, 0.0, 1.0)); run(window3, (1.0, 0.0, 0.0, 1.0));
}); });
t1.join();
t2.join();
t3.join();
} }
#[cfg(feature = "window")] #[cfg(feature = "window")]

View file

@ -23,7 +23,7 @@ fn resize_callback(width: uint, height: uint) {
fn main() { fn main() {
let mut window = glutin::Window::new().unwrap(); let mut window = glutin::Window::new().unwrap();
window.set_title("A fantastic window!"); window.set_title("A fantastic window!");
window.set_window_resize_callback(Some(resize_callback)); window.set_window_resize_callback(Some(resize_callback as fn(uint, uint)));
unsafe { window.make_current() }; unsafe { window.make_current() };
let context = support::load(&window); let context = support::load(&window);

View file

@ -37,7 +37,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
// GetMessage must be called in the same thread as CreateWindow, // GetMessage must be called in the same thread as CreateWindow,
// so we create a new thread dedicated to this window. // so we create a new thread dedicated to this window.
// This is the only safe method. Using `nosend` wouldn't work for non-native runtime. // This is the only safe method. Using `nosend` wouldn't work for non-native runtime.
spawn(move || { ::std::thread::Thread::spawn(move || {
// registering the window class // registering the window class
let class_name = { let class_name = {
let class_name: Vec<u16> = "Window Class".utf16_units().chain(Some(0).into_iter()) let class_name: Vec<u16> = "Window Class".utf16_units().chain(Some(0).into_iter())
@ -69,8 +69,8 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
// building a RECT object with coordinates // building a RECT object with coordinates
let mut rect = winapi::RECT { let mut rect = winapi::RECT {
left: 0, right: builder_dimensions.unwrap_or((1024, 768)).val0() as winapi::LONG, left: 0, right: builder_dimensions.unwrap_or((1024, 768)).0 as winapi::LONG,
top: 0, bottom: builder_dimensions.unwrap_or((1024, 768)).val1() as winapi::LONG, top: 0, bottom: builder_dimensions.unwrap_or((1024, 768)).1 as winapi::LONG,
}; };
// switching to fullscreen if necessary // switching to fullscreen if necessary
@ -82,10 +82,10 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
// adjusting the rect // adjusting the rect
{ {
let pos = monitor.get_position(); let pos = monitor.get_position();
rect.left += pos.val0() as winapi::LONG; rect.left += pos.0 as winapi::LONG;
rect.right += pos.val0() as winapi::LONG; rect.right += pos.0 as winapi::LONG;
rect.top += pos.val1() as winapi::LONG; rect.top += pos.1 as winapi::LONG;
rect.bottom += pos.val1() as winapi::LONG; rect.bottom += pos.1 as winapi::LONG;
} }
// changing device settings // changing device settings
@ -299,9 +299,9 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
if builder_gl_version.is_some() { if builder_gl_version.is_some() {
let version = builder_gl_version.as_ref().unwrap(); let version = builder_gl_version.as_ref().unwrap();
attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as libc::c_int); attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as libc::c_int);
attributes.push(version.val0() as libc::c_int); attributes.push(version.0 as libc::c_int);
attributes.push(gl::wgl_extra::CONTEXT_MINOR_VERSION_ARB as libc::c_int); attributes.push(gl::wgl_extra::CONTEXT_MINOR_VERSION_ARB as libc::c_int);
attributes.push(version.val1() as libc::c_int); attributes.push(version.1 as libc::c_int);
} }
if builder_debug { if builder_debug {
@ -409,7 +409,7 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
unsafe { winapi::TranslateMessage(&msg) }; unsafe { winapi::TranslateMessage(&msg) };
unsafe { winapi::DispatchMessageW(&msg) }; // calls `callback` (see below) unsafe { winapi::DispatchMessageW(&msg) }; // calls `callback` (see below)
} }
}); }).detach();
rx.recv() rx.recv()
} }