Mercurial > touhou
diff examples/stdrenderer.rs @ 742:0a250ddfae79
examples: Update luminance.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 07 Jan 2020 00:23:15 +0100 |
parents | d5d5496e4e53 |
children | 0fed350d1778 |
line wrap: on
line diff
--- a/examples/stdrenderer.rs +++ b/examples/stdrenderer.rs @@ -1,6 +1,6 @@ use luminance::blending::{Equation, Factor}; use luminance::context::GraphicsContext; -use luminance::pipeline::BoundTexture; +use luminance::pipeline::{BoundTexture, PipelineState}; use luminance::pixel::NormUnsigned; use luminance::render_state::RenderState; use luminance::shader::program::{Program, Uniform}; @@ -129,11 +129,17 @@ fn main() { // TODO: seed this PRNG with a valid seed. let prng = Rc::new(RefCell::new(Prng::new(0))); + let mut surface = GlfwSurface::new(WindowDim::Windowed(384, 448), "Touhou", WindowOpt::default()).unwrap(); + + // Open the image atlas matching this ANM. + let tex = load_anm_image(&mut surface, &anm0, anm_filename).expect("image loading"); + assert_eq!(std::mem::size_of::<Vertex>(), std::mem::size_of::<FakeVertex>()); let mut vertices: Vec<Vertex> = vec![]; let mut indices = vec![]; { + let anms = Rc::new(RefCell::new([anm0])); for model in stage.models.iter() { let begin = vertices.len(); for quad in model.quads.iter() { @@ -142,7 +148,7 @@ fn main() { // Create the AnmRunner from the ANM and the sprite. let sprite = Rc::new(RefCell::new(Sprite::with_size(width, height))); - let _anm_runner = AnmRunner::new(&anm0, quad.anm_script as u8, sprite.clone(), Rc::downgrade(&prng), 0); + let _anm_runner = AnmRunner::new(anms.clone(), quad.anm_script as u8, sprite.clone(), Rc::downgrade(&prng), 0); let mut new_vertices: [Vertex; 6] = unsafe { std::mem::uninitialized() }; fill_vertices(sprite.clone(), &mut new_vertices, x, y, z); new_vertices[4] = new_vertices[0]; @@ -156,11 +162,6 @@ fn main() { let mut stage_runner = StageRunner::new(Rc::new(RefCell::new(stage))); - let mut surface = GlfwSurface::new(WindowDim::Windowed(384, 448), "Touhou", WindowOpt::default()).unwrap(); - - // Open the image atlas matching this ANM. - let tex = load_anm_image(&mut surface, &anm0, anm_filename).expect("image loading"); - // set the uniform interface to our type so that we can read textures from the shader let program = Program::<Semantics, (), ShaderInterface>::from_strings(None, VS, None, FS).expect("program creation").ignore_warnings(); @@ -202,7 +203,7 @@ fn main() { // and use it in the shader surface .pipeline_builder() - .pipeline(&back_buffer, [0., 0., 0., 0.], |pipeline, mut shd_gate| { + .pipeline(&back_buffer, &PipelineState::default(), |pipeline, mut shd_gate| { // bind our fancy texture to the GPU: it gives us a bound texture we can use with the shader let bound_tex = match &tex { LoadedTexture::Rgb(tex) => pipeline.bind_texture(tex), @@ -233,7 +234,7 @@ fn main() { for instance in stage.instances.iter() { iface.instance_position.update([instance.pos.x, instance.pos.y, instance.pos.z]); - rdr_gate.render(render_state, |mut tess_gate| { + rdr_gate.render(&render_state, |mut tess_gate| { let (begin, end) = indices[instance.id as usize]; tess_gate.render(tess.slice(begin..end)); });