无法为 QOpenGLWidget 启用调试上下文
Can't enable debug context for QOpenGLWidget
我想在我的Qt QOpenGLWidget应用程序中启用OpenGL日志记录。
主.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();
}
主小部件.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?我的代码出了什么问题?
您需要在使用 QOpenGLDebugLogger 之前创建 QOpenGLContext。
就像:
QSurfaceFormat format;
format.setDepthBufferSize(24);
format.setVersion(3, 3);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(format);
QOpenGLContext *context = new QOpenGLContext();
context->setFormat(format);
context->create();
相关文章:
- 当回溯以零开始时,如何调试崩溃
- #为""定义宏;静态";针对不同的上下文
- 与互斥锁相比,旋转锁可以保证上下文切换
- 线程,如果else语句,都是错误的上下文切换后,会发生什么
- 在linux上调试巨大的C++项目
- 为什么我不能使用 EGL 创建无头 OpenGl 上下文?
- 为什么使用__LINE_的代码在发布模式下在MSVC下编译,而不是在调试模式下
- 如何针对特定情况调试和修复此双自由内存损坏问题
- 正在VS调试器中监视映射条目
- 使用调试/崩溃报告将应用程序部署到客户端
- VC++本机单元测试,找不到调试符号
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- 如何在C++生成器中禁用"使用调试.dcus"
- 为什么在逗号分隔符上下文中将预增量的结果强制转换为void
- 使用vscode调试时,GDB意外退出
- 错误"Could not find Boost"(缺少:上下文标头)
- 使用 mod_gsoap 部署服务时,如何在 Gsoap 中更改 soap 上下文的模式?
- 即使使用调试编译标志,表达式也是"optimized out"
- OpenGL 调试上下文警告 -"将使用视频内存作为缓冲区异议的来源
- 无法为 QOpenGLWidget 启用调试上下文