DIMEDROLL
30th November 2010, 09:25
I've found a nice tutorial on multithreaded OpenGL rendering on QGLWidget:
http://doc.trolltech.com/qq/qq06-glimpsing.html#writingmultithreadedglapplications
But I have some questions about it:
1.
class GLThread : public QThread
Is it safe to modify GLThread's members:
bool doRendering;
bool doResize;
int w;
...
when GLThread thread is running and reads each variable every iteration?
I'm talking about
void GLWidget::resizeEvent(QResizeEvent *evt)
{ /*glt is GLThread's object*/
glt.resizeViewport(evt->size());
}
2. Is it safe to modify more complex GLThread's members when GLThread thread is running? E.g.
class MyComplexGLThreadMemberClass {
int a;
double b;
vector<int> c;
};
3.
class GLWidget : public QGLWidget
Is it safe to call GLWidget's methods from a running GLThread thread?
void GLThread::run()
{
glw->makeCurrent();
while (doRendering) {
// Rendering code goes here
glw->swapBuffers();
}
}
Here is my source code for Qt4.7 and exe file built with Qt4.7, you'll need Qt dlls to run it.
5546
5547
http://doc.trolltech.com/qq/qq06-glimpsing.html#writingmultithreadedglapplications
But I have some questions about it:
1.
class GLThread : public QThread
Is it safe to modify GLThread's members:
bool doRendering;
bool doResize;
int w;
...
when GLThread thread is running and reads each variable every iteration?
I'm talking about
void GLWidget::resizeEvent(QResizeEvent *evt)
{ /*glt is GLThread's object*/
glt.resizeViewport(evt->size());
}
2. Is it safe to modify more complex GLThread's members when GLThread thread is running? E.g.
class MyComplexGLThreadMemberClass {
int a;
double b;
vector<int> c;
};
3.
class GLWidget : public QGLWidget
Is it safe to call GLWidget's methods from a running GLThread thread?
void GLThread::run()
{
glw->makeCurrent();
while (doRendering) {
// Rendering code goes here
glw->swapBuffers();
}
}
Here is my source code for Qt4.7 and exe file built with Qt4.7, you'll need Qt dlls to run it.
5546
5547