我想在我的Qt QOpenGLWidget应用程序中启用OpenGL日志记录。代码:
的main.cpp
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QSurfaceFormat format;
format.setMajorVersion(3);
format.setMinorVersion(2);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setOption(QSurfaceFormat::DebugContext);
app.setApplicationName("MPGLES");
app.setApplicationVersion("0.0.1");
MainWidget widget;
widget.setFormat(format);
widget.show();
return app.exec();
}
mainwidget.cpp
MainWidget::MainWidget(QWidget *parent) : QOpenGLWidget(parent), m_debugLogger(Q_NULLPTR) { }
void MainWidget::initializeGL()
{
makeCurrent();
m_functions.initializeOpenGLFunctions();
m_functions.glClearColor(0, 0, 0, 1);
m_debugLogger = new QOpenGLDebugLogger(context());
if (m_debugLogger->initialize()) {
qDebug() << "GL_DEBUG Debug Logger" << m_debugLogger << "\n";
connect(m_debugLogger, SIGNAL(messageLogged(QOpenGLDebugMessage)), this, SLOT(messageLogged(QOpenGLDebugMessage)));
m_debugLogger->startLogging();
}
initializeMP();
timer.start(12, this);
}
致电后
m_debugLogger->initialize();
我看到下一个输出:
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.
为什么我不能创建QOpenGLDebugLogger?我的代码有什么问题?
答案 0 :(得分:0)
您需要在使用 QOpenGLDebugLogger 之前创建 QOpenGLContext。
就像:
STABBR STABBR
AK AK 3
AL AL 14
AR AR 10
AZ AZ 8
CA CA 32