7
如何在创建窗口时启用多重采样?我应该如何初始化OpenGL以匹配?如何使用Qt5在OpenGL中启用多重采样(抗锯齿)?
如何在创建窗口时启用多重采样?我应该如何初始化OpenGL以匹配?如何使用Qt5在OpenGL中启用多重采样(抗锯齿)?
花了我一会儿来弄清楚这一点。
关键是在你QWindow
的构造使用QSurfaceFormat
像这样:
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...
真的很奇怪,什么是它设置点在QOpenGLContext上,如果QWindow只是做自己的事情 – paulm
@ paulm:不知道,我只是摆弄东西,直到它工作;-) – Cameron