add standalone engine runner
authoralfadur
Fri, 09 Nov 2018 20:15:29 +0300
changeset 14187 675aa499a70e
parent 14186 0d18ecb520ed
child 14188 3b83ec44e10b
add standalone engine runner
rust/hwrunner/Cargo.toml
rust/hwrunner/src/main.rs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/hwrunner/Cargo.toml	Fri Nov 09 20:15:29 2018 +0300
@@ -0,0 +1,10 @@
+[package]
+name = "hwrunner"
+version = "0.1.0"
+authors = ["Hedgewars Project"]
+edition = "2018"
+
+[dependencies]
+gfx = "0.17"
+glutin = "0.18"
+gfx_device_gl = "0.15"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/hwrunner/src/main.rs	Fri Nov 09 20:15:29 2018 +0300
@@ -0,0 +1,41 @@
+use glutin::{
+    dpi::LogicalSize,
+    Event,
+    WindowEvent,
+    EventsLoop,
+    GlWindow,
+};
+
+fn init(event_loop: &EventsLoop, size: LogicalSize) -> GlWindow {
+    use glutin::{
+        ContextBuilder,
+        WindowBuilder
+    };
+
+    let window = WindowBuilder::new()
+        .with_title("hwengine")
+        .with_dimensions(size);
+
+    let context = ContextBuilder::new();
+    GlWindow::new(window, context, event_loop).unwrap()
+}
+
+fn main() {
+    let mut event_loop = EventsLoop::new();
+    let window = init(&event_loop, LogicalSize::new(1024.0, 768.0));
+
+    let mut is_running = true;
+    while is_running {
+        event_loop.poll_events(|event| {
+            match event {
+                Event::WindowEvent { event, ..} => match event {
+                    WindowEvent::CloseRequested => {
+                        is_running = false;
+                    },
+                    _ => ()
+                },
+                _ => ()
+            }
+        })
+    }
+}