use super::{Context, ContextDisplay, BackendContext, HasContext};
pub struct ContextBuilder {
pub(super) cursor : bool,
pub(super) vsync : bool,
pub(super) display : ContextDisplay
}
impl Default for ContextBuilder {
fn default() -> Self {
let cursor = false;
let vsync = true;
let display = ContextDisplay::Screen;
Self {cursor,vsync,display}
}
}
impl ContextBuilder {
pub fn new() -> Self { Default::default() }
pub fn with_display(mut self, display:ContextDisplay) -> Self {
self.display = display;
self
}
pub fn cursor(mut self, cursor:bool) -> Self {
self.cursor = cursor;
self
}
pub fn vsync(mut self, vsync:bool) -> Self {
self.vsync = vsync;
self
}
pub fn build(self) -> Context {
Box::new(BackendContext::new(&self))
}
#[cfg(target_arch = "wasm32")]
pub fn build_from_canvas(self, canvas: web_sys::HtmlCanvasElement) -> Context {
Box::new(BackendContext::from_canvas(canvas))
}
}