Vis-Sim.com Forums Forum Index Vis-Sim.com Forums
3D Real-Time Simulation Services, Resources and Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

(35)With multiple rendering windows, I get weird results

 
Post new topic   Reply to topic    Vis-Sim.com Forums Forum Index -> OSG Faq's
View previous topic :: View next topic  
Author Message
UrbanLegend
Site Admin


Joined: 11 Apr 2005
Posts: 1147

PostPosted: Sun Apr 22, 2007 8:35 pm    Post subject: (35)With multiple rendering windows, I get weird results Reply with quote

Q : With multiple rendering windows, I get weird results & textures display incorrectly

A : Each rendering window has its own OpenGL context which is separate from all other contexts. OSG doesn't know how you set up your windowing environment, you thus need to ensure that each osg::State object is tied to a unique OpenGL context.

To do that you do something along the lines of:

1. for each window, get the associated osgUtil::SceneView object
2. for each SceneView object, get the associated osg::State object
3. call State::setContextID() on each State, passing a unique number to identify that context

Code:

osgProducer::OsgSceneHandler *m_shandle = NULL; 
 
osgUtil::SceneView  *m_sceneview_one    = NULL;
 
osgUtil::SceneView  *m_sceneview_two    = NULL;
 
//
// Grab the SceneViews 
//
m_shandle = dynamic_cast<osgProducer>( camera_one->getSceneHandler() );   
 
m_sceneview_one = m_shandle->getSceneView();
 
m_shandle = dynamic_cast<osgProducer>( camera_two->getSceneHandler());   
 
m_sceneview_two = m_shandle->getSceneView();
 
 
// 
//  Create the default osg::State and the reset of the First Sceneviews defaults
//
m_sceneview_one->setDefatults();
 
// 
// now set the ID to 0 ,this is the default
//
m_sceneview_one->getState()->setContextID(0);
 
 
 
// 
//  Create the default osg::State and the reset of the Second Sceneviews defaults
//
m_sceneview_two->setDefatults();
 
// 
// now set the ID to 1, on the next sceneview
//
m_sceneview_two->getState()->setContextID(1);



Note, that context ID's are used as indices in to vectors that grow automatically, so avoid setting large numbers, start counting from 0 and then increment by one each time
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Vis-Sim.com Forums Forum Index -> OSG Faq's All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


SwiftBlue Theme created by BitByBit
Powered by phpBB © 2001, 2002 phpBB Group