robotology / idyntree

Multibody Dynamics Library designed for Free Floating Robots
BSD 3-Clause "New" or "Revised" License
156 stars 65 forks source link

Set resizable window on Windows #1070

Closed dariosortino closed 1 year ago

dariosortino commented 1 year ago

At the moment is impossible to resize the visualizer window in Windows OS.

With @S-Dafarra in https://github.com/robotology/human-dynamics-estimation/pull/341/files , we added the possibility to set the height and width of the window in a configuration file as a workaround to this, but it's not convenient if we keep switching between different screens with different resolutions.

cc @traversaro

S-Dafarra commented 1 year ago

I have tried adding setResizable(true) but as soon as the visualizer starts, the window shrinks and the visualization is messed up.

Investigating

traversaro commented 1 year ago

I have tried adding setResizable(true) but as soon as the visualizer starts, the window shrinks and the visualization is messed up.

Investigating

For testing you could try also to temporary revert https://github.com/robotology/idyntree/pull/976 (by commenting the line https://github.com/robotology/idyntree/blob/v8.1.0/src/visualization/src/Visualizer.cpp#L283) to see if without using SDL the resize on Windows works. If that works, we can think about exposing that so that we can opt-out of using SDL on Windows, as anyhow the problem reported in https://github.com/robotology/idyntree/issues/975 is not a problem if HumanStateVisualizer is a process just devoted to visualization .

S-Dafarra commented 1 year ago

I tried it, but it is still not usable. I think it may be a bug on the Windows implementation of irrlicht. I also tried following a bit https://irrlicht.sourceforge.io/forum/viewtopic.php?t=43316&sid=34c5d329ed5118c383d18231a046b4e9, but I had no luck. I am not able to change the size of the window from code.

S-Dafarra commented 1 year ago

I managed to make it working. Instead of removing that line, I had to change it to

irrDevParams.DeviceType = irr::EIDT_WIN32;
S-Dafarra commented 1 year ago

I tried it, but it is still not usable. I think it may be a bug on the Windows implementation of irrlicht. I also tried following a bit https://irrlicht.sourceforge.io/forum/viewtopic.php?t=43316&sid=34c5d329ed5118c383d18231a046b4e9, but I had no luck. I am not able to change the size of the window from code.

Actually, I did a mistake before, and I commented out the wrong lines. Indeed, the suggestion of @traversaro was correct. Now we can decide if we want to resize or close the window :joy:

traversaro commented 1 year ago

Cool! While we thing how to do this properly @dariosortino I think you can do the local modification suggested in https://github.com/robotology/idyntree/issues/1070#issuecomment-1532723289 and tested by @S-Dafarra in your system/the system used for the demo, so that for future them you can already resize the window, right?

S-Dafarra commented 1 year ago

While we thing how to do this properly

What about creating a window on our own and have irrlicht printing on it? In this way we might be able to deal with the closure more easily. I have been using glfw in the past and it might also be a quite portable solution. @traversaro what do you think?

S-Dafarra commented 1 year ago

While we thing how to do this properly

What about creating a window on our own and have irrlicht printing on it? In this way we might be able to deal with the closure more easily. I have been using glfw in the past and it might also be a quite portable solution. @traversaro what do you think?

I have quickly tried, but no inputs are received by the engine. I probably need to pass custom events via postEventFromUser

S-Dafarra commented 1 year ago

I have started having some results with the custom window, without the mouse inputs. Here the commit https://github.com/S-Dafarra/idyntree/tree/test_visualization

Funny story. If I run the test where I use two visualizer, the entire graphical system of my PC crashes :sweat_smile:

S-Dafarra commented 1 year ago

Funny story. If I run the test where I use two visualizer, the entire graphical system of my PC crashes

Actually, I was testing an old version in my PC cause I forgot to install :sweat: It seems to be working now after removing this line https://github.com/S-Dafarra/idyntree/blob/212fdb017a6922404b7af3362c1e81f375530ae1/src/visualization/src/Visualizer.cpp#L830

S-Dafarra commented 1 year ago

With https://github.com/S-Dafarra/idyntree/commit/2ed1e973c99f55e39e8a4a40f80043be052020ce I managed to have mouse inputs working. Hence, I should have recovered all the features. I need to test it on Windows