2013-01-23 34 views
7

जब मैं खिड़की बनाता हूं तो मैं multisampling को कैसे सक्षम करूं? ओपनजीएल को मिलान करने के लिए मुझे कैसे प्रारंभ करना चाहिए?मैं QT5 के साथ OpenGL में मल्टीसाम्पलिंग (एंटीअलाइजिंग) को कैसे सक्षम करूं?

उत्तर

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(); 

और बाद में, जब ओपन initialising:

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