Connect ImGui render to QOpenGLWidgets

This commit is contained in:
Dan Paulat 2022-11-20 22:12:05 -06:00
parent 3c69ad28c6
commit dd1b4f27c8
4 changed files with 76 additions and 6 deletions

View file

@ -13,6 +13,8 @@
#include <scwx/util/threads.hpp>
#include <scwx/util/time.hpp>
#include <backends/imgui_impl_opengl3.h>
#include <imgui.h>
#include <QApplication>
#include <QColor>
#include <QDebug>
@ -682,10 +684,24 @@ void MapWidget::initializeGL()
void MapWidget::paintGL()
{
p->frameDraws_++;
// Setup ImGui Frame
ImGui::GetIO().DisplaySize = {static_cast<float>(size().width()),
static_cast<float>(size().height())};
// Start ImGui Frame
ImGui_ImplOpenGL3_NewFrame();
ImGui::NewFrame();
// Render QMapLibreGL Map
p->map_->resize(size());
p->map_->setFramebufferObject(defaultFramebufferObject(),
size() * pixelRatio());
p->map_->render();
// Render ImGui Frame
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
}
void MapWidget::mapChanged(QMapLibreGL::Map::MapChange mapChange)