aboutsummaryrefslogtreecommitdiffstats
path: root/3rdparty/qtimgui/ImGuiRenderer.h
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/qtimgui/ImGuiRenderer.h')
-rw-r--r--3rdparty/qtimgui/ImGuiRenderer.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/3rdparty/qtimgui/ImGuiRenderer.h b/3rdparty/qtimgui/ImGuiRenderer.h
new file mode 100644
index 00000000..ca69ffaa
--- /dev/null
+++ b/3rdparty/qtimgui/ImGuiRenderer.h
@@ -0,0 +1,58 @@
+#pragma once
+
+#include <QOpenGLExtraFunctions>
+#include <QObject>
+#include <QPoint>
+#include <imgui.h>
+#include <memory>
+
+class QMouseEvent;
+class QWheelEvent;
+class QKeyEvent;
+
+namespace QtImGui {
+
+class WindowWrapper {
+public:
+ virtual ~WindowWrapper() {}
+ virtual void installEventFilter(QObject *object) = 0;
+ virtual QSize size() const = 0;
+ virtual qreal devicePixelRatio() const = 0;
+ virtual bool isActive() const = 0;
+ virtual QPoint mapFromGlobal(const QPoint &p) const = 0;
+};
+
+class ImGuiRenderer : public QObject, QOpenGLExtraFunctions {
+ Q_OBJECT
+public:
+ void initialize(WindowWrapper *window);
+ void newFrame();
+
+ bool eventFilter(QObject *watched, QEvent *event);
+
+ static ImGuiRenderer *instance();
+
+private:
+ ImGuiRenderer() {}
+
+ void onMousePressedChange(QMouseEvent *event);
+ void onWheel(QWheelEvent *event);
+ void onKeyPressRelease(QKeyEvent *event);
+
+ void renderDrawList(ImDrawData *draw_data);
+ bool createFontsTexture();
+ bool createDeviceObjects();
+
+ std::unique_ptr<WindowWrapper> m_window;
+ double g_Time = 0.0f;
+ bool g_MousePressed[3] = { false, false, false };
+ float g_MouseWheel;
+ float g_MouseWheelH;
+ GLuint g_FontTexture = 0;
+ int g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
+ int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0;
+ int g_AttribLocationPosition = 0, g_AttribLocationUV = 0, g_AttribLocationColor = 0;
+ unsigned int g_VboHandle = 0, g_VaoHandle = 0, g_ElementsHandle = 0;
+};
+
+}