diff examples/anmrenderer.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/anmrenderer.rs
+++ b/examples/anmrenderer.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};
@@ -122,18 +122,19 @@ 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");
+
     // Create the AnmRunner from the ANM and the sprite.
-    let mut anm_runner = AnmRunner::new(&anm0, script, sprite.clone(), Rc::downgrade(&prng), 0);
+    let anms = Rc::new(RefCell::new([anm0]));
+    let mut anm_runner = AnmRunner::new(anms, script, sprite.clone(), Rc::downgrade(&prng), 0);
 
     assert_eq!(std::mem::size_of::<Vertex>(), std::mem::size_of::<FakeVertex>());
     let mut vertices: [Vertex; 4] = unsafe { std::mem::uninitialized() };
     fill_vertices(sprite.clone(), &mut vertices);
 
-    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();
@@ -178,7 +179,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),
@@ -200,7 +201,7 @@ fn main() {
                     let render_state = RenderState::default()
                         .set_blending((Equation::Additive, Factor::SrcAlpha, Factor::SrcAlphaComplement));
 
-                    rdr_gate.render(render_state, |mut tess_gate| {
+                    rdr_gate.render(&render_state, |mut tess_gate| {
                         tess_gate.render(&tess);
                     });
                 });