调用QGLShaderProgram :: link()时是否有办法转换日志消息? http://qt-project.org/doc/qt-4.8/qglshaderprogram.html#link
消息如下:
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;
}
答案 0 :(得分: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