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
use crate::render_backend::RenderBackend; /// The Covalent structure contains all the information required to render a scene. pub struct Covalent { hints: DisplayHints, rb: Box<dyn RenderBackend> } /// Hints to use when constructing the display window. pub struct DisplayHints { /// The title to show on the display window, if in windowed mode on a backend that supports this. pub title: String, /// The default width of the window, when this can be defined. pub width: i32, /// The default height of the window, when this can be defined. pub height: i32, } impl DisplayHints { /// Creates a DisplayHints object with default parameters. pub fn new() -> DisplayHints { DisplayHints { title: String::from("Covalent"), width: 1024, height: 768, } } } impl Covalent { /// Construct a Covalent context from the given backend. /// Only create a single context during the lifetime of your application, /// and only create this context on the main thread! pub fn new(hints: DisplayHints, rb: Box<dyn RenderBackend>) -> Covalent { Covalent { hints: hints, rb: rb } } /// Executes the application defined by this Covalent context. pub fn execute(mut self) { self.rb.create_window(&self.hints); self.rb.main_loop(); } }