annotate examples/common.rs @ 752:5e5e7136ac92

examples: Return a Result for load_file_into_vec()
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 29 Jan 2020 17:45:25 +0100
parents ee45bfde91bb
children a662dddd4a2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
745
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
1 use image::{GenericImageView, DynamicImage, GrayImage, ImageError};
705
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2 use luminance::pixel::{NormRGB8UI, NormRGBA8UI};
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 use luminance::texture::{Dim2, Flat, Sampler, Texture, GenMipmaps};
707
987409d48991 Switch to versioned luminance now that it got released, not hardcoded paths.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 706
diff changeset
4 use luminance_glfw::GlfwSurface;
706
bca515da9047 examples: use common module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 705
diff changeset
5 use touhou::th06::anm0::Anm0;
705
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 use std::fs::File;
752
5e5e7136ac92 examples: Return a Result for load_file_into_vec()
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 749
diff changeset
7 use std::io::{self, BufReader, Read};
705
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 use std::path::Path;
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9
752
5e5e7136ac92 examples: Return a Result for load_file_into_vec()
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 749
diff changeset
10 pub fn load_file_into_vec<P: AsRef<Path>>(filename: P) -> io::Result<Vec<u8>> {
5e5e7136ac92 examples: Return a Result for load_file_into_vec()
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 749
diff changeset
11 let file = File::open(filename)?;
705
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 let mut file = BufReader::new(file);
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 let mut buf = vec![];
752
5e5e7136ac92 examples: Return a Result for load_file_into_vec()
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 749
diff changeset
14 file.read_to_end(&mut buf)?;
5e5e7136ac92 examples: Return a Result for load_file_into_vec()
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 749
diff changeset
15 Ok(buf)
705
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16 }
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18 pub enum LoadedTexture {
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19 Rgba(Texture<Flat, Dim2, NormRGBA8UI>),
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20 Rgb(Texture<Flat, Dim2, NormRGB8UI>),
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21 }
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
22
717
d5d5496e4e53 examples: Propagate image loading errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 715
diff changeset
23 #[derive(Debug)]
d5d5496e4e53 examples: Propagate image loading errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 715
diff changeset
24 pub enum TextureLoadError {
d5d5496e4e53 examples: Propagate image loading errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 715
diff changeset
25 CannotOpenRgb(String, ImageError),
d5d5496e4e53 examples: Propagate image loading errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 715
diff changeset
26 CannotOpenAlpha(String, ImageError),
d5d5496e4e53 examples: Propagate image loading errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 715
diff changeset
27 AlphaToGrayscale(String),
d5d5496e4e53 examples: Propagate image loading errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 715
diff changeset
28 }
d5d5496e4e53 examples: Propagate image loading errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 715
diff changeset
29
745
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
30 fn open_rgb_png(path: &Path) -> Result<DynamicImage, TextureLoadError> {
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
31 // load the texture into memory as a whole bloc (i.e. no streaming)
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
32 image::open(&path).map_err(|e| TextureLoadError::CannotOpenRgb(path.to_str().unwrap().to_owned(), e))
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
33 }
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
34
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
35 fn open_alpha_png(path: &Path) -> Result<DynamicImage, TextureLoadError> {
705
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 // load the texture into memory as a whole bloc (i.e. no streaming)
745
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
37 image::open(&path).map_err(|e| TextureLoadError::CannotOpenAlpha(path.to_str().unwrap().to_owned(), e))
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
38 }
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
39
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
40 fn merge_rgb_alpha(rgb: &DynamicImage, alpha: &GrayImage) -> Vec<(u8, u8, u8, u8)> {
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
41 rgb
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
42 .pixels()
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
43 .zip(alpha.pixels())
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
44 .map(|((_x, _y, rgb), luma)| (rgb[0], rgb[1], rgb[2], luma[0]))
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
45 .collect::<Vec<_>>()
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
46 }
705
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47
746
0ebf6467e4ff examples: Add a menu example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 745
diff changeset
48 pub fn load_from_data(data: &[u8]) -> Result<DynamicImage, ImageError> {
0ebf6467e4ff examples: Add a menu example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 745
diff changeset
49 image::load_from_memory(data)
0ebf6467e4ff examples: Add a menu example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 745
diff changeset
50 }
0ebf6467e4ff examples: Add a menu example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 745
diff changeset
51
749
ee45bfde91bb examples: Add missing reupload_texture_from_rgb_image() to common
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 746
diff changeset
52 pub fn reupload_texture_from_rgb_image(tex: &mut Texture<Flat, Dim2, NormRGB8UI>, img: DynamicImage) -> Result<(), TextureLoadError> {
745
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
53 let texels = img
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
54 .pixels()
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
55 .map(|(_x, _y, rgb)| (rgb[0], rgb[1], rgb[2]))
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
56 .collect::<Vec<_>>();
705
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
57
749
ee45bfde91bb examples: Add missing reupload_texture_from_rgb_image() to common
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 746
diff changeset
58 // the first argument disables mipmap generation (we don’t care so far)
ee45bfde91bb examples: Add missing reupload_texture_from_rgb_image() to common
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 746
diff changeset
59 tex.upload(GenMipmaps::No, &texels).unwrap();
ee45bfde91bb examples: Add missing reupload_texture_from_rgb_image() to common
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 746
diff changeset
60
ee45bfde91bb examples: Add missing reupload_texture_from_rgb_image() to common
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 746
diff changeset
61 Ok(())
ee45bfde91bb examples: Add missing reupload_texture_from_rgb_image() to common
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 746
diff changeset
62 }
ee45bfde91bb examples: Add missing reupload_texture_from_rgb_image() to common
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 746
diff changeset
63
ee45bfde91bb examples: Add missing reupload_texture_from_rgb_image() to common
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 746
diff changeset
64 pub fn upload_texture_from_rgb_image(surface: &mut GlfwSurface, img: DynamicImage) -> Result<LoadedTexture, TextureLoadError> {
ee45bfde91bb examples: Add missing reupload_texture_from_rgb_image() to common
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 746
diff changeset
65 let (width, height) = img.dimensions();
ee45bfde91bb examples: Add missing reupload_texture_from_rgb_image() to common
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 746
diff changeset
66
745
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
67 // create the luminance texture; the third argument is the number of mipmaps we want (leave it
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
68 // to 0 for now) and the latest is a the sampler to use when sampling the texels in the
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
69 // shader (we’ll just use the default one)
749
ee45bfde91bb examples: Add missing reupload_texture_from_rgb_image() to common
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 746
diff changeset
70 let mut tex =
745
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
71 Texture::new(surface, [width, height], 0, Sampler::default()).expect("luminance texture creation");
705
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
72
749
ee45bfde91bb examples: Add missing reupload_texture_from_rgb_image() to common
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 746
diff changeset
73 reupload_texture_from_rgb_image(&mut tex, img)?;
705
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
74
745
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
75 Ok(LoadedTexture::Rgb(tex))
705
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
76 }
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
77
746
0ebf6467e4ff examples: Add a menu example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 745
diff changeset
78 pub fn load_rgb_texture(surface: &mut GlfwSurface, path: &Path) -> Result<LoadedTexture, TextureLoadError> {
0ebf6467e4ff examples: Add a menu example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 745
diff changeset
79 let img = open_rgb_png(&path)?;
0ebf6467e4ff examples: Add a menu example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 745
diff changeset
80 upload_texture_from_rgb_image(surface, img)
0ebf6467e4ff examples: Add a menu example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 745
diff changeset
81 }
0ebf6467e4ff examples: Add a menu example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 745
diff changeset
82
717
d5d5496e4e53 examples: Propagate image loading errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 715
diff changeset
83 fn load_rgb_a_pngs(surface: &mut GlfwSurface, rgb: &Path, alpha: &Path) -> Result<LoadedTexture, TextureLoadError> {
745
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
84 let img = open_alpha_png(&alpha)?;
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
85 let alpha = match img.grayscale() {
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
86 DynamicImage::ImageLuma8(img) => img,
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
87 _ => {
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
88 return Err(TextureLoadError::AlphaToGrayscale(alpha.to_str().unwrap().to_owned()))
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
89 }
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
90 };
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
91 let (width, height) = img.dimensions();
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
92 let img = open_rgb_png(&rgb)?;
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
93 assert_eq!((width, height), img.dimensions());
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
94 let texels = merge_rgb_alpha(&img, &alpha);
705
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
95
745
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
96 // create the luminance texture; the third argument is the number of mipmaps we want (leave it
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
97 // to 0 for now) and the latest is a the sampler to use when sampling the texels in the
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
98 // shader (we’ll just use the default one)
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
99 let tex =
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
100 Texture::new(surface, [width, height], 0, Sampler::default()).expect("luminance texture creation");
705
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
101
745
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
102 // the first argument disables mipmap generation (we don’t care so far)
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
103 tex.upload(GenMipmaps::No, &texels).unwrap();
705
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
104
745
90e907859bae examples: Simplify PNG load functions.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 740
diff changeset
105 Ok(LoadedTexture::Rgba(tex))
705
ed65f9412bc0 anmrenderer: split common loading functions in another module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
106 }
706
bca515da9047 examples: use common module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 705
diff changeset
107
740
8d29dac12219 examples: Make the common functions take AsRef<Path>.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 717
diff changeset
108 pub fn load_anm_image<P: AsRef<Path>>(mut surface: &mut GlfwSurface, anm0: &Anm0, anm_filename: P) -> Result<LoadedTexture, TextureLoadError> {
8d29dac12219 examples: Make the common functions take AsRef<Path>.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 717
diff changeset
109 let anm_filename = anm_filename.as_ref();
706
bca515da9047 examples: use common module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 705
diff changeset
110 let png_filename = anm_filename.with_file_name(Path::new(&anm0.png_filename).file_name().unwrap());
bca515da9047 examples: use common module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 705
diff changeset
111 match anm0.alpha_filename {
bca515da9047 examples: use common module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 705
diff changeset
112 Some(ref filename) => {
bca515da9047 examples: use common module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 705
diff changeset
113 let alpha_filename = anm_filename.with_file_name(Path::new(filename).file_name().unwrap());
717
d5d5496e4e53 examples: Propagate image loading errors.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 715
diff changeset
114 load_rgb_a_pngs(&mut surface, &png_filename, &alpha_filename)
706
bca515da9047 examples: use common module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 705
diff changeset
115 },
bca515da9047 examples: use common module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 705
diff changeset
116 None => {
746
0ebf6467e4ff examples: Add a menu example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 745
diff changeset
117 load_rgb_texture(&mut surface, &png_filename)
706
bca515da9047 examples: use common module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 705
diff changeset
118 }
bca515da9047 examples: use common module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 705
diff changeset
119 }
bca515da9047 examples: use common module.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 705
diff changeset
120 }