diff options
author | Miodrag Milanović <mmicko@gmail.com> | 2018-10-26 17:27:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-26 17:27:47 +0200 |
commit | 757dcd2a5277ef65d9ce4ff7b118e6072edbb71a (patch) | |
tree | 27c31559c02d6fb8e57d032f54daf190591e61e0 /3rdparty/qtimgui/ImGuiRenderer.h | |
parent | 40a8e17db63ec0fea417f6fc1b1711ddbdec5330 (diff) | |
parent | 62a615a17d9b69f3b727d59ed13e297ace610778 (diff) | |
download | nextpnr-757dcd2a5277ef65d9ce4ff7b118e6072edbb71a.tar.gz nextpnr-757dcd2a5277ef65d9ce4ff7b118e6072edbb71a.tar.bz2 nextpnr-757dcd2a5277ef65d9ce4ff7b118e6072edbb71a.zip |
Merge pull request #96 from YosysHQ/imgui
Imgui integration
Diffstat (limited to '3rdparty/qtimgui/ImGuiRenderer.h')
-rw-r--r-- | 3rdparty/qtimgui/ImGuiRenderer.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/3rdparty/qtimgui/ImGuiRenderer.h b/3rdparty/qtimgui/ImGuiRenderer.h new file mode 100644 index 00000000..f0d7315e --- /dev/null +++ b/3rdparty/qtimgui/ImGuiRenderer.h @@ -0,0 +1,60 @@ +#pragma once + +#include <QOpenGLFunctions> +#include <QOpenGLFunctions_3_3_Core> +#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, QOpenGLFunctions { + 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; + QOpenGLFunctions_3_3_Core *g_fun = nullptr; +}; + +} |