RigsofRods
Soft-body Physics Simulation
OgreImGuiOverlay.h
Go to the documentation of this file.
1 // This file is part of the OGRE project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at https://www.ogre3d.org/licensing.
4 
5 #pragma once
6 
7 #include <OgreOverlay.h>
8 
9 #include <imgui.h>
10 
11 namespace Ogre
12 {
13 class ImGuiOverlay : public Overlay
14 {
15 public:
16  ImGuiOverlay();
17  ~ImGuiOverlay();
18 
21  ImFont* addFont(const String& name, const String& group OGRE_RESOURCE_GROUP_INIT);
22 
23  static void NewFrame(const FrameEvent& evt);
24 
25  void _findVisibleObjects(Camera* cam, RenderQueue* queue, Viewport* vp);
26 
27  void initialise(); // RIGSOFRODS: Private and non-virtual in OGRE... how does it even work?
28 
29 private:
30 
31  typedef std::vector<ImWchar> CodePointRange;
32  std::vector<CodePointRange> mCodePointRanges;
33 
34  class ImGUIRenderable : public Ogre::Renderable
35  {
36  public:
39 
40  void initialise();
41 
42  void updateVertexData(const ImVector<ImDrawVert>& vtxBuf, const ImVector<ImDrawIdx>& idxBuf);
43 
44  bool preRender(SceneManager* sm, RenderSystem* rsys);
45 
46  virtual void getWorldTransforms(Matrix4* xform) const { *xform = mXform; }
47  virtual void getRenderOperation(RenderOperation& op) { op = mRenderOp; }
48 
49  const LightList& getLights(void) const;
50 
51  void createMaterial();
52  void createFontTexture();
53 
54  const MaterialPtr& getMaterial() const { return mMaterial; }
55 
56  Real getSquaredViewDepth(const Camera*) const { return 0; }
57 
58  void _update();
59 
61 
62  Matrix4 mXform;
63  RenderOperation mRenderOp;
64  TexturePtr mFontTex;
65  MaterialPtr mMaterial;
66  };
67 
69 };
70 } // namespace Ogre
71 
Ogre::ImGuiOverlay::NewFrame
static void NewFrame(const FrameEvent &evt)
Definition: OgreImGuiOverlay.cpp:126
Ogre::ImGuiOverlay::ImGUIRenderable::~ImGUIRenderable
~ImGUIRenderable()
Definition: OgreImGuiOverlay.cpp:289
Ogre::ImGuiOverlay::CodePointRange
std::vector< ImWchar > CodePointRange
Definition: OgreImGuiOverlay.h:31
Ogre::ImGuiOverlay::ImGUIRenderable::updateVertexData
void updateVertexData(const ImVector< ImDrawVert > &vtxBuf, const ImVector< ImDrawIdx > &idxBuf)
Definition: OgreImGuiOverlay.cpp:295
Ogre::ImGuiOverlay::_findVisibleObjects
void _findVisibleObjects(Camera *cam, RenderQueue *queue, Viewport *vp)
Definition: OgreImGuiOverlay.cpp:48
Ogre::ImGuiOverlay::ImGUIRenderable::mXform
Matrix4 mXform
Definition: OgreImGuiOverlay.h:62
Ogre::ImGuiOverlay::addFont
ImFont * addFont(const String &name, const String &group OGRE_RESOURCE_GROUP_INIT)
add font from ogre .fontdef file must be called before first show()
Definition: OgreImGuiOverlay.cpp:77
Ogre::ImGuiOverlay
Definition: OgreImGuiOverlay.h:13
Ogre::ImGuiOverlay::ImGUIRenderable::preRender
bool preRender(SceneManager *sm, RenderSystem *rsys)
Definition: OgreImGuiOverlay.cpp:172
Ogre::ImGuiOverlay::ImGUIRenderable::getMaterial
const MaterialPtr & getMaterial() const
Definition: OgreImGuiOverlay.h:54
Ogre::ImGuiOverlay::mRenderable
ImGUIRenderable mRenderable
Definition: OgreImGuiOverlay.h:68
Ogre::ImGuiOverlay::ImGUIRenderable::createMaterial
void createMaterial()
Definition: OgreImGuiOverlay.cpp:57
Ogre::ImGuiOverlay::ImGUIRenderable::mConvertToBGR
bool mConvertToBGR
Definition: OgreImGuiOverlay.h:60
Ogre::ImGuiOverlay::ImGUIRenderable::getLights
const LightList & getLights(void) const
Definition: OgreImGuiOverlay.cpp:239
Ogre::ImGuiOverlay::ImGUIRenderable::getRenderOperation
virtual void getRenderOperation(RenderOperation &op)
Definition: OgreImGuiOverlay.h:47
Ogre::ImGuiOverlay::ImGUIRenderable::mRenderOp
RenderOperation mRenderOp
Definition: OgreImGuiOverlay.h:63
Ogre::ImGuiOverlay::~ImGuiOverlay
~ImGuiOverlay()
Definition: OgreImGuiOverlay.cpp:32
Ogre::ImGuiOverlay::ImGUIRenderable
Definition: OgreImGuiOverlay.h:34
Ogre::ImGuiOverlay::ImGUIRenderable::createFontTexture
void createFontTexture()
Definition: OgreImGuiOverlay.cpp:110
Ogre::ImGuiOverlay::ImGUIRenderable::getSquaredViewDepth
Real getSquaredViewDepth(const Camera *) const
Definition: OgreImGuiOverlay.h:56
Ogre::ImGuiOverlay::ImGUIRenderable::getWorldTransforms
virtual void getWorldTransforms(Matrix4 *xform) const
Definition: OgreImGuiOverlay.h:46
Ogre::ImGuiOverlay::ImGUIRenderable::_update
void _update()
Definition: OgreImGuiOverlay.cpp:146
Ogre::ImGuiOverlay::mCodePointRanges
std::vector< CodePointRange > mCodePointRanges
Definition: OgreImGuiOverlay.h:32
Ogre
Definition: ExtinguishableFireAffector.cpp:35
Ogre::ImGuiOverlay::ImGUIRenderable::ImGUIRenderable
ImGUIRenderable()
Definition: OgreImGuiOverlay.cpp:246
Ogre::ImGuiOverlay::ImGUIRenderable::mMaterial
MaterialPtr mMaterial
Definition: OgreImGuiOverlay.h:65
Ogre::ImGuiOverlay::ImGUIRenderable::mFontTex
TexturePtr mFontTex
Definition: OgreImGuiOverlay.h:64
Ogre::ImGuiOverlay::initialise
void initialise()
Definition: OgreImGuiOverlay.cpp:37
Ogre::ImGuiOverlay::ImGUIRenderable::initialise
void initialise()
Definition: OgreImGuiOverlay.cpp:258
Ogre::ImGuiOverlay::ImGuiOverlay
ImGuiOverlay()
Definition: OgreImGuiOverlay.cpp:25