diff options
author | Clifford Wolf <clifford@clifford.at> | 2018-11-09 12:57:14 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2018-11-09 12:57:14 +0100 |
commit | 66dd17664c08aca17b53d2853558121aa9e702e4 (patch) | |
tree | b6bc5dd919e5f525ec7328861b81f616673a1ea6 /3rdparty/qtimgui/ImGuiRenderer.h | |
parent | e91241f10d68fcaaf0a81fa77e9a91666120ccee (diff) | |
parent | 15d9b3d3cc05656e58d01ba2f97ec92b6daaee1c (diff) | |
download | nextpnr-66dd17664c08aca17b53d2853558121aa9e702e4.tar.gz nextpnr-66dd17664c08aca17b53d2853558121aa9e702e4.tar.bz2 nextpnr-66dd17664c08aca17b53d2853558121aa9e702e4.zip |
Merge branch 'master' of github.com:YosysHQ/nextpnr into router_improve
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..8962c07b --- /dev/null +++ b/3rdparty/qtimgui/ImGuiRenderer.h @@ -0,0 +1,60 @@ +#pragma once + +#include <QOpenGLFunctions> +#include <QOpenGLFunctions_3_2_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_2_Core *g_fun = nullptr; +}; + +} |