1010#include < fstream>
1111#include < algorithm>
1212#include < cstring>
13+ #include " imgui_impl_glfw.h"
14+ #include < imgui_impl_opengl3.h>
15+ #include < realsense_imgui.h>
1316
1417void render_slider (rect location, float & clipping_dist);
1518void remove_background (rs2::video_frame& other, const rs2::depth_frame& depth_frame, float depth_scale, float clipping_dist);
@@ -24,7 +27,11 @@ int main(int argc, char * argv[]) try
2427
2528 // Create and initialize GUI related objects
2629 window app (1280 , 720 , " RealSense Align (Advanced) Example" ); // Simple window handling
27- ImGui_ImplGlfw_Init (app, false ); // ImGui library intializition
30+ // Setup Dear ImGui context
31+ ImGui::CreateContext ();
32+ // Setup Platform/Renderer backends
33+ ImGui_ImplGlfw_InitForOpenGL (app, true );
34+ ImGui_ImplOpenGL3_Init ();
2835 rs2::colorizer c; // Helper to colorize depth images
2936 texture renderer; // Helper for renderig images
3037
@@ -109,11 +116,18 @@ int main(int argc, char * argv[]) try
109116 renderer.show (pip_stream);
110117
111118 // Using ImGui library to provide a slide controller to select the depth clipping distance
112- ImGui_ImplGlfw_NewFrame (1 );
119+ ImGui_ImplOpenGL3_NewFrame ();
120+ ImGui_ImplGlfw_NewFrame ();
121+ ImGui::NewFrame ();
113122 render_slider ({ 5 .f , 0 , w, h }, depth_clipping_distance);
114123 ImGui::Render ();
124+ ImGui_ImplOpenGL3_RenderDrawData (ImGui::GetDrawData ());
115125
116126 }
127+ // Cleanup
128+ ImGui_ImplOpenGL3_Shutdown ();
129+ ImGui_ImplGlfw_Shutdown ();
130+ ImGui::DestroyContext ();
117131 return EXIT_SUCCESS;
118132}
119133catch (const rs2::error & e)
@@ -158,11 +172,11 @@ void render_slider(rect location, float& clipping_dist)
158172
159173 // Render the vertical slider
160174 ImGui::Begin (" slider" , nullptr , flags);
161- ImGui::PushStyleColor (ImGuiCol_FrameBg, ImColor ( 215 . f / 255 , 215 . 0f / 255 , 215 .0f / 255 ));
162- ImGui::PushStyleColor (ImGuiCol_SliderGrab, ImColor ( 215 .f / 255 , 215 .0f / 255 , 215 .0f / 255 ) );
163- ImGui::PushStyleColor (ImGuiCol_SliderGrabActive, ImColor ( 215 .f / 255 , 215 .0f / 255 , 215 .0f / 255 ) );
175+ ImGui::PushStyleColor (ImGuiCol_FrameBg, ImVec4 ( 0 . 2f , 0 . 3f , 0 . 7f , 1 .0f ));
176+ ImGui::PushStyleColor (ImGuiCol_SliderGrab, { 215 .f / 255 , 215 .0f / 255 , 215 .0f / 255 , 1 } );
177+ ImGui::PushStyleColor (ImGuiCol_SliderGrabActive, { 215 .f / 255 , 215 .0f / 255 , 215 .0f / 255 , 1 } );
164178 auto slider_size = ImVec2 (slider_window_width / 2 , location.h - (pixels_to_buttom_of_stream_text * 2 ) - 20 );
165- ImGui::VSliderFloat (" " , slider_size, &clipping_dist, 0 .0f , 6 .0f , " " , 1 . 0f , true );
179+ ImGui::VSliderFloat (" ##vslider " , slider_size, &clipping_dist, 0 .0f , 6 .0f ," % .2f " );
166180 if (ImGui::IsItemHovered ())
167181 ImGui::SetTooltip (" Depth Clipping Distance: %.3f" , clipping_dist);
168182 ImGui::PopStyleColor (3 );
0 commit comments