I want to create two views in opengl and then switch between both of them depending on a gui option.
If I select that option in gui, then view 1 should be visible otherwise view 2 should be visible.
(I am basically using Pangolin library which uses opengl in the background)
My code is as below :
// view 1
pangolin::OpenGlRenderState camera1 = pangolin::OpenGlRenderState(
pangolin::ProjectionMatrix(w, h, 400, 400, w / 2.0, h / 2.0, 0.1,
10000),
pangolin::ModelViewLookAt(15, 5, 10, 0, 0, 0, pangolin::AxisY));
pangolin::View& view1 =
pangolin::CreateDisplay().SetBounds(0.0, 1.0, 0, 1.0,
-w / static_cast<float>(h));
auto* handler = new pangolin::Handler3D(camera1);
view1.SetHandler(handler);
// view 2
pangolin::OpenGlRenderState camera2 = pangolin::OpenGlRenderState(
pangolin::ProjectionMatrix(w, h, 400, 400, w / 2.0, h / 2.0, 0.1,
10000),
pangolin::ModelViewLookAt(15, 5, 10, 0, 0, 0, pangolin::AxisY));
pangolin::View& view2 =
pangolin::CreateDisplay().SetBounds(0.0, 1.0, 0, 1.0,
-w / static_cast<float>(h));
view2.SetHandler(new pangolin::Handler3D(camera2));
if(option){
view1.Activate(camera1);
}
else
{
camera2.SetModelViewMatrix(pangolin::ModelViewLookAt(camDistFromCenter, 5, camDistFromCenter, 0, 0, 0, pangolin::AxisY));
view2.Activate(camera2);
}
I am able to switch between the two views but the problem is that the gui is not interactive anymore. I am not able to rotate or zoom in or out.