diff examples/eclrenderer.rs @ 715:2b2376811f46

examples: Update luminance.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 23 Sep 2019 00:22:08 +0200
parents 3954801b6299
children 5016c09e5d7c
line wrap: on
line diff
--- a/examples/eclrenderer.rs
+++ b/examples/eclrenderer.rs
@@ -137,8 +137,8 @@ fn main() {
     let tex = load_anm_image(&mut surface, &anm0.borrow(), anm_filename);
 
     // 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");
+    let program =
+        Program::<Semantics, (), ShaderInterface>::from_strings(None, VS, None, FS).expect("program creation").ignore_warnings();
 
     let mut tess = TessBuilder::new(&mut surface)
         .add_vertices(vertices)
@@ -146,21 +146,27 @@ fn main() {
         .build()
         .unwrap();
 
-    let mut back_buffer = Framebuffer::back_buffer(surface.size());
+    let mut back_buffer = surface.back_buffer().unwrap();
+    let mut resize = false;
 
     'app: loop {
         for event in surface.poll_events() {
             match event {
                 WindowEvent::Close | WindowEvent::Key(Key::Escape, _, Action::Release, _) => break 'app,
 
-                WindowEvent::FramebufferSize(width, height) => {
-                    back_buffer = Framebuffer::back_buffer([width as u32, height as u32]);
+                WindowEvent::FramebufferSize(..) => {
+                    resize = true;
                 }
 
                 _ => (),
             }
         }
 
+        if resize {
+            back_buffer = surface.back_buffer().unwrap();
+            resize = false;
+        }
+
         if ecl_runner.running == false {
             break;
         }
@@ -185,14 +191,14 @@ fn main() {
         // and use it in the shader
         surface
             .pipeline_builder()
-            .pipeline(&back_buffer, [0., 0., 0., 0.], |pipeline, shd_gate| {
+            .pipeline(&back_buffer, [0., 0., 0., 0.], |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),
                     LoadedTexture::Rgba(tex) => pipeline.bind_texture(tex),
                 };
 
-                shd_gate.shade(&program, |rdr_gate, iface| {
+                shd_gate.shade(&program, |iface, mut rdr_gate| {
                     // update the texture; strictly speaking, this update doesn’t do much: it just tells the GPU
                     // to use the texture passed as argument (no allocation or copy is performed)
                     iface.color_map.update(&bound_tex);
@@ -207,10 +213,10 @@ fn main() {
                     let render_state = RenderState::default()
                         .set_blending((Equation::Additive, Factor::SrcAlpha, Factor::SrcAlphaComplement));
 
-                    rdr_gate.render(render_state, |tess_gate| {
+                    rdr_gate.render(render_state, |mut tess_gate| {
                         // render the tessellation to the surface the regular way and let the vertex shader’s
                         // magic do the rest!
-                        tess_gate.render(&mut surface, (&tess).into());
+                        tess_gate.render(&tess);
                     });
                 });
             });