diff examples/stdrenderer.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 d5d5496e4e53
line wrap: on
line diff
--- a/examples/stdrenderer.rs
+++ b/examples/stdrenderer.rs
@@ -1,6 +1,5 @@
 use luminance::blending::{Equation, Factor};
 use luminance::context::GraphicsContext;
-use luminance::framebuffer::Framebuffer;
 use luminance::pipeline::BoundTexture;
 use luminance::pixel::NormUnsigned;
 use luminance::render_state::RenderState;
@@ -163,8 +162,8 @@ fn main() {
     let tex = load_anm_image(&mut surface, &anm0, 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 tess = TessBuilder::new(&mut surface)
         .add_vertices(vertices)
@@ -172,21 +171,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;
+        }
+
         {
             stage_runner.run_frame();
             //let sprites = stage.get_sprites();
@@ -197,14 +202,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);
@@ -228,9 +233,9 @@ 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, |tess_gate| {
+                        rdr_gate.render(render_state, |mut tess_gate| {
                             let (begin, end) = indices[instance.id as usize];
-                            tess_gate.render(&mut surface, tess.slice(begin..end));
+                            tess_gate.render(tess.slice(begin..end));
                         });
                     }
                 });