diff --git a/ezgui/Cargo.toml b/ezgui/Cargo.toml index 6ce2fc4291..724f9a1b95 100644 --- a/ezgui/Cargo.toml +++ b/ezgui/Cargo.toml @@ -5,7 +5,9 @@ authors = ["Dustin Carlino "] edition = "2018" [features] -default = [] +default = ["glium-backend"] +glium-backend = ["glium"] +glow-backend = ["glow"] profiler = ["cpuprofiler"] [dependencies] @@ -13,8 +15,8 @@ abstutil = { path = "../abstutil" } # backtrace = "0.3.40" cpuprofiler = { version = "0.0.3", optional = true } geom = { path = "../geom" } -#glium = "0.26.0" -glow = "0.4.0" +glium = { version = "0.26.0", optional = true } +glow = { version = "0.4.0", optional = true } glutin = "0.23.0" htmlescape = "0.3.1" image = "0.22.2" diff --git a/ezgui/src/backend_glium.rs b/ezgui/src/backend_glium.rs index 1bb3604cf7..15b2cf73eb 100644 --- a/ezgui/src/backend_glium.rs +++ b/ezgui/src/backend_glium.rs @@ -155,7 +155,7 @@ impl<'a> GfxCtxInnards<'a> { }); } - pub fn disable_clipping(&mut self) { + pub fn disable_clipping(&mut self, _: &Canvas) { assert!(self.params.scissor.is_some()); self.params.scissor = None; } @@ -194,7 +194,7 @@ pub struct PrerenderInnards { program: glium::Program, // TODO Prerender doesn't know what things are temporary and permanent. Could make the API more - // detailed (and use the corresponding persistent glium types). + // detailed. pub total_bytes_uploaded: Cell, // Kind of a weird place for this, but ah well. @@ -330,4 +330,6 @@ impl PrerenderInnards { .push(Texture2dArray::new(&self.display, raw_data).unwrap()); } } + + pub fn window_resized(&self, _: f64, _: f64) {} } diff --git a/ezgui/src/backend_glow.rs b/ezgui/src/backend_glow.rs index 187272624b..ea4bf0b6ad 100644 --- a/ezgui/src/backend_glow.rs +++ b/ezgui/src/backend_glow.rs @@ -172,7 +172,7 @@ pub struct PrerenderInnards { program: ::Program, // TODO Prerender doesn't know what things are temporary and permanent. Could make the API more - // detailed (and use the corresponding persistent glium types). + // detailed. pub total_bytes_uploaded: Cell, // Kind of a weird place for this, but ah well. diff --git a/ezgui/src/drawing.rs b/ezgui/src/drawing.rs index e625c19568..f8ea6c772e 100644 --- a/ezgui/src/drawing.rs +++ b/ezgui/src/drawing.rs @@ -1,5 +1,5 @@ use crate::assets::Assets; -use crate::backend_glow::{GfxCtxInnards, PrerenderInnards}; +use crate::backend::{GfxCtxInnards, PrerenderInnards}; use crate::svg; use crate::{ Canvas, Color, Drawable, EventCtx, HorizontalAlignment, ScreenDims, ScreenPt, ScreenRectangle, diff --git a/ezgui/src/lib.rs b/ezgui/src/lib.rs index 1764e5dde4..c4908798cd 100644 --- a/ezgui/src/lib.rs +++ b/ezgui/src/lib.rs @@ -1,4 +1,7 @@ mod assets; +#[cfg(feature = "glium-backend")] +mod backend_glium; +#[cfg(feature = "glow-backend")] mod backend_glow; mod canvas; mod color; @@ -14,7 +17,7 @@ mod svg; mod text; mod widgets; -pub use crate::backend_glow::Drawable; +pub use crate::backend::Drawable; pub use crate::canvas::{Canvas, HorizontalAlignment, VerticalAlignment}; pub use crate::color::Color; pub use crate::drawing::{GeomBatch, GfxCtx, Prerender, RewriteColor}; @@ -35,3 +38,11 @@ pub enum InputResult { StillActive, Done(String, T), } + +mod backend { + #[cfg(feature = "glium-backend")] + pub use crate::backend_glium::*; + + #[cfg(feature = "glow-backend")] + pub use crate::backend_glow::*; +} diff --git a/ezgui/src/runner.rs b/ezgui/src/runner.rs index a50637b1b3..66e9b70fe6 100644 --- a/ezgui/src/runner.rs +++ b/ezgui/src/runner.rs @@ -159,7 +159,7 @@ impl Settings { } pub fn run G>(settings: Settings, make_gui: F) -> ! { - let (prerender_innards, event_loop) = crate::backend_glow::setup(&settings.window_title); + let (prerender_innards, event_loop) = crate::backend::setup(&settings.window_title); let window_size = event_loop.primary_monitor().size(); let mut canvas = Canvas::new(window_size.width.into(), window_size.height.into()); diff --git a/game/Cargo.toml b/game/Cargo.toml index 0a85d01421..567bf19cf2 100644 --- a/game/Cargo.toml +++ b/game/Cargo.toml @@ -12,6 +12,7 @@ chrono = "0.4.10" counter = "0.4.3" downcast-rs = "1.0.4" ezgui = { path = "../ezgui" } +#ezgui = { path = "../ezgui", default-features=false, features=["glow-backend"] } geom = { path = "../geom" } kml = { path = "../kml" } map_model = { path = "../map_model" }