Hi,
I've some problems when my context get's renewed due
to pixelformat changes e.g. the user selected stereo
etc. I'm using qt 4.2.3 and I use it's setFormat method.
Qt recreates a new context behind the scenes and informs
the QGLWidget about the change by calling initializeGL.
So I'm ok OpenGL-context-wise. I'm not quite sure what
I'm supposed to do OpenSG-wise for getting the transition
right. After some experiments I figured out that it's
a good thing to recreate the PassiveWindow associated
to the context. See the code posted below. I get
some problems trying to cleanup the old passive
window though (crash, segfault, sorry no decent stack trace
at hand). But it get's more weird. When I comment
the lines that do the cleanup, the program seems
to work correctly on the first switch mono->stereo.
After switching back and forth for a while, my lighting
get's screwed, the light source seems to be black.
All this might be caused by an error inside
my program, but as this one was the last modification
I made to the code I suspect it's OpenSG's fault. Just
want to ask if the code below has some obvious errors..
Thank you and regards,
Toni
void
OpenSGWidget::initializeGL(){
static bool firstTime = true;
// every time a new context is created (e.g. when
// stereo format is requested through setFormat this
// function is called. To make OpenSG aware of the context
// change, we recreate the passiveWindow!
if( firstTime ){
firstTime = false;
mPwin->init();
mPwin->activate();
mPwin->frameInit();
mMgr->redraw();
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
}else{
PassiveWindowPtr mPwinNew = PassiveWindow::create();
PassiveWindowPtr oldWin = mPwin;
beginEditCP(mPwinNew);
// copy all viewports from old win to the new one.
for( unsigned int i = 0; i < mPwin->getPort().size(); ++i )
mPwinNew->addPort( mPwin->getPort()[i] );
endEditCP(mPwinNew);
mPwin = mPwinNew;
mMgr->setWindow(mPwin);
mPwin->init();
mPwin->activate();
mPwin->frameInit();
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
// cleanup old passive window and subref it.
unsigned int n = mPwin->getPort().size();
beginEditCP(oldWin);
for( unsigned int i = 0; i < n; ++i )
oldWin->subPort( 0 ); // makes osg crash
endEditCP(oldWin);
subRefCP(oldWin); // makes osg crash at exit!
mMgr->redraw();
}
printf( "OpenSGWidget::initializeGL\n" );
}
--
Ing. Antonio Bleile
Seac02 S.r.l.
via Avogadro 4
10121 Torino Italia
Tel. +39.011.197.006.52
Fax +39.011.197.006.53
E-mail [EMAIL PROTECTED]
Sito www.seac02.it
Questa E-mail è rivolta unicamente alle persone o enti ai quali è
indirizzata. Essa può contenere informazioni la cui riservatezza è tutelata.
Sono vietati la riproduzione e qualsiasi uso di questa e-mail e/o delle
informazioni in essa contenute in mancanza di autorizzazione del
destinatario.
This e-mail is intended only for the person or entity to which is addressed.
It may contain information that is privileged, proprietary, confidential,
attorney work product or otherwise exempted from disclosure under applicable
law. Copying, dissemination or use of this e-mail or the information herein
by anyone other than the intended recipient is prohibited.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users