[Qt-interest] where do you initialize Opengl?
Shi Yan
billconan at gmail.com
Sat Oct 31 03:47:39 CET 2009
hello guys,
i'm writing a simple 3D CAD tool. i'm using the Model-view pattern. i
have several qglwidgets representing different cameras viewing the
same scene and a singleton class, which i call a "Scene".
inside this "Scene" class, i define the geometry that needs to be
rendered and initialize GLSL shader language, etc.
the problem where should i call Scene.init() ?
one option is calling it within the initializeGL() function of a
qglwidgets. but there are many qglwidgets in my program. if i call
scene.init() inside initializeGL(), then the initialization will
execute several times.
however, if i call scene initialization somewhere else (for example in
the main function), it will fail, because the opengl context hasn't
been set up yet:
main()
{
QApplication app(argc, argv);
MainWindow mainWindow;
scene.init();
mainWindow.showMaximized();
return app.exec();
}
is there anyway to initialize opengl related settings right after QT
sets up the opengl?
i think QT should pop up a signal after setting up Opengl. this signal
should be emitted by a global object, say QGLContext.
and then, i can write a slot, once the opengl is ready, i call my
initialization function.
hope you can give me some advice.
is the Qt team reading this ? what do you think about the
"Opengl-ready signal"?
thanks.
More information about the Qt-interest-old
mailing list