如何启用多重采样,当我创建的窗口? 我应该如何初始化的OpenGL搭配?
Answer 1:
我花了一段时间才能弄清楚这一个。
诀窍是使用QSurfaceFormat
在QWindow
的构造就像这样:
setSurfaceType(QWindow::OpenGLSurface);
QSurfaceFormat format;
format.setSamples(4); // Set the number of samples used for multisampling
setFormat(format); // Note we set the format on the window...
create(); // Create the window
context = new QOpenGLContext(this);
context->setFormat(format); // ...and set the format on the context too
context->create();
后来,OpenGL的初始化时:
glEnable(GL_MULTISAMPLE); // This seems to be the default given the configuration above, but just in case that's not universal...
文章来源: How do I enable multisampling (antialiasing) in OpenGL with Qt5?