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
//! Context creation configuration //! //! A [`Conf`](struct.Conf.html) struct is used to descrbe a hardware and platform specific setup, //! mostly video display settings. //! //! ## High DPI rendering //! //! You can set the [`Conf::high_dpi`](struct.Conf.html#structfield.high_dpi) flag during initialization to request //! a full-resolution framebuffer on HighDPI displays. The default behaviour //! is `high_dpi = false`, this means that the application will //! render to a lower-resolution framebuffer on HighDPI displays and the //! rendered content will be upscaled by the window system composer. //! In a HighDPI scenario, you still request the same window size during //! [`miniquad::start`](../fn.start.html), but the framebuffer sizes returned by [`Context::screen_size`](../graphics/struct.Context.html#method.screen_size) //! will be scaled up according to the DPI scaling ratio. //! You can also get a DPI scaling factor with the function //! [`Context::dpi_scale`](../graphics/struct.Context.html#method.dpi_scale). //! Here's an example on a Mac with Retina display: //! ``` //! Conf { //! width = 640, //! height = 480, //! high_dpi = true, //! .. Default::default() //! }; //! ``` //! //! The functions [`screen_size`](../graphics/struct.Context.html#method.screen_size) and [`dpi_scale`](../graphics/struct.Context.html#method.dpi_scale) will //! return the following values: //! ```bash //! screen_size -> (1280, 960) //! dpi_scale -> 2.0 //! ``` //! //! If the high_dpi flag is false, or you're not running on a Retina display, //! the values would be: //! ```bash //! screen_size -> (640, 480) //! dpi_scale -> 1.0 //! ``` #[derive(Debug)] pub enum Cache { /// No preloading at all, filesystem::open will always panic. No, /// Load /index.txt first, and cache all the files specified. /// Game will not start until all the files will be cached Index, /// Same as Index, but with the files list instead of index.txt List(Vec<&'static str>), /// Tar archive contents, usually from include_bytes! Tar(&'static [u8]), } #[derive(Debug)] pub enum Loading { /// No progressbar at all, no html special requirements No, /// Will look for some specific html elements and show default progress bar Embedded, //Custom(Box<dyn LoadingPage>), } #[derive(Debug)] pub struct Conf { pub cache: Cache, pub loading: Loading, pub window_title: String, /// the preferred width of the window, ignored on wasm/android pub window_width: i32, /// the preferred height of the window, ignored on wasm/android pub window_height: i32, /// whether the rendering canvas is full-resolution on HighDPI displays pub high_dpi: bool, /// whether the window should be created in fullscreen mode, ignored on wasm/android pub fullscreen: bool, } impl Default for Conf { fn default() -> Conf { Conf { cache: Cache::No, loading: Loading::No, window_title: "".to_owned(), window_width: 800, window_height: 600, high_dpi: false, fullscreen: false, } } }