Launch a blank window for the editor

This commit is contained in:
Richard Feldman 2020-05-04 21:06:36 -04:00
parent 6556306e25
commit f0b65a25e2
3 changed files with 931 additions and 1 deletions

875
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -48,6 +48,24 @@ tokio = { version = "0.2", features = ["blocking", "fs", "sync", "rt-threaded",
# This way, GitHub Actions works and nobody's builds get broken. # This way, GitHub Actions works and nobody's builds get broken.
inkwell = { git = "https://github.com/rtfeldman/inkwell", tag = "llvm10-0.release1" } inkwell = { git = "https://github.com/rtfeldman/inkwell", tag = "llvm10-0.release1" }
target-lexicon = "0.10" target-lexicon = "0.10"
winit = "0.22"
image = "0.23"
gfx-hal = "0.5"
[target.'cfg(target_os = "macos")'.dependencies.backend]
package = "gfx-backend-metal"
version = "0.5"
[target.'cfg(windows)'.dependencies.backend]
package = "gfx-backend-dx12"
version = "0.5"
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies.backend]
package = "gfx-backend-vulkan"
version = "0.5"
[build-dependencies]
glsl-to-spirv = "0.1"
[dev-dependencies] [dev-dependencies]
pretty_assertions = "0.5.1" pretty_assertions = "0.5.1"
@ -55,3 +73,4 @@ maplit = "1.0.1"
indoc = "0.3.3" indoc = "0.3.3"
quickcheck = "0.8" quickcheck = "0.8"
quickcheck_macros = "0.8" quickcheck_macros = "0.8"

View file

@ -2,7 +2,43 @@ use std::io;
/// The editor is actually launched from the CLI if you pass it zero arguments. /// The editor is actually launched from the CLI if you pass it zero arguments.
pub fn launch() -> io::Result<()> { pub fn launch() -> io::Result<()> {
println!("TODO launch the editor."); // TODO do any initialization here
run_event_loop();
Ok(()) Ok(())
} }
use winit::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
};
fn run_event_loop() {
let event_loop = EventLoop::new();
let window = WindowBuilder::new().build(&event_loop).unwrap();
event_loop.run(move |event, _, control_flow| {
// TODO try ControlFlow::Poll and see if it affects input latency.
// Otherwise, this seems like a better default for minimizing idle
// CPU usage and battry drain. (Might want to switch to Poll whenever
// there are animations in progress though.)
*control_flow = ControlFlow::Wait;
match event {
Event::WindowEvent {
event: WindowEvent::CloseRequested,
..
} => {
println!("Thank you for flying Roc Airlines!");
*control_flow = ControlFlow::Exit
}
Event::MainEventsCleared => window.request_redraw(),
Event::RedrawRequested(_) => {
// TODO render the editor
}
_ => (),
}
});
}