1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
mod init; pub mod shader_strings; pub use init::*; mod mainloop; use crate::hal::ConsoleBacking; pub use mainloop::*; use parking_lot::Mutex; use std::any::Any; pub type GlCallback = fn(&mut dyn Any, &glow::Context); lazy_static! { pub static ref BACKEND: Mutex<PlatformGL> = Mutex::new(PlatformGL { gl: None, quad_vao: None, context_wrapper: None, backing_buffer: None, frame_sleep_time: None, gl_callback: None, resize_scaling: false, resize_request: None, request_screenshot: None, }); } lazy_static! { pub(crate) static ref CONSOLE_BACKING: Mutex<Vec<ConsoleBacking>> = Mutex::new(Vec::new()); } pub struct PlatformGL { pub gl: Option<glow::Context>, pub quad_vao: Option<u32>, pub context_wrapper: Option<WrappedContext>, pub backing_buffer: Option<super::Framebuffer>, pub frame_sleep_time: Option<u64>, pub gl_callback: Option<GlCallback>, pub resize_scaling: bool, pub resize_request: Option<(u32, u32)>, pub request_screenshot: Option<String>, } unsafe impl Send for PlatformGL {} unsafe impl Sync for PlatformGL {} pub struct WrappedContext { pub el: glutin::event_loop::EventLoop<()>, pub wc: glutin::WindowedContext<glutin::PossiblyCurrent>, } pub struct InitHints { pub vsync: bool, pub fullscreen: bool, pub gl_version: glutin::GlRequest, pub gl_profile: glutin::GlProfile, pub hardware_acceleration: bool, pub srgb: bool, pub frame_sleep_time: Option<f32>, pub resize_scaling: bool, } impl InitHints { pub fn new() -> Self { Self { vsync: true, fullscreen: false, gl_version: glutin::GlRequest::Latest, gl_profile: glutin::GlProfile::Core, hardware_acceleration: true, srgb: true, frame_sleep_time: None, resize_scaling: false, } } } impl Default for InitHints { fn default() -> Self { Self { vsync: true, fullscreen: false, gl_version: glutin::GlRequest::Latest, gl_profile: glutin::GlProfile::Core, hardware_acceleration: true, srgb: true, frame_sleep_time: None, resize_scaling: false, } } } pub fn log(s: &str) { println!("{}", s); }