You need to put the viewer->frame() call in the OnPaint callback and Invalidate the host window in the main loop.


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Valentin Nedyalkov
Sent: 31 October 2006 16:15
To: osg users
Subject: RE: [osg-users] OSG-MFC

Hi,

I put loop:
viewer->realize()
while ( !viewer->done() )
{
viewer->sync();
viewer->update();
viewer->frame();
}
in separate thread and there is now problem until I decide to resize window with mouse or maximize it. What to do?
 
Thank you in advance
Valentin
Ignacio García <[EMAIL PROTECTED]> wrote:
My little experience with OSG with MFC has leaded me to two threads, besides
OSG internal threads:
- The MFC main thread (CWinApp), that controls the MFC GUI.
- Another thread for OSG loop:
viewer->realize()
while ( !viewer->done() )
{
viewer->sync();
viewer->update();
viewer->frame();
}

The OSG loop must be always done, in order to refresh the scene. And if you
use the MFC thread to do it, no messages will be processed in the GUI, the
GUI will be responseless.


________________________________________
De: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] En nombre de Valentin
Nedyalkov
Enviado el: miércoles, 25 de octubre de 2006 11:17
Para: [email protected]
Asunto: [osg-users] OSG-MFC

Dear osg-users,
I am working on a project, in which I must use OSG and MFC. I
make eparate class, which contains only OSG function for initalize a
viewer, drawing and these variables:
 // Application main 3D viewer
   osgProducer::Viewer *_pViewer;
 //node for transformation
   osg::ref_ptr
 _objectXform;

In GUI there is a button to load 3D model and show in a viewer and
another button to start animation(for example move along x axis). When user
click on irst button, viewer is created and its scene contain two node: one
is objectXform and another is 3Dmodel, which is child of first one. I
don't use glut window and only do this to show viewer:
 // create the windows and run the threads.
   _pViewer->realize ();
   _pViewer->sync();
   _pViewer->update();
   _pViewer->frame();
but in this case window with a veiwer is not repaint. If I put the code
above in cycle in this way:
  while( _pViewer->done() )
 {
     _pViewer->realize ();
     _pViewer->sync();
    _pViewer->update();
    _pViewer->frame();
 }
to correct update of viewer, user can interact with  window contains
GUI, while the viewer is opened, because the main thread of my application
is occupied by this cicle. What could you advise me to do?
I thought to use a worker thread to repaint viewer constanly, but it
didn't work.And the other problem is that when user click on button to start

animation viewer is not refresh.The scene stays in its initial state, in
spite
of that:
//animation
for( int i=1; ; i++)
{
        _pViewer->sync();
        _pViewer->update();
         osg::Vec3 newPosit(i,0.0,0);
       _objectXform->setPosition( shipPosit1 );
      _objectXform->setAttitude( osg::Quat(osg::DegreesToRadians( 10.0 ),
                        osg::Vec3   (0,0,1) ) );
       _pViewer->frame();
 }
This code is in separate function in my OSG class. I think that there
is a problem with reference.If this code is in the same function where
 _objectXform node is add to scene there is no problem.

 Thank you in advance
 Valentin Nedyalkov

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/


Access over 1 million songs - Yahoo! Music Unlimited Try it today.
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System.

________________________________________________________________________
The contents of this email (including any attachments) are confidential and may be legally privileged. If you are not the intended recipient of this email, any disclosure, copying, distribution or use of its contents is strictly prohibited, and you should please notify the sender immediately and then delete it (including any attachments) from your system.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to