mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 22:31:30 +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]
|
||||
extern crate android_glue;
|
||||
|
||||
extern crate glutin;
|
||||
extern crate winit;
|
||||
|
||||
use glutin::{Event, ElementState, MouseCursor};
|
||||
|
||||
mod support;
|
||||
use winit::{Event, ElementState, MouseCursor};
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
android_start!(main);
|
||||
|
||||
fn main() {
|
||||
let window = glutin::WindowBuilder::new().build().unwrap();
|
||||
let window = winit::WindowBuilder::new().build().unwrap();
|
||||
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 mut cursor_idx = 0;
|
||||
|
||||
|
@ -34,8 +30,5 @@ fn main() {
|
|||
Event::Closed => break,
|
||||
_ => (),
|
||||
}
|
||||
|
||||
context.draw_frame((0.0, 1.0, 0.0, 1.0));
|
||||
window.swap_buffers().unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,19 +2,17 @@
|
|||
#[macro_use]
|
||||
extern crate android_glue;
|
||||
|
||||
extern crate glutin;
|
||||
extern crate winit;
|
||||
|
||||
use std::io::{self, Write};
|
||||
|
||||
mod support;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
android_start!(main);
|
||||
|
||||
fn main() {
|
||||
// enumerating monitors
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -24,33 +22,25 @@ fn main() {
|
|||
let mut num = String::new();
|
||||
io::stdin().read_line(&mut num).unwrap();
|
||||
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());
|
||||
|
||||
monitor
|
||||
};
|
||||
|
||||
let window = glutin::WindowBuilder::new()
|
||||
let window = winit::WindowBuilder::new()
|
||||
.with_title("Hello world!".to_string())
|
||||
.with_fullscreen(monitor)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
let _ = unsafe { window.make_current() };
|
||||
|
||||
|
||||
let context = support::load(&window);
|
||||
|
||||
for event in window.wait_events() {
|
||||
context.draw_frame((0.0, 1.0, 0.0, 1.0));
|
||||
let _ = window.swap_buffers();
|
||||
|
||||
println!("{:?}", event);
|
||||
|
||||
match event {
|
||||
glutin::Event::Closed => break,
|
||||
glutin::Event::KeyboardInput(_, _, Some(glutin::VirtualKeyCode::Escape)) => break,
|
||||
winit::Event::Closed => break,
|
||||
winit::Event::KeyboardInput(_, _, Some(winit::VirtualKeyCode::Escape)) => break,
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,21 +2,17 @@
|
|||
#[macro_use]
|
||||
extern crate android_glue;
|
||||
|
||||
extern crate glutin;
|
||||
extern crate winit;
|
||||
|
||||
use glutin::{Event, ElementState};
|
||||
|
||||
mod support;
|
||||
use winit::{Event, ElementState};
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
android_start!(main);
|
||||
|
||||
fn main() {
|
||||
let window = glutin::WindowBuilder::new().build().unwrap();
|
||||
window.set_title("glutin - Cursor grabbing test");
|
||||
let _ = unsafe { window.make_current() };
|
||||
let window = winit::WindowBuilder::new().build().unwrap();
|
||||
window.set_title("winit - Cursor grabbing test");
|
||||
|
||||
let context = support::load(&window);
|
||||
let mut grabbed = false;
|
||||
|
||||
for event in window.wait_events() {
|
||||
|
@ -24,11 +20,11 @@ fn main() {
|
|||
Event::KeyboardInput(ElementState::Pressed, _, _) => {
|
||||
if grabbed {
|
||||
grabbed = false;
|
||||
window.set_cursor_state(glutin::CursorState::Normal)
|
||||
window.set_cursor_state(winit::CursorState::Normal)
|
||||
.ok().expect("could not ungrab mouse cursor");
|
||||
} else {
|
||||
grabbed = true;
|
||||
window.set_cursor_state(glutin::CursorState::Grab)
|
||||
window.set_cursor_state(winit::CursorState::Grab)
|
||||
.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]
|
||||
extern crate android_glue;
|
||||
|
||||
extern crate glutin;
|
||||
extern crate winit;
|
||||
|
||||
use std::thread;
|
||||
|
||||
mod support;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
android_start!(main);
|
||||
|
||||
fn main() {
|
||||
let window1 = glutin::WindowBuilder::new().build().unwrap();
|
||||
let window2 = glutin::WindowBuilder::new().build().unwrap();
|
||||
let window3 = glutin::WindowBuilder::new().build().unwrap();
|
||||
let window1 = winit::WindowBuilder::new().build().unwrap();
|
||||
let window2 = winit::WindowBuilder::new().build().unwrap();
|
||||
let window3 = winit::WindowBuilder::new().build().unwrap();
|
||||
|
||||
let t1 = thread::spawn(move || {
|
||||
run(window1, (0.0, 1.0, 0.0, 1.0));
|
||||
run(window1);
|
||||
});
|
||||
|
||||
let t2 = thread::spawn(move || {
|
||||
run(window2, (0.0, 0.0, 1.0, 1.0));
|
||||
run(window2);
|
||||
});
|
||||
|
||||
let t3 = thread::spawn(move || {
|
||||
run(window3, (1.0, 0.0, 0.0, 1.0));
|
||||
run(window3);
|
||||
});
|
||||
|
||||
let _ = t1.join();
|
||||
|
@ -33,17 +31,10 @@ fn main() {
|
|||
let _ = t3.join();
|
||||
}
|
||||
|
||||
fn run(window: glutin::Window, color: (f32, f32, f32, f32)) {
|
||||
let _ = unsafe { window.make_current() };
|
||||
|
||||
let context = support::load(&window);
|
||||
|
||||
fn run(window: winit::Window) {
|
||||
for event in window.wait_events() {
|
||||
context.draw_frame(color);
|
||||
let _ = window.swap_buffers();
|
||||
|
||||
match event {
|
||||
glutin::Event::Closed => break,
|
||||
winit::Event::Closed => break,
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
#[macro_use]
|
||||
extern crate android_glue;
|
||||
|
||||
extern crate glutin;
|
||||
|
||||
mod support;
|
||||
extern crate winit;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
android_start!(main);
|
||||
|
@ -14,25 +12,17 @@ fn resize_callback(width: u32, height: u32) {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let mut window = glutin::WindowBuilder::new().with_decorations(false)
|
||||
let mut window = winit::WindowBuilder::new().with_decorations(false)
|
||||
.with_transparency(true)
|
||||
.build().unwrap();
|
||||
window.set_title("A fantastic window!");
|
||||
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() {
|
||||
context.draw_frame((0.0, 0.0, 0.0, 0.0));
|
||||
let _ = window.swap_buffers();
|
||||
|
||||
println!("{:?}", event);
|
||||
|
||||
match event {
|
||||
glutin::Event::Closed => break,
|
||||
winit::Event::Closed => break,
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
extern crate glutin;
|
||||
extern crate winit;
|
||||
|
||||
#[cfg(feature = "window")]
|
||||
#[test]
|
||||
fn window_proxy_send() {
|
||||
// ensures that `glutin::WindowProxy` implements `Send`
|
||||
// ensures that `winit::WindowProxy` implements `Send`
|
||||
fn needs_send<T:Send>() {}
|
||||
needs_send::<glutin::WindowProxy>();
|
||||
needs_send::<winit::WindowProxy>();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue