fix texture initialization
authoralfadur
Fri, 22 Mar 2019 21:09:17 +0300
changeset 14729 19358c313ebb
parent 14728 5237b4c44d11
child 14730 65c971417780
fix texture initialization
rust/lib-hedgewars-engine/src/render/camera.rs
rust/lib-hedgewars-engine/src/world.rs
--- a/rust/lib-hedgewars-engine/src/render/camera.rs	Fri Mar 22 20:38:50 2019 +0300
+++ b/rust/lib-hedgewars-engine/src/render/camera.rs	Fri Mar 22 21:09:17 2019 +0300
@@ -15,7 +15,7 @@
     pub fn with_size(size: Size) -> Self {
         Self {
             position: Point::ZERO,
-            zoom: 0.0,
+            zoom: 1.0,
             size,
         }
     }
--- a/rust/lib-hedgewars-engine/src/world.rs	Fri Mar 22 20:38:50 2019 +0300
+++ b/rust/lib-hedgewars-engine/src/world.rs	Fri Mar 22 21:09:17 2019 +0300
@@ -43,6 +43,18 @@
     pub fn create_renderer(&mut self, width: u16, height: u16) {
         self.renderer = Some(MapRenderer::new(512, 512));
         self.camera = Camera::with_size(Size::new(width as usize, height as usize));
+
+        use mapgen::{theme::Theme, MapGenerator};
+        use std::path::Path;
+
+        if let Some(ref state) = self.game_state {
+            let theme =
+                Theme::load(Path::new("../../share/hedgewars/Data/Themes/Cheese/")).unwrap();
+            let texture = MapGenerator::new().make_texture32(&state.land, &theme);
+            if let Some(ref mut renderer) = self.renderer {
+                renderer.init(&texture);
+            }
+        }
     }
 
     pub fn set_seed(&mut self, seed: &[u8]) {
@@ -83,18 +95,6 @@
         let landgen = TemplatedLandGenerator::new(template);
         let land = landgen.generate_land(&params, &mut self.random_numbers_gen);
 
-        use mapgen::{
-            theme::{slice_u32_to_u8, Theme},
-            MapGenerator,
-        };
-
-        use std::path::Path;
-
-        let theme = Theme::load(Path::new("../../share/hedgewars/Data/Themes/Cheese/")).unwrap();
-        let texture = MapGenerator::new().make_texture32(&land, &theme);
-        if let Some(ref mut renderer) = self.renderer {
-            renderer.init(&texture);
-        }
         self.game_state = Some(GameState::new(land, physics));
     }