| @@ -74,16 +74,24 @@ pub struct Context { | |||||
| pixel_buffer: PixelBuffer, | pixel_buffer: PixelBuffer, | ||||
| height: usize, | height: usize, | ||||
| width: usize, | width: usize, | ||||
| scale: usize, | |||||
| window: Window, | window: Window, | ||||
| } | } | ||||
| impl Context { | impl Context { | ||||
| /// create a new context | /// create a new context | ||||
| pub fn new(width: usize, height: usize, title: String) -> Result<Context> { | |||||
| let pixel_buffer = PixelBuffer::new(height, width); | |||||
| let mut window = Window::new(&title, width, height, WindowOptions::default())?; | |||||
| pub fn new( | |||||
| width: usize, | |||||
| height: usize, | |||||
| title: String, | |||||
| scale: Option<usize>, | |||||
| ) -> Result<Context> { | |||||
| let scale = scale.unwrap_or(1); | |||||
| let pixel_buffer = PixelBuffer::new(width, height); | |||||
| let mut window = Window::new(&title, width * scale, height * scale, WindowOptions::default())?; | |||||
| window.limit_update_rate(Some(std::time::Duration::from_micros(16600))); | window.limit_update_rate(Some(std::time::Duration::from_micros(16600))); | ||||
| Ok(Context { pixel_buffer, window, height, width }) | |||||
| Ok(Context { pixel_buffer, window, height, width, scale }) | |||||
| } | } | ||||
| /// render the internal buffer to the screen | /// render the internal buffer to the screen | ||||