From 7352f3f6d287533d68bebc1008f7167f8014e624 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Fri, 14 Aug 2020 04:01:30 -0400 Subject: [PATCH] cleanup; pink was due to missing "layout(location=10)" --- src/point_cloud/point_cloud_renderer.rs | 67 +++++++------------------ 1 file changed, 18 insertions(+), 49 deletions(-) diff --git a/src/point_cloud/point_cloud_renderer.rs b/src/point_cloud/point_cloud_renderer.rs index 6ec6dee63c..742179a42b 100644 --- a/src/point_cloud/point_cloud_renderer.rs +++ b/src/point_cloud/point_cloud_renderer.rs @@ -62,8 +62,8 @@ pub static POINT_CLOUD_VERTEX_SHADER : &'static str = "\ #version 430 // NB: It appears that locations need to be wide enough apart, or the colors bleed across locations. -in vec4 inColor0; -in vec4 inColor1; +layout(location=0) in vec4 inColor0; +layout(location=10) in vec4 inColor1; out vec4 vertexColor; @@ -515,9 +515,9 @@ impl PointCloudRenderer { gl::UseProgram(self.shader_program_id); } - for j in 0 .. color_images.len() { - let color_image = color_images.get(j).unwrap(); - let point_cloud_texture = point_cloud_textures.get(j).unwrap(); + for i in 0 .. self.num_cameras { + let color_image = color_images.get(i).unwrap(); + let point_cloud_texture = point_cloud_textures.get(i).unwrap(); // NB: This experiment demonstrates that only one set of texture (colors) seem to be updated. // let i = if seconds % 10 > 4 { @@ -532,7 +532,6 @@ impl PointCloudRenderer { //let i = 1 - j; //geometry2, cameratexture2 (below is i=j) //let i = j; // geometry2, cameratexture1, (below is i=1-j) //let i = 1 - j; //geometry1, cameratexture2 (below is i=1-j) - let i = j; //let i = if swap { j } else { 1 - j }; // swaps which image data is used let vertex_array_object = self.vertex_array_objects.get(i).unwrap(); @@ -577,8 +576,6 @@ impl PointCloudRenderer { let color_src = color_image.get_buffer(); let typed_color_src = color_src as *const u8; - //let mut typed_color_src = color_src as *const BgraPixel; - //let length = color_image.get_width_pixels() * color_image.get_height_pixels(); let result = unsafe { if i == 9 { @@ -604,50 +601,23 @@ impl PointCloudRenderer { // a single index, only one of the camera geometries gets shaded. //let i = j; // (SEE TABLE ABOVE) //let i = 1 - j; // (SEE TABLE ABOVE) - let i = j; //let i = if !swap { j } else { 1 - j }; // (in isolation) PUTS THE IMAGES ON BOTH POINTCLOUD GEOS!? - unsafe { - if !do_break { - //let i = 1 - j; // face image -> room geo - let vertex_attrib_location = self.vertex_attrib_locations.get(i).unwrap(); + let vertex_attrib_location = self.vertex_attrib_locations.get(i).unwrap(); - // NB: Controling these indices change where the color bytes are uploaded - gl::EnableVertexAttribArray(*vertex_attrib_location as u32); + // NB: Controling these indices change where the color bytes are uploaded + gl::EnableVertexAttribArray(*vertex_attrib_location as u32); - //let location = i; - gl::VertexAttribPointer( - *vertex_attrib_location as u32, - //location as u32, // TODO: Does this matter? - gl::BGRA as i32, - gl::UNSIGNED_BYTE, - gl::TRUE, - //get_stride::(0), - //get_pointer_offset::(0), - 0 as i32, - 0 as *const c_void, - ); - } else { - //let i = 1 - j; // face image -> room geo - let vertex_attrib_location = self.vertex_attrib_locations.get(i).unwrap(); - - // NB: Controling these indices change where the color bytes are uploaded - gl::EnableVertexAttribArray(*vertex_attrib_location as u32); - - //let location = i; - gl::VertexAttribPointer( - *vertex_attrib_location as u32, - //location as u32, // TODO: Does this matter? - gl::BGRA as i32, - gl::UNSIGNED_BYTE, - gl::TRUE, - //get_stride::(0), - //get_pointer_offset::(0), - 0 as i32, - 0 as *const c_void, - ); - } + //let location = i; + gl::VertexAttribPointer( + *vertex_attrib_location as u32, + gl::BGRA as i32, + gl::UNSIGNED_BYTE, + gl::TRUE, + 0 as i32, + 0 as *const c_void, + ); // NB: I believe these point cloud textures are the geometry itself. Not the color data. // I think the code here is *fine* because the point cloud structures are in-tact. @@ -658,7 +628,6 @@ impl PointCloudRenderer { //if i == 1 { continue } //let i = 1 - j; //let i = if swap { j } else { 1 - j }; // swaps physical location of the geometry - let i = j; // // NB: it's okay to copy an i32, but this sucks // let point_cloud_texture_index = self.point_cloud_texture_indices.get(i).unwrap().clone(); @@ -671,7 +640,7 @@ impl PointCloudRenderer { gl::BindTexture(gl::TEXTURE_2D, point_cloud_texture.id()); gl::BindImageTexture( // https://www.khronos.org/opengl/wiki/Sampler_(GLSL) ? - i as GLuint, // image unit (zero-indexed) + i as GLuint, // image unit (zero-indexed) // TODO - why? why does it work this way? point_cloud_texture.id(), // texture 0, // level gl::FALSE, // layered