From 29ea69f347bd996b109c3147225a90c9ac614354 Mon Sep 17 00:00:00 2001 From: jutsu <175562675+Battojutsu@users.noreply.github.com> Date: Tue, 16 Jul 2024 18:18:32 -0500 Subject: [PATCH 1/8] Add documentation for set_target_bitmap --- allegro/src/core.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/allegro/src/core.rs b/allegro/src/core.rs index ec83ed476..318e43f4a 100644 --- a/allegro/src/core.rs +++ b/allegro/src/core.rs @@ -562,6 +562,17 @@ impl Core unsafe { mem::transmute(al_get_new_bitmap_format() as u32) } } + + /// This function is used to set the target bitmap that allegro draws to. + /// ``` + /// // How to set target bitmap similar to al_set_target_bitmap + /// // For a more complete example look at example/example.rs + /// use allegro::*; + /// let core = Core::init().unwrap(); + /// let bmp = Bitmap::new(&core, 400, 400).unwrap(); + /// core.set_target_bitmap(Some(&map)); + /// ``` + pub fn set_target_bitmap(&self, bmp: Option<&T>) { unsafe { From 56edcdef52215906e2c4ec084ca9dcbc1e210edc Mon Sep 17 00:00:00 2001 From: jutsu <175562675+Battojutsu@users.noreply.github.com> Date: Wed, 17 Jul 2024 19:18:57 -0500 Subject: [PATCH 2/8] fix wrong paramater name --- allegro/src/core.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/allegro/src/core.rs b/allegro/src/core.rs index 318e43f4a..f1538ebfb 100644 --- a/allegro/src/core.rs +++ b/allegro/src/core.rs @@ -570,7 +570,7 @@ impl Core /// use allegro::*; /// let core = Core::init().unwrap(); /// let bmp = Bitmap::new(&core, 400, 400).unwrap(); - /// core.set_target_bitmap(Some(&map)); + /// core.set_target_bitmap(Some(&bmp)); /// ``` pub fn set_target_bitmap(&self, bmp: Option<&T>) From fdff3cf93afa05e0e4257b61cc8f2f5495325e4e Mon Sep 17 00:00:00 2001 From: jutsu <175562675+Battojutsu@users.noreply.github.com> Date: Thu, 18 Jul 2024 17:24:07 -0500 Subject: [PATCH 3/8] Add some more documentation --- allegro/src/bitmap.rs | 28 ++++++++++++++++++++++++++++ allegro/src/core.rs | 1 + 2 files changed, 29 insertions(+) diff --git a/allegro/src/bitmap.rs b/allegro/src/bitmap.rs index 3748edab4..37603a617 100644 --- a/allegro/src/bitmap.rs +++ b/allegro/src/bitmap.rs @@ -21,6 +21,21 @@ pub struct Bitmap impl Bitmap { + + /// This method is used to create a new Bitmap object. + /// Can be used to create a bitmap of w width and h height. + /// + /// # Examples + /// ``` + /// use allegro::*; + /// + /// pub fn blank_bitmap(core: &Core) { + /// let blank_bitmap: Bitmap = match Bitmap::new(&core, 400, 200) { + /// Ok(v) => v, + /// Err(e) => panic!("Error loading blank_bitmap {e:?}"), + /// }; + /// } + /// ``` pub fn new(_: &Core, w: i32, h: i32) -> Result { unsafe { @@ -36,6 +51,19 @@ impl Bitmap } } + /// This method is used to load a bitmap file into a Bitmap object. + /// Takes a string path_to_map that points to a bitmap file. + /// # Examples + /// ``` + /// use allegro::*; + /// + /// pub fn load_bitmap(core: &Core, path_to_map: &str) { + /// let tileset_bitmap: Bitmap = match Bitmap::load(&core, path_to_map) { + /// Ok(v) => v, + /// Err(e) => panic!("Error loading tileset_bitmap {e:?}"), + /// }; + /// } + /// ``` pub fn load(_: &Core, filename: &str) -> Result { unsafe { diff --git a/allegro/src/core.rs b/allegro/src/core.rs index f1538ebfb..5c29cf45e 100644 --- a/allegro/src/core.rs +++ b/allegro/src/core.rs @@ -564,6 +564,7 @@ impl Core /// This function is used to set the target bitmap that allegro draws to. + /// # Examples /// ``` /// // How to set target bitmap similar to al_set_target_bitmap /// // For a more complete example look at example/example.rs From b09731e44a16fce25349171c33360cf96fa898ba Mon Sep 17 00:00:00 2001 From: jutsu <175562675+Battojutsu@users.noreply.github.com> Date: Sat, 20 Jul 2024 17:52:35 -0500 Subject: [PATCH 4/8] Fix extraneous space. --- allegro/src/bitmap.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/allegro/src/bitmap.rs b/allegro/src/bitmap.rs index 37603a617..d6991e7b3 100644 --- a/allegro/src/bitmap.rs +++ b/allegro/src/bitmap.rs @@ -54,7 +54,7 @@ impl Bitmap /// This method is used to load a bitmap file into a Bitmap object. /// Takes a string path_to_map that points to a bitmap file. /// # Examples - /// ``` + /// ``` /// use allegro::*; /// /// pub fn load_bitmap(core: &Core, path_to_map: &str) { From 4d15529f03b22c1648673f22ec4757705f3bc5ed Mon Sep 17 00:00:00 2001 From: jutsu <175562675+Battojutsu@users.noreply.github.com> Date: Sat, 20 Jul 2024 17:56:07 -0500 Subject: [PATCH 5/8] Clear up the example with a more descriptive name. --- allegro/src/bitmap.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/allegro/src/bitmap.rs b/allegro/src/bitmap.rs index d6991e7b3..7e97eb38b 100644 --- a/allegro/src/bitmap.rs +++ b/allegro/src/bitmap.rs @@ -29,10 +29,10 @@ impl Bitmap /// ``` /// use allegro::*; /// - /// pub fn blank_bitmap(core: &Core) { - /// let blank_bitmap: Bitmap = match Bitmap::new(&core, 400, 200) { + /// pub fn new_bitmap(core: &Core) { + /// let new_bitmap: Bitmap = match Bitmap::new(&core, 400, 200) { /// Ok(v) => v, - /// Err(e) => panic!("Error loading blank_bitmap {e:?}"), + /// Err(e) => panic!("Error loading new_bitmap {e:?}"), /// }; /// } /// ``` From e909e4a98274b49c66034a97be5cfffb8aec3e8b Mon Sep 17 00:00:00 2001 From: jutsu <175562675+Battojutsu@users.noreply.github.com> Date: Sat, 20 Jul 2024 18:03:46 -0500 Subject: [PATCH 6/8] These are functions not methods. --- allegro/src/bitmap.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/allegro/src/bitmap.rs b/allegro/src/bitmap.rs index 7e97eb38b..141aeea15 100644 --- a/allegro/src/bitmap.rs +++ b/allegro/src/bitmap.rs @@ -22,7 +22,7 @@ pub struct Bitmap impl Bitmap { - /// This method is used to create a new Bitmap object. + /// This function is used to create a new Bitmap object. /// Can be used to create a bitmap of w width and h height. /// /// # Examples @@ -51,7 +51,7 @@ impl Bitmap } } - /// This method is used to load a bitmap file into a Bitmap object. + /// This function is used to load a bitmap file into a Bitmap object. /// Takes a string path_to_map that points to a bitmap file. /// # Examples /// ``` From 83b49a393f92315c0bfb8058a90aa647b237e2e3 Mon Sep 17 00:00:00 2001 From: jutsu <175562675+Battojutsu@users.noreply.github.com> Date: Sat, 20 Jul 2024 18:11:15 -0500 Subject: [PATCH 7/8] Seems like that was an unneeded formatting placeholder. --- allegro/src/bitmap.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/allegro/src/bitmap.rs b/allegro/src/bitmap.rs index 141aeea15..fdfb48c5c 100644 --- a/allegro/src/bitmap.rs +++ b/allegro/src/bitmap.rs @@ -32,7 +32,7 @@ impl Bitmap /// pub fn new_bitmap(core: &Core) { /// let new_bitmap: Bitmap = match Bitmap::new(&core, 400, 200) { /// Ok(v) => v, - /// Err(e) => panic!("Error loading new_bitmap {e:?}"), + /// Err(e) => panic!("Error loading new_bitmap"), /// }; /// } /// ``` @@ -60,7 +60,7 @@ impl Bitmap /// pub fn load_bitmap(core: &Core, path_to_map: &str) { /// let tileset_bitmap: Bitmap = match Bitmap::load(&core, path_to_map) { /// Ok(v) => v, - /// Err(e) => panic!("Error loading tileset_bitmap {e:?}"), + /// Err(e) => panic!("Error loading tileset_bitmap"), /// }; /// } /// ``` From e5d44fc74194ef268796524f3809380d7169c57c Mon Sep 17 00:00:00 2001 From: jutsu <175562675+Battojutsu@users.noreply.github.com> Date: Sun, 21 Jul 2024 17:16:03 -0500 Subject: [PATCH 8/8] This would have been helpful for me. --- allegro/src/bitmap.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/allegro/src/bitmap.rs b/allegro/src/bitmap.rs index fdfb48c5c..6631cce8f 100644 --- a/allegro/src/bitmap.rs +++ b/allegro/src/bitmap.rs @@ -53,6 +53,11 @@ impl Bitmap /// This function is used to load a bitmap file into a Bitmap object. /// Takes a string path_to_map that points to a bitmap file. + /// + /// NOTE: Be sure to initialize image addon before running the + /// load_bitmap function ex: ImageAddon::init(&core).unwrap(); + /// + /// // For a more complete example look at example/example.rs /// # Examples /// ``` /// use allegro::*;