Qt双缓冲行为
Qt double buffering behaviour
我正在使用QWidget将一些代码转换为QOpenGLWidget,到目前为止,我想使用双缓冲来呈现小部件:
void clsElevStrip::initializeGL() {
qDebug() << "clsElevStrip::initializeGL()";
initializeOpenGLFunctions();
//Get the openGL context
mpobjContext = context();
if ( mpobjContext != NULL ) {
//Setup surface
mobjFormat.setDepthBufferSize(24);
mobjFormat.setSamples(4);
mobjFormat.setVersion(3, 0);
mobjFormat.setProfile(QSurfaceFormat::NoProfile);
mobjFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
int intSB = (int)mobjFormat.swapBehavior();
qDebug() << "swapBehavour as set-up in format: " << QString::number(intSB);
mpobjContext->setFormat(mobjFormat);
intSB = (int)mpobjContext->format().swapBehavior();
qDebug() << "swapBehavour as set-up in context: " << QString::number(intSB);
}
}
我可以在调试器中看到,在检查格式的交换行为时,intSB 是 2,但是当我检查上下文中设置的 intSB 时,它是 0,而不是 2?
因此,我渲染到上下文的任何内容都是可见的。
已解决:
我修改了代码,添加了
mpobjContext->create();
后:
mpobjContext->setFormat(mobjFormat);
现在它工作了!
相关文章:
- Qt VTK交互风格的信号到小部件
- QT在错误的班级中寻找空位
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 如何在Qt窗口小部件中使用QStringView(或QStringRef)
- 如何在Qt C++中更改光标
- 如何在MS Visual Studio 2019中运行QT UI
- QT通过C++添加映射QML项目
- libssh 的函数在构建 libssh 时无法在 Qt 和 cmake 错误中找到
- 如何将点击的信号和插槽添加到qt中的自定义按钮中
- Qt C++静态thread_local QNetworkAccessManager是线程应用程序的好选择吗
- Qt双缓冲行为
- Qt 帧缓冲对象甚至不渲染顶点
- Qt有循环缓冲吗?
- Qt OpenGL帧缓冲在一台PC上创建,但在另一台PC上失败
- 捕获到缓冲 QT
- 如何将可折叠元素(Qmenu,Qcombobox)渲染到使用QT的位图缓冲液
- 在跨HTTP的协议缓冲序列化中,空格使用QT
- 什么是Qt帧缓冲工作机制
- 我如何渲染地形使用顶点缓冲对象在Qt
- OpenGL顶点缓冲对象上的窗口-如何运行它?qt窗口