From 910b68617bd89bcc63a44bb1b4eff95aa7128383 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 12 Apr 2020 20:44:27 -0400 Subject: [PATCH] unpack from captureprovider --- src/graphics_grr.rs | 21 +++++++++++++++++++-- src/main.rs | 4 ++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/graphics_grr.rs b/src/graphics_grr.rs index 7d4cbba8ec..936362c302 100644 --- a/src/graphics_grr.rs +++ b/src/graphics_grr.rs @@ -2,6 +2,8 @@ use glutin::dpi::LogicalSize; use grr; use std::path::Path; +use sensor_control::CaptureProvider; +use std::sync::Arc; const VERTEX_SRC: &str = r#" #version 450 core @@ -33,7 +35,7 @@ const VERTICES: [f32; 16] = [ const INDICES: [u16; 6] = [0, 1, 2, 2, 3, 0]; -pub fn run() -> grr::Result<()> { +pub fn run(capture_provider: Arc) -> grr::Result<()> { unsafe { let mut events_loop = glutin::EventsLoop::new(); let wb = glutin::WindowBuilder::new() @@ -138,7 +140,7 @@ pub fn run() -> grr::Result<()> { }, ); - let texture_view = grr.create_image_view( + let mut texture_view = grr.create_image_view( texture, grr::ImageViewType::D2, grr::Format::R8G8B8A8_SRGB, @@ -179,6 +181,8 @@ pub fn run() -> grr::Result<()> { }], }; + //let mut my_buffer = grr.create_buffer(640000, grr::MemoryFlags::DYNAMIC)?; + let mut running = true; while running { events_loop.poll_events(|event| match event { @@ -195,6 +199,19 @@ pub fn run() -> grr::Result<()> { _ => (), }); + // TODO: This belongs in a worker thread with buffers on both producer and consumer. + if let Some(capture) = capture_provider.get_capture() { + if let Ok(image) = capture.get_depth_image() { + let width = image.get_width_pixels(); + let height = image.get_height_pixels(); + println!("Size: {}x{}", width, height); + + //let buffer = image.get_buffer(); + + + } + } + grr.bind_pipeline(pipeline); grr.bind_vertex_array(vertex_array); grr.bind_color_blend_state(&color_blend); diff --git a/src/main.rs b/src/main.rs index 42c47b1179..e7d28e737d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,8 +62,8 @@ pub fn main() { let capture_provider = Arc::new(CaptureProvider::new()); let capture_provider2= capture_provider.clone(); - thread::spawn(move || capture_thread(capture_provider2)); + thread::spawn(move || capture_thread(capture_provider)); - graphics_grr::run().unwrap(); + graphics_grr::run(capture_provider2).unwrap(); //graphics_glium::run_glium(); }