2013-01-23 52 views

回答

10

花了我一会儿来弄清楚这一点。

关键是在你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... 
+0

真的很奇怪,什么是它设置点在QOpenGLContext上,如果QWindow只是做自己的事情 – paulm

+2

@ paulm:不知道,我只是摆弄东西,直到它工作;-) – Cameron