OpenSceneGraph
OpenSceneGraph copied to clipboard
osgGA::GUIEventAdapter::getWindowHeight() returns different values in ::MOVE and in ::FRAME events
In the ::MOVE event it returns the correct window height, but in ::FRAME it returns the initial value of _windowHeight (1024).
I need it in ::FRAME in order to debounce mouse events, so I only process one per frame and avoid running expensive computations multiple times per frame.
Here is a minimal repro case:
#include <iostream>
#include <osg/Group>
#include <osgViewer/Viewer>
class MyHandler : public osgGA::GUIEventHandler {
virtual bool handle(const osgGA::GUIEventAdapter &ea,
osgGA::GUIActionAdapter &aa) override {
switch (ea.getEventType()) {
case osgGA::GUIEventAdapter::MOVE: {
std::cout << "IN MOVE " << ea.getWindowHeight() << std::endl;
break;
}
case osgGA::GUIEventAdapter::FRAME: {
std::cout << "IN FRAME " << ea.getWindowHeight() << std::endl;
break;
}
default:
return false;
}
return true;
}
};
// Compiled with: g++ main.cc -losg -losgViewer -losgGA
int main() {
osgViewer::Viewer viewer;
viewer.addEventHandler(new MyHandler);
while (!viewer.done()) {
viewer.frame();
}
return 0;
}