PDA

View Full Version : Single QGLContext across multiple QGLWidgets



pseudosig
17th June 2008, 19:26
I'm having some serious issues trying to figure out how I successfully share a single QGLContext across multiple QGLWidgets. I want to share resources (display lists, vertex buffer objects, textures, etc) across both to optimize data loading (i.e. only create a single large VBO to draw in multiple gl windows).



QGLFormat format;
QGLContext* context = new QGLContext(format);
//GlWorld inherits from QGLWidget...
GlWorld world1(context);
MySprite single_sprite;

world1.InstallSprite2D(&single_sprite);
world1.show();
world1.run();


// Application Crashes at the
// creation of world2... not sure why?
// QGLcontext, QWidget*, QGLWidget*
GlWorld world2(context, NULL, &world1);
world2.InstallSprite2D(&single_sprite);
world2.show();
world2.run();

Part of class definition...
GlWorld::GlWorld(QGLContext* context,
QWidget *parent, QGLWidget* shared) : QGLWidget(context, parent, shared)
{
...
..
}


Any help would be great... but a working example would probably be most helpful.
thanks in advance...

pseudosig
18th June 2008, 16:39
No one have any ideas on this?

jacek
22nd June 2008, 23:13
What does GlWorld::run() do?