简体   繁体   中英

Qt: QGLShaderProgram turn off log messages

Is there a way to turn of log messages when calling QGLShaderProgram::link()? http://qt-project.org/doc/qt-4.8/qglshaderprogram.html#link

Messages look like:

QGLShader::link: "Vertex shader(s) linked, fragment shader(s) linked.
"

Qt code looks like this: src/opengl/qglshaderprogram.cpp:893

    glLinkProgram(program);
    value = 0;
    glGetProgramiv(program, GL_LINK_STATUS, &value);
    d->linked = (value != 0);
    value = 0;
    glGetProgramiv(program, GL_INFO_LOG_LENGTH, &value);
    d->log = QString();
    if (value > 1) {
        char *logbuf = new char [value];
        GLint len;
        glGetProgramInfoLog(program, value, &len, logbuf);
        d->log = QString::fromLatin1(logbuf);
        QString name = objectName();
        if (name.isEmpty())
            qWarning() << "QGLShader::link:" << d->log;
        else
            qWarning() << "QGLShader::link[" << name << "]:" << d->log;
        delete [] logbuf;
    }
    return d->linked;
}

So it seems the only possible solution is to redirect qWarning() as done in: How to redirect qDebug, qWarning, qCritical etc output?

 qInstallMsgHandler([](QtMsgType , const char* ) { });  // empty message handler
 bool result = program.link();
 qInstallMsgHandler(0);  // restore default message handling

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM