diff options
Diffstat (limited to 'graphics/src/lib.rs')
| -rw-r--r-- | graphics/src/lib.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/graphics/src/lib.rs b/graphics/src/lib.rs index 5f44e41..4f55388 100644 --- a/graphics/src/lib.rs +++ b/graphics/src/lib.rs @@ -1,9 +1,14 @@ +//! The `graphics` crate contains the core functionality for +//! rendering using the `raylib` library. + use raylib::prelude::*; use crate::render::{FrameInfo, Renderer}; pub mod render; +/// The `Window` type represents the game window +#[derive(Debug)] pub struct Window { handle: RaylibHandle, thread: RaylibThread, @@ -12,6 +17,13 @@ pub struct Window { impl Window { /// Instantiates a new window provided with the default /// window `width`, `height`, and `title`. + /// + /// # Examples + /// ```no_run + /// use graphics::Window; + /// + /// let window = Window::new(800, 600, "Dungeon Crawl"); + /// ``` pub fn new(width: i32, height: i32, title: &str) -> Self { let (handle, thread) = raylib::init() .size(width, height) @@ -30,6 +42,14 @@ impl Window { } /// Returns the renderer for the game + /// + /// # Examples + /// ```no_run + /// use graphics::Window; + /// + /// let mut window = Window::new(800, 600, "Dungeon Crawl"); + /// let mut renderer = window.renderer(); + /// ``` pub fn renderer(&mut self) -> Renderer<'_> { let info = FrameInfo::new(&self.handle); let handle = self.handle.begin_drawing(&self.thread); |