From 986029e65c732d735deff1441868151eb7d51fad Mon Sep 17 00:00:00 2001 From: bnewbold Date: Sun, 12 Jun 2016 14:04:31 -0400 Subject: initial from_existing_window() glutin stuff --- src/main.rs | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 6369ad9..f393f9d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,10 @@ #[macro_use] extern crate glium; extern crate image; + +use std::env; +use std::u64; +use glium::glutin::os::unix::WindowBuilderExt; mod util; mod cow_vertex; @@ -12,18 +16,22 @@ mod cow_horns; mod cow_tail; mod cow_udder; -fn run() { +fn run(window_id: Option) { use glium::{DisplayBuild, Surface}; let mut t: f32 = 0.0; let mut z: f32; - - let display = glium::glutin::WindowBuilder::new() - .with_title(format!("Exuberant Cow!")) - .with_depth_buffer(24) - .build_glium() - .unwrap(); + + let win_builder: glium::glutin::WindowBuilder = match window_id { + Some(id) => + glium::glutin::WindowBuilder::new() + .from_existing_window(id), + None => glium::glutin::WindowBuilder::new() + .with_title(format!("Exuberant Cow!")) + .with_depth_buffer(24), + }; + let display = win_builder.build_glium().unwrap(); let indices = glium::index::NoIndices(glium::index::PrimitiveType::TrianglesList); @@ -175,5 +183,20 @@ fn run() { } fn main() { - run(); + let args: Vec = env::args().collect(); + + let window_id: Option = { + if args.len() >= 2 { + let parsed = if (&args[1]).starts_with("0x") { + u64::from_str_radix(args[1].trim_left_matches('0').trim_left_matches('x'), 16) + } else { + args[1].parse::() + }; + Some(parsed.expect("Failed to parse numerical arg")) + } else { + None + } + }; + + run(window_id); } -- cgit v1.2.3