make the glow and glium backends toggleable at build-time

This commit is contained in:
Dustin Carlino 2020-02-10 20:23:12 -08:00
parent 0b56ef6dea
commit 606325ac77
7 changed files with 25 additions and 9 deletions

View File

@ -5,7 +5,9 @@ authors = ["Dustin Carlino <dabreegster@gmail.com>"]
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"

View File

@ -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<usize>,
// 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) {}
}

View File

@ -172,7 +172,7 @@ pub struct PrerenderInnards {
program: <glow::Context as glow::HasContext>::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<usize>,
// Kind of a weird place for this, but ah well.

View File

@ -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,

View File

@ -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<T: Clone> {
StillActive,
Done(String, T),
}
mod backend {
#[cfg(feature = "glium-backend")]
pub use crate::backend_glium::*;
#[cfg(feature = "glow-backend")]
pub use crate::backend_glow::*;
}

View File

@ -159,7 +159,7 @@ impl Settings {
}
pub fn run<G: 'static + GUI, F: FnOnce(&mut EventCtx) -> 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());

View File

@ -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" }