diff --git a/src/graphics_imgui.rs b/src/graphics_imgui.rs index 65bc99f5e3..5a17db53e6 100644 --- a/src/graphics_imgui.rs +++ b/src/graphics_imgui.rs @@ -53,11 +53,16 @@ pub fn run(capture_provider: Arc, calibration_data: k4a_sys::k4 let gl_texture_id = load_texture("n64logo.png"); let imgui_texture_id = TextureId::from(gl_texture_id as usize); + let mut visualizer = PointCloudVisualizer::new( true, calibration_data ); + let mut gl_texture_id_3 = load_texture("sneslogo.png"); + let mut imgui_texture_id_3 = TextureId::from(gl_texture_id_3 as usize); + + rebinder.restore(); let mut texture = ViewerImage::create( @@ -118,10 +123,13 @@ pub fn run(capture_provider: Arc, calibration_data: k4a_sys::k4 ui.separator(); Image::new(imgui_texture_id, [100.0, 100.0]).build(&ui); - ui.separator(); Image::new(imgui_texture_id_2, [100.0, 100.0]).build(&ui); + ui.separator(); + + Image::new(imgui_texture_id_3, [100.0, 100.0]).build(&ui); + ui.separator(); unsafe { gl::ClearColor(0.2, 0.2, 0.2, 1.0); @@ -134,7 +142,7 @@ pub fn run(capture_provider: Arc, calibration_data: k4a_sys::k4 window.gl_swap_window(); if let Some(capture) = capture_provider.get_capture() { - visualizer.update_texture(&texture, capture) + visualizer.update_texture_id(gl_texture_id_3, capture) .map(|_| { println!("UPDATED TEXTURE!"); }) @@ -155,8 +163,7 @@ pub fn run(capture_provider: Arc, calibration_data: k4a_sys::k4 } } - -fn asdf(capture_provider: Arc, calibration_data: k4a_sys::k4a_calibration_t) { +/*fn asdf(capture_provider: Arc, calibration_data: k4a_sys::k4a_calibration_t) { let system = support::init(file!()); let context = system.display.get_context(); @@ -329,4 +336,4 @@ fn asdf(capture_provider: Arc, calibration_data: k4a_sys::k4a_c //gl_window.swap_buffers().unwrap(); } }); -} \ No newline at end of file +}*/ diff --git a/src/point_cloud/point_cloud_visualiser.rs b/src/point_cloud/point_cloud_visualiser.rs index 0785541496..747b3d9f67 100644 --- a/src/point_cloud/point_cloud_visualiser.rs +++ b/src/point_cloud/point_cloud_visualiser.rs @@ -1,19 +1,20 @@ //! Based off Microsoft's MIT-licensed k4a library code and examples, specifically //! `k4apointcloudvisualizer.h` -use point_cloud::point_cloud_renderer_shader::{PointCloudRendererShader, PointCloudRendererError}; -use k4a_sys_wrapper::{Capture, Transformation}; +use gl::types::*; use k4a_sys_wrapper::Image; use k4a_sys_wrapper::ImageFormat; -use opengl_wrapper::{Texture, Renderbuffer, Framebuffer}; -use point_cloud::point_cloud_compute_shader::{PointCloudComputeShader, PointCloudComputeError}; -use std::fmt::{Error, Formatter}; +use k4a_sys_wrapper::{Capture, Transformation}; use opengl_wrapper::OpenGlError; +use opengl_wrapper::{Texture, Renderbuffer, Framebuffer}; use point_cloud::pixel_structs::BgraPixel; use point_cloud::pixel_structs::DepthPixel; -use std::mem::size_of; +use point_cloud::point_cloud_compute_shader::{PointCloudComputeShader, PointCloudComputeError}; +use point_cloud::point_cloud_renderer_shader::{PointCloudRendererShader, PointCloudRendererError}; use point_cloud::viewer_image::ViewerImage; use rand::Rng; +use std::fmt::{Error, Formatter}; +use std::mem::size_of; pub type Result = std::result::Result; @@ -213,6 +214,10 @@ impl PointCloudVisualizer { } pub fn update_texture(&mut self, texture: &ViewerImage, capture: Capture) -> Result<()> { + self.update_texture_id(texture.texture_id(), capture) + } + + pub fn update_texture_id(&mut self, texture_id: GLuint, capture: Capture) -> Result<()> { println!("==== Visualizer.update_texture()"); // Update the point cloud renderer with the latest point data @@ -235,7 +240,7 @@ impl PointCloudVisualizer { // TODO: // glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, static_cast(**texture), 0); // gl::FramebufferTexture(gl::FRAMEBUFFER, gl::COLOR_ATTACHMENT0, texture_buffer, 0); - gl::FramebufferTexture(gl::FRAMEBUFFER, gl::COLOR_ATTACHMENT0, texture.texture_id(), 0); + gl::FramebufferTexture(gl::FRAMEBUFFER, gl::COLOR_ATTACHMENT0, texture_id, 0); // DrawBuffers writes to a COLOR BUFFER //