Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osgGA::GUIEventAdapter::getWindowHeight() returns different values in ::MOVE and in ::FRAME events #1241

Open
rubenlg opened this issue Jul 6, 2023 · 0 comments

Comments

@rubenlg
Copy link

rubenlg commented Jul 6, 2023

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant