mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 06:41:31 +11:00
Merge pull request #7 from tomaka/fix-test
Fix the test and the examples
This commit is contained in:
commit
f7bef4f156
|
@ -2,21 +2,17 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate android_glue;
|
extern crate android_glue;
|
||||||
|
|
||||||
extern crate glutin;
|
extern crate winit;
|
||||||
|
|
||||||
use glutin::{Event, ElementState, MouseCursor};
|
use winit::{Event, ElementState, MouseCursor};
|
||||||
|
|
||||||
mod support;
|
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
android_start!(main);
|
android_start!(main);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let window = glutin::WindowBuilder::new().build().unwrap();
|
let window = winit::WindowBuilder::new().build().unwrap();
|
||||||
window.set_title("A fantastic window!");
|
window.set_title("A fantastic window!");
|
||||||
unsafe { window.make_current().unwrap() };
|
|
||||||
|
|
||||||
let context = support::load(&window);
|
|
||||||
let cursors = [MouseCursor::Default, MouseCursor::Crosshair, MouseCursor::Hand, MouseCursor::Arrow, MouseCursor::Move, MouseCursor::Text, MouseCursor::Wait, MouseCursor::Help, MouseCursor::Progress, MouseCursor::NotAllowed, MouseCursor::ContextMenu, MouseCursor::NoneCursor, MouseCursor::Cell, MouseCursor::VerticalText, MouseCursor::Alias, MouseCursor::Copy, MouseCursor::NoDrop, MouseCursor::Grab, MouseCursor::Grabbing, MouseCursor::AllScroll, MouseCursor::ZoomIn, MouseCursor::ZoomOut, MouseCursor::EResize, MouseCursor::NResize, MouseCursor::NeResize, MouseCursor::NwResize, MouseCursor::SResize, MouseCursor::SeResize, MouseCursor::SwResize, MouseCursor::WResize, MouseCursor::EwResize, MouseCursor::NsResize, MouseCursor::NeswResize, MouseCursor::NwseResize, MouseCursor::ColResize, MouseCursor::RowResize];
|
let cursors = [MouseCursor::Default, MouseCursor::Crosshair, MouseCursor::Hand, MouseCursor::Arrow, MouseCursor::Move, MouseCursor::Text, MouseCursor::Wait, MouseCursor::Help, MouseCursor::Progress, MouseCursor::NotAllowed, MouseCursor::ContextMenu, MouseCursor::NoneCursor, MouseCursor::Cell, MouseCursor::VerticalText, MouseCursor::Alias, MouseCursor::Copy, MouseCursor::NoDrop, MouseCursor::Grab, MouseCursor::Grabbing, MouseCursor::AllScroll, MouseCursor::ZoomIn, MouseCursor::ZoomOut, MouseCursor::EResize, MouseCursor::NResize, MouseCursor::NeResize, MouseCursor::NwResize, MouseCursor::SResize, MouseCursor::SeResize, MouseCursor::SwResize, MouseCursor::WResize, MouseCursor::EwResize, MouseCursor::NsResize, MouseCursor::NeswResize, MouseCursor::NwseResize, MouseCursor::ColResize, MouseCursor::RowResize];
|
||||||
let mut cursor_idx = 0;
|
let mut cursor_idx = 0;
|
||||||
|
|
||||||
|
@ -34,8 +30,5 @@ fn main() {
|
||||||
Event::Closed => break,
|
Event::Closed => break,
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
context.draw_frame((0.0, 1.0, 0.0, 1.0));
|
|
||||||
window.swap_buffers().unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,19 +2,17 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate android_glue;
|
extern crate android_glue;
|
||||||
|
|
||||||
extern crate glutin;
|
extern crate winit;
|
||||||
|
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
|
|
||||||
mod support;
|
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
android_start!(main);
|
android_start!(main);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// enumerating monitors
|
// enumerating monitors
|
||||||
let monitor = {
|
let monitor = {
|
||||||
for (num, monitor) in glutin::get_available_monitors().enumerate() {
|
for (num, monitor) in winit::get_available_monitors().enumerate() {
|
||||||
println!("Monitor #{}: {:?}", num, monitor.get_name());
|
println!("Monitor #{}: {:?}", num, monitor.get_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,33 +22,25 @@ fn main() {
|
||||||
let mut num = String::new();
|
let mut num = String::new();
|
||||||
io::stdin().read_line(&mut num).unwrap();
|
io::stdin().read_line(&mut num).unwrap();
|
||||||
let num = num.trim().parse().ok().expect("Please enter a number");
|
let num = num.trim().parse().ok().expect("Please enter a number");
|
||||||
let monitor = glutin::get_available_monitors().nth(num).expect("Please enter a valid ID");
|
let monitor = winit::get_available_monitors().nth(num).expect("Please enter a valid ID");
|
||||||
|
|
||||||
println!("Using {:?}", monitor.get_name());
|
println!("Using {:?}", monitor.get_name());
|
||||||
|
|
||||||
monitor
|
monitor
|
||||||
};
|
};
|
||||||
|
|
||||||
let window = glutin::WindowBuilder::new()
|
let window = winit::WindowBuilder::new()
|
||||||
.with_title("Hello world!".to_string())
|
.with_title("Hello world!".to_string())
|
||||||
.with_fullscreen(monitor)
|
.with_fullscreen(monitor)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let _ = unsafe { window.make_current() };
|
|
||||||
|
|
||||||
|
|
||||||
let context = support::load(&window);
|
|
||||||
|
|
||||||
for event in window.wait_events() {
|
for event in window.wait_events() {
|
||||||
context.draw_frame((0.0, 1.0, 0.0, 1.0));
|
|
||||||
let _ = window.swap_buffers();
|
|
||||||
|
|
||||||
println!("{:?}", event);
|
println!("{:?}", event);
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
glutin::Event::Closed => break,
|
winit::Event::Closed => break,
|
||||||
glutin::Event::KeyboardInput(_, _, Some(glutin::VirtualKeyCode::Escape)) => break,
|
winit::Event::KeyboardInput(_, _, Some(winit::VirtualKeyCode::Escape)) => break,
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,21 +2,17 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate android_glue;
|
extern crate android_glue;
|
||||||
|
|
||||||
extern crate glutin;
|
extern crate winit;
|
||||||
|
|
||||||
use glutin::{Event, ElementState};
|
use winit::{Event, ElementState};
|
||||||
|
|
||||||
mod support;
|
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
android_start!(main);
|
android_start!(main);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let window = glutin::WindowBuilder::new().build().unwrap();
|
let window = winit::WindowBuilder::new().build().unwrap();
|
||||||
window.set_title("glutin - Cursor grabbing test");
|
window.set_title("winit - Cursor grabbing test");
|
||||||
let _ = unsafe { window.make_current() };
|
|
||||||
|
|
||||||
let context = support::load(&window);
|
|
||||||
let mut grabbed = false;
|
let mut grabbed = false;
|
||||||
|
|
||||||
for event in window.wait_events() {
|
for event in window.wait_events() {
|
||||||
|
@ -24,11 +20,11 @@ fn main() {
|
||||||
Event::KeyboardInput(ElementState::Pressed, _, _) => {
|
Event::KeyboardInput(ElementState::Pressed, _, _) => {
|
||||||
if grabbed {
|
if grabbed {
|
||||||
grabbed = false;
|
grabbed = false;
|
||||||
window.set_cursor_state(glutin::CursorState::Normal)
|
window.set_cursor_state(winit::CursorState::Normal)
|
||||||
.ok().expect("could not ungrab mouse cursor");
|
.ok().expect("could not ungrab mouse cursor");
|
||||||
} else {
|
} else {
|
||||||
grabbed = true;
|
grabbed = true;
|
||||||
window.set_cursor_state(glutin::CursorState::Grab)
|
window.set_cursor_state(winit::CursorState::Grab)
|
||||||
.ok().expect("could not grab mouse cursor");
|
.ok().expect("could not grab mouse cursor");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -41,8 +37,5 @@ fn main() {
|
||||||
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
context.draw_frame((0.0, 1.0, 0.0, 1.0));
|
|
||||||
let _ = window.swap_buffers();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,30 +2,28 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate android_glue;
|
extern crate android_glue;
|
||||||
|
|
||||||
extern crate glutin;
|
extern crate winit;
|
||||||
|
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
mod support;
|
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
android_start!(main);
|
android_start!(main);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let window1 = glutin::WindowBuilder::new().build().unwrap();
|
let window1 = winit::WindowBuilder::new().build().unwrap();
|
||||||
let window2 = glutin::WindowBuilder::new().build().unwrap();
|
let window2 = winit::WindowBuilder::new().build().unwrap();
|
||||||
let window3 = glutin::WindowBuilder::new().build().unwrap();
|
let window3 = winit::WindowBuilder::new().build().unwrap();
|
||||||
|
|
||||||
let t1 = thread::spawn(move || {
|
let t1 = thread::spawn(move || {
|
||||||
run(window1, (0.0, 1.0, 0.0, 1.0));
|
run(window1);
|
||||||
});
|
});
|
||||||
|
|
||||||
let t2 = thread::spawn(move || {
|
let t2 = thread::spawn(move || {
|
||||||
run(window2, (0.0, 0.0, 1.0, 1.0));
|
run(window2);
|
||||||
});
|
});
|
||||||
|
|
||||||
let t3 = thread::spawn(move || {
|
let t3 = thread::spawn(move || {
|
||||||
run(window3, (1.0, 0.0, 0.0, 1.0));
|
run(window3);
|
||||||
});
|
});
|
||||||
|
|
||||||
let _ = t1.join();
|
let _ = t1.join();
|
||||||
|
@ -33,17 +31,10 @@ fn main() {
|
||||||
let _ = t3.join();
|
let _ = t3.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run(window: glutin::Window, color: (f32, f32, f32, f32)) {
|
fn run(window: winit::Window) {
|
||||||
let _ = unsafe { window.make_current() };
|
|
||||||
|
|
||||||
let context = support::load(&window);
|
|
||||||
|
|
||||||
for event in window.wait_events() {
|
for event in window.wait_events() {
|
||||||
context.draw_frame(color);
|
|
||||||
let _ = window.swap_buffers();
|
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
glutin::Event::Closed => break,
|
winit::Event::Closed => break,
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate android_glue;
|
extern crate android_glue;
|
||||||
|
|
||||||
extern crate glutin;
|
extern crate winit;
|
||||||
|
|
||||||
mod support;
|
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
android_start!(main);
|
android_start!(main);
|
||||||
|
@ -14,25 +12,17 @@ fn resize_callback(width: u32, height: u32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut window = glutin::WindowBuilder::new().with_decorations(false)
|
let mut window = winit::WindowBuilder::new().with_decorations(false)
|
||||||
.with_transparency(true)
|
.with_transparency(true)
|
||||||
.build().unwrap();
|
.build().unwrap();
|
||||||
window.set_title("A fantastic window!");
|
window.set_title("A fantastic window!");
|
||||||
window.set_window_resize_callback(Some(resize_callback as fn(u32, u32)));
|
window.set_window_resize_callback(Some(resize_callback as fn(u32, u32)));
|
||||||
let _ = unsafe { window.make_current() };
|
|
||||||
|
|
||||||
println!("Pixel format of the window: {:?}", window.get_pixel_format());
|
|
||||||
|
|
||||||
let context = support::load(&window);
|
|
||||||
|
|
||||||
for event in window.wait_events() {
|
for event in window.wait_events() {
|
||||||
context.draw_frame((0.0, 0.0, 0.0, 0.0));
|
|
||||||
let _ = window.swap_buffers();
|
|
||||||
|
|
||||||
println!("{:?}", event);
|
println!("{:?}", event);
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
glutin::Event::Closed => break,
|
winit::Event::Closed => break,
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
extern crate glutin;
|
extern crate winit;
|
||||||
|
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
#[test]
|
#[test]
|
||||||
fn window_proxy_send() {
|
fn window_proxy_send() {
|
||||||
// ensures that `glutin::WindowProxy` implements `Send`
|
// ensures that `winit::WindowProxy` implements `Send`
|
||||||
fn needs_send<T:Send>() {}
|
fn needs_send<T:Send>() {}
|
||||||
needs_send::<glutin::WindowProxy>();
|
needs_send::<winit::WindowProxy>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue