From d578a60a0ca7685e614830e150dfc2908cdd4f4b Mon Sep 17 00:00:00 2001 From: k-a-z-u Date: Wed, 4 Apr 2018 11:00:57 +0200 Subject: [PATCH] fixed openGL issues --- mapview/3D/MapView3D.cpp | 19 +++++++++++++++---- mapview/3D/MapView3D.h | 2 ++ mapview/3D/misc/Shader.cpp | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/mapview/3D/MapView3D.cpp b/mapview/3D/MapView3D.cpp index f737555..b0a6c0e 100644 --- a/mapview/3D/MapView3D.cpp +++ b/mapview/3D/MapView3D.cpp @@ -102,17 +102,16 @@ MapView3D::MapView3D(QWidget *parent) : QOpenGLWidget(parent) { grabGesture(Qt::PinchGesture); auto format = QSurfaceFormat(); - format.setRenderableType(QSurfaceFormat::OpenGLES); - format.setVersion(3, 0); + format.setRenderableType(QSurfaceFormat::OpenGL); + format.setVersion(3, 4); //format.setSamples(2); auto ver = format.version(); std::cout << ver.first << " " << ver.second << std::endl; - format.setProfile(QSurfaceFormat::CoreProfile); + format.setProfile(QSurfaceFormat::CompatibilityProfile); format.setOption(QSurfaceFormat::DebugContext); setFormat(format); - } @@ -131,6 +130,18 @@ void MapView3D::initializeGL() { // additional settings glEnable(GL_DEPTH_TEST); glClearColor(0.5, 0.5, 0.5, 1.0); + + //QOpenGLContext* ctx = QOpenGLContext::currentContext(); + logger = new QOpenGLDebugLogger(this); + if (logger->initialize()) { + + connect(logger, &QOpenGLDebugLogger::messageLogged, [] (const QOpenGLDebugMessage& debugMessage) { + std::cout << debugMessage.message().toStdString() << std::endl; + }); + logger->startLogging(QOpenGLDebugLogger::SynchronousLogging); + + } + } void MapView3D::paintGL() { diff --git a/mapview/3D/MapView3D.h b/mapview/3D/MapView3D.h index 6092649..ffe4a2a 100644 --- a/mapview/3D/MapView3D.h +++ b/mapview/3D/MapView3D.h @@ -24,6 +24,8 @@ class MapView3D : public QOpenGLWidget, protected QOpenGLFunctions { bool usePerspectiveProjection = false; bool useWireframe = false; + QOpenGLDebugLogger* logger = nullptr; + public: MapView3D(QWidget* parent = 0); diff --git a/mapview/3D/misc/Shader.cpp b/mapview/3D/misc/Shader.cpp index f9e1657..25460dc 100644 --- a/mapview/3D/misc/Shader.cpp +++ b/mapview/3D/misc/Shader.cpp @@ -51,6 +51,7 @@ Shader::Shader() { void Shader::setModelMatrix(const QMatrix4x4& m) { + //vao.bind();; setUniformValue(getUniform("M"), m); } @@ -78,6 +79,7 @@ int Shader::getUniform(const char* name) { return loc; } int Shader::getAttribute(const char* name) { + vao.bind(); int loc = attributeLocation(name); if (loc == -1) {throw std::runtime_error("error");} return loc;