Browse Source

Include resources with include_bytes! macro

Johannes Hofmann 7 years ago
parent
commit
098ebc582a
2 changed files with 9 additions and 2 deletions
  1. 5
    1
      src/map_view_gl.rs
  2. 4
    1
      src/tile_atlas.rs

+ 5
- 1
src/map_view_gl.rs View File

31
         ) -> MapViewGl
31
         ) -> MapViewGl
32
         where F: Fn() + Sync + Send + 'static,
32
         where F: Fn() + Sync + Send + 'static,
33
     {
33
     {
34
-        let mut program = Program::from_paths(cx, "shader/map.vert", "shader/map.frag").unwrap();
34
+        let mut program = Program::new(
35
+            cx,
36
+            include_bytes!("../shader/map.vert"),
37
+            include_bytes!("../shader/map.frag"),
38
+        ).unwrap();
35
         check_gl_errors!(cx);
39
         check_gl_errors!(cx);
36
 
40
 
37
         let tile_size = 256;
41
         let tile_size = 256;

+ 4
- 1
src/tile_atlas.rs View File

29
     fn init(&mut self) {
29
     fn init(&mut self) {
30
         // add tile for default slot
30
         // add tile for default slot
31
         {
31
         {
32
-            let img = image::open("img/no_tile.png").unwrap();
32
+            let img = image::load_from_memory_with_format(
33
+                include_bytes!("../img/no_tile.png"),
34
+                image::ImageFormat::PNG,
35
+            ).unwrap();
33
             self.texture.sub_image(0, 0, &img);
36
             self.texture.sub_image(0, 0, &img);
34
         }
37
         }
35
 
38