Trouble with QOpenGLDebugLogger
Unsolved
General and Desktop
-
Hi,
when trying to add a Debuglogger to the Scene Graph example (http://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-example.html) to embedd an OpenGL context into a QQuickItem i've stumbled upon the problem, that, whatever i try, the loggers initialize function always prints out:QOpenGLDebugLogger::initialize(): the current context is not a debug context: this means that the GL may not generate any debug output at all. To avoid this warning, try creating the context with the QSurfaceFormat::DebugContext surface format option.
To show how i did the initialization i put the header and source file here:
class GLRenderEngine : public QOpenGLContext { public: GLRenderEngine(); ~GLRenderEngine(); void setViewportSize(const QSize &size) { m_Viewport = size; } void setWindow(QQuickWindow *window) { m_pWindow = window; } public slots: void paint(); void onMessageLogged(QOpenGLDebugMessage message); signals: void messageLogged( QOpenGLDebugMessage message ); private: bool m_bInit; QSize m_Viewport; QQuickWindow* m_pWindow; QOpenGLDebugLogger* m_pLogger; };
void GLRenderEngine::onMessageLogged(QOpenGLDebugMessage message) { qDebug() << message; } void GLRenderEngine::paint() { if(!m_bInit) { QSurfaceFormat format; format.setMajorVersion(3); format.setMinorVersion(2); format.setProfile(QSurfaceFormat::CoreProfile); format.setOption(QSurfaceFormat::DebugContext); setFormat(format); create(); m_pLogger = new QOpenGLDebugLogger(currentContext());//using 'this' didn't change anything connect( m_pLogger, SIGNAL( messageLogged( QOpenGLDebugMessage ) ), this, SLOT( onMessageLogged( QOpenGLDebugMessage ) ), Qt::DirectConnection ); m_pLogger->initialize(); m_pLogger->startLogging(); FontRenderer::getInstance().initGL(functions()); m_bInit = true; } glViewport(0, 0, m_Viewport.width(), m_Viewport.height()); float fOrthoMatrix[16] = {0}; float fViewMatrix[16] = {0}; float fProjMatrix[16] = {0}; ortho(fOrthoMatrix, 0.f, m_Viewport.width(), m_Viewport.height(), 0.f, 0, 50); // Set the camera position (View matrix) setLookAt(fViewMatrix, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.0f, 0.0f); // Calculate the projection and view transformation multiply(fProjMatrix, fOrthoMatrix, fViewMatrix); glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); TextUnit aText = { "Hello World", "./Sniglet-Regular.ttf", 18, 100, 100, 0xffffffff }; FontRenderer::getInstance().drawText(&aText, fProjMatrix); // Not strictly needed for this example, but generally useful for when // mixing with raw OpenGL. m_pWindow->resetOpenGLState(); }
I've got an NVIDIA GTX 750, which has Debug support so it's not the graphics card fault.
Also I'm using Ubuntu 16.04 with NVIDIA drivers version 375.66.
I' appreciate help with this, because a subsequent part of my opengl code is not working and thus needs debugging.Thanks in advance.