rust/hwrunner/src/main.rs
changeset 14188 3b83ec44e10b
parent 14187 675aa499a70e
child 14293 b8871dd33ec4
--- a/rust/hwrunner/src/main.rs	Fri Nov 09 20:15:29 2018 +0300
+++ b/rust/hwrunner/src/main.rs	Fri Nov 09 23:03:45 2018 +0300
@@ -4,8 +4,19 @@
     WindowEvent,
     EventsLoop,
     GlWindow,
+    GlContext
 };
 
+use gfx::{
+    texture,
+    format,
+    Encoder
+};
+
+use gfx_window_glutin::init_existing;
+
+use hedgewars_engine::EngineInstance;
+
 fn init(event_loop: &EventsLoop, size: LogicalSize) -> GlWindow {
     use glutin::{
         ContextBuilder,
@@ -24,6 +35,13 @@
     let mut event_loop = EventsLoop::new();
     let window = init(&event_loop, LogicalSize::new(1024.0, 768.0));
 
+    let (mut device, mut factory, color_view, depth_view) =
+        init_existing::<format::Rgba8, format::Depth>(&window);
+
+    let mut encoder: Encoder<_, _> = factory.create_command_buffer().into();
+
+    let engine = EngineInstance::new();
+
     let mut is_running = true;
     while is_running {
         event_loop.poll_events(|event| {
@@ -36,6 +54,13 @@
                 },
                 _ => ()
             }
-        })
+        });
+
+        encoder.clear(&color_view, [0.5, 0.0, 0.0, 1.0]);
+        engine.render(&mut encoder, &color_view);
+
+        encoder.flush(&mut device);
+
+        window.swap_buffers().unwrap();
     }
 }