opensurgsim
OsgImGuiHandler.h
1 #ifndef OSGIMGUIHANDLER_H
2 #define OSGIMGUIHANDLER_H
3 
4 // Source https://github.com/Tordan/imgui-osg
5 
6 #include <osgViewer/ViewerEventHandlers>
7 
8 namespace osg {
9 class Camera;
10 }
11 
12 class OsgImGuiHandler : public osgGA::GUIEventHandler
13 {
14 public:
16 
17  bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) override;
18 
19 protected:
20  // Put your ImGui code inside this function
21  virtual void drawUi() = 0;
22 
23 private:
24  void init();
25 
26  void setCameraCallbacks(osg::Camera* camera);
27 
28  void newFrame(osg::RenderInfo& renderInfo);
29 
30  void render(osg::RenderInfo& renderInfo);
31 
32 private:
33  struct ImGuiNewFrameCallback;
34  struct ImGuiRenderCallback;
35 
36  double time_;
37  bool mousePressed_[3];
38  float mouseWheel_;
39  bool initialized_;
40 };
41 
42 #endif
Definition: OsgImGuiHandler.cpp:28
Definition: OsgImGuiHandler.cpp:12
Definition: OsgImGuiHandler.h:12
Definition: OsgImGuiHandler.h:8