2012-06-12 165 views
0

有沒有辦法在調用QGLShaderProgram :: link()時打開日誌消息? http://qt-project.org/doc/qt-4.8/qglshaderprogram.html#linkQt:QGLShaderProgram關閉日誌消息

的消息是這樣的:

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

Qt代碼如下所示: 的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; 
} 

回答

1

如此看來唯一可行的解​​決辦法是重新qWarning()如下所示: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