Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
OgreImGui.h
Go to the documentation of this file.
1
2// -------------------------------------------
3// OGRE-IMGUI bindings
4// See file 'README-OgreImGui.txt' for details
5// -------------------------------------------
6
7/*
8 This source file is part of Rigs of Rods
9 Copyright 2016-2020 Petr Ohlidal
10
11 For more information, see http://www.rigsofrods.org/
12
13 Rigs of Rods is free software: you can redistribute it and/or modify
14 it under the terms of the GNU General Public License version 3, as
15 published by the Free Software Foundation.
16
17 Rigs of Rods is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
24*/
25
26#pragma once
27
28#include "OgreImGuiOverlay.h" // RoR's ported version
29
30#include <imgui.h>
31#include <Ogre.h>
32#include <OISMouse.h>
33#include <OISKeyboard.h>
34#include <memory>
35
36// DearIMGUI math functions, copypasted from <imgui_internal.h>
37static inline ImVec2 operator*(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x*rhs, lhs.y*rhs); }
38static inline ImVec2 operator/(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x/rhs, lhs.y/rhs); }
39static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); }
40static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x-rhs.x, lhs.y-rhs.y); }
41static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x*rhs.x, lhs.y*rhs.y); }
42static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x/rhs.x, lhs.y/rhs.y); }
43static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; }
44static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
45static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
46static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
47
54class OgreImGui: public Ogre::RenderQueueListener
55{
56public:
57 void Init();
58
59 // Input-injecting functions
60 void InjectMouseMoved( const OIS::MouseEvent &arg );
61 void SetMouseButtonState(OIS::MouseButtonID id, bool down);
63 void InjectKeyPressed( const OIS::KeyEvent &arg );
64 void InjectKeyReleased( const OIS::KeyEvent &arg );
65
66 // Ogre::RenderQueueListener
67 virtual void renderQueueStarted(Ogre::uint8 queueGroupId,
68 const Ogre::String& invocation, bool& skipThisInvocation) override;
69
70private:
71 std::unique_ptr<Ogre::ImGuiOverlay> m_imgui_overlay;
72};
static ImVec2 operator+(const ImVec2 &lhs, const ImVec2 &rhs)
Definition OgreImGui.h:39
static ImVec2 operator*(const ImVec2 &lhs, const float rhs)
Definition OgreImGui.h:37
static ImVec2 operator-(const ImVec2 &lhs, const ImVec2 &rhs)
Definition OgreImGui.h:40
static ImVec2 operator/(const ImVec2 &lhs, const float rhs)
Definition OgreImGui.h:38
static ImVec2 & operator/=(ImVec2 &lhs, const float rhs)
Definition OgreImGui.h:46
static ImVec2 & operator*=(ImVec2 &lhs, const float rhs)
Definition OgreImGui.h:45
static ImVec2 & operator-=(ImVec2 &lhs, const ImVec2 &rhs)
Definition OgreImGui.h:44
static ImVec2 & operator+=(ImVec2 &lhs, const ImVec2 &rhs)
Definition OgreImGui.h:43
DearIMGUI integration.
Definition OgreImGui.h:55
void InjectKeyReleased(const OIS::KeyEvent &arg)
void InjectMouseMoved(const OIS::MouseEvent &arg)
Definition OgreImGui.cpp:89
void ResetAllMouseButtons()
void SetMouseButtonState(OIS::MouseButtonID id, bool down)
Definition OgreImGui.cpp:99
void Init()
Definition OgreImGui.cpp:38
void InjectKeyPressed(const OIS::KeyEvent &arg)
virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation) override
std::unique_ptr< Ogre::ImGuiOverlay > m_imgui_overlay
Definition OgreImGui.h:71