PDA

View Full Version : QGLContext problems



bhuang
7th May 2010, 17:25
I use the GLWidget class from the hellogl sample.

In initializeGL(), I want to access the current QGLContext and call makeCurrent(), doneCurrent() to make it available to other rendering threads and make it unavailable to current thread.

To do this, I call QGLContext::currentContext(). But the return type is a const* pointer, hence I can't call QGLContext::doneCurrent().

If I instead create my own context via
QGLContext* p = new QGLContext( QGLFormat::defaultFormat() );
bool result = p->create();

result is always 0. Same with other ways to construct QGLFormat.

Thanks

przemo_li
25th August 2010, 09:18
From Qt 4.6 docs:

void QGLContext::doneCurrent () [virtual]
Makes no GL context the current context. Normally, you do not need to call this function; QGLContext calls it as necessary.

Problem is multiple threads accesing one GLWindget? QGLContext is not thread safe. Use other means of syncing and then use only QGLContext::makeCurent()
it should do.