Cam*_*ron 12
我花了一段时间才想出这个.
诀窍是QSurfaceFormat
在你QWindow
的构造函数中使用a ,如下所示:
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();
Run Code Online (Sandbox Code Playgroud)
后来,在初始化OpenGL时:
glEnable(GL_MULTISAMPLE); // This seems to be the default given the configuration above, but just in case that's not universal...
Run Code Online (Sandbox Code Playgroud)