comparison examples/anmrenderer.rs @ 706:bca515da9047

examples: use common module.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 23 Aug 2019 19:46:47 +0200
parents ed65f9412bc0
children 987409d48991
comparison
equal deleted inserted replaced
705:ed65f9412bc0 706:bca515da9047
19 use std::env; 19 use std::env;
20 use std::path::Path; 20 use std::path::Path;
21 21
22 #[path = "common.rs"] 22 #[path = "common.rs"]
23 mod common; 23 mod common;
24 24 use common::{load_file_into_vec, load_anm_image, LoadedTexture};
25 use common::{load_file_into_vec, load_rgb_png, load_rgb_a_pngs, LoadedTexture};
26 25
27 const VS: &str = r#" 26 const VS: &str = r#"
28 in ivec3 in_position; 27 in ivec3 in_position;
29 in vec2 in_texcoord; 28 in vec2 in_texcoord;
30 in vec4 in_color; 29 in vec4 in_color;
133 fill_vertices(sprite.clone(), &mut vertices); 132 fill_vertices(sprite.clone(), &mut vertices);
134 133
135 let mut surface = GlfwSurface::new(WindowDim::Windowed(384, 448), "Touhou", WindowOpt::default()).unwrap(); 134 let mut surface = GlfwSurface::new(WindowDim::Windowed(384, 448), "Touhou", WindowOpt::default()).unwrap();
136 135
137 // Open the image atlas matching this ANM. 136 // Open the image atlas matching this ANM.
138 let png_filename = anm_filename.with_file_name(Path::new(&anm0.png_filename).file_name().unwrap()); 137 let tex = load_anm_image(&mut surface, &anm0, anm_filename);
139 let tex = match anm0.alpha_filename {
140 Some(ref filename) => {
141 let alpha_filename = anm_filename.with_file_name(Path::new(filename).file_name().unwrap());
142 load_rgb_a_pngs(&mut surface, &png_filename, &alpha_filename).expect("texture loading")
143 },
144 None => {
145 load_rgb_png(&mut surface, &png_filename).expect("texture loading")
146 }
147 };
148 138
149 // set the uniform interface to our type so that we can read textures from the shader 139 // set the uniform interface to our type so that we can read textures from the shader
150 let (program, _) = 140 let (program, _) =
151 Program::<Semantics, (), ShaderInterface>::from_strings(None, VS, None, FS).expect("program creation"); 141 Program::<Semantics, (), ShaderInterface>::from_strings(None, VS, None, FS).expect("program creation");
152 142