diff --git a/src/gl/align-gl.cpp b/src/gl/align-gl.cpp index b8963665d0..9c9ae82382 100644 --- a/src/gl/align-gl.cpp +++ b/src/gl/align-gl.cpp @@ -93,10 +93,6 @@ void align_gl::align_z_to_other(rs2::video_frame& aligned, auto extr = prof.get_extrinsics_to(other_profile); render(p, depth, intr, extr, aligned_tex); - - //aligned.get_data(); - aligned = _upload->process(aligned); - aligned = _upload->process(aligned); } // From: https://jamesgregson.blogspot.com/2011/11/matching-calibrated-cameras-with-opengl.html diff --git a/src/gl/colorizer-gl.cpp b/src/gl/colorizer-gl.cpp index fb70e763ea..ac01399381 100644 --- a/src/gl/colorizer-gl.cpp +++ b/src/gl/colorizer-gl.cpp @@ -252,50 +252,68 @@ namespace librealsense uint32_t depth_texture; uint32_t hist_texture = _cm_texture; + bool generate_depth_texture = false; + bool generate_histogram_texture = false; + const void *frame_data = nullptr; if (auto input_frame = f.as()) { depth_texture = input_frame.get_texture_id(0); - hist_texture = input_frame.get_texture_id(1); + + try + { + hist_texture = input_frame.get_texture_id(1); + } + catch(const std::exception& e) + { + LOG_DEBUG("Histogram Texture is not available. Generating one."); + generate_histogram_texture = true; + frame_data = input_frame.get_data(); + } } else + { + generate_depth_texture = true; + generate_histogram_texture = true; + frame_data = f.get_data(); + } + if (generate_depth_texture) { glGenTextures(1, &depth_texture); glBindTexture(GL_TEXTURE_2D, depth_texture); if (disparity) { - glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, _width, _height, 0, GL_RED, GL_FLOAT, f.get_data()); + glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, _width, _height, 0, GL_RED, GL_FLOAT, frame_data); } else { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RG8, _width, _height, 0, GL_RG, GL_UNSIGNED_BYTE, f.get_data()); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RG8, _width, _height, 0, GL_RG, GL_UNSIGNED_BYTE, frame_data); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + } + if (generate_histogram_texture && _equalize) + { + glGenTextures(1, &hist_texture); + glBindTexture(GL_TEXTURE_2D, hist_texture); - if (_equalize) + if (disparity) { - glGenTextures(1, &hist_texture); - glBindTexture(GL_TEXTURE_2D, hist_texture); - - if (disparity) - { - update_histogram(_hist_data, reinterpret_cast(f.get_data()), _width, _height); - populate_floating_histogram(_fhist_data, _hist_data); - glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, MAX_DISPARITY, 1, 0, GL_RED, GL_FLOAT, _fhist_data); - } - else - { - update_histogram(_hist_data, reinterpret_cast(f.get_data()), _width, _height); - populate_floating_histogram(_fhist_data, _hist_data); - glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, 0xFF, 0xFF, 0, GL_RED, GL_FLOAT, _fhist_data); - } - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + update_histogram(_hist_data, reinterpret_cast(frame_data), _width, _height); + populate_floating_histogram(_fhist_data, _hist_data); + glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, MAX_DISPARITY, 1, 0, GL_RED, GL_FLOAT, _fhist_data); } + else + { + update_histogram(_hist_data, reinterpret_cast(frame_data), _width, _height); + populate_floating_histogram(_fhist_data, _hist_data); + glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, 0xFF, 0xFF, 0, GL_RED, GL_FLOAT, _fhist_data); + } + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } if( auto gf = dynamic_cast< gpu_addon_interface * >( (frame_interface *)res.get() ) )