Added realize() and isRealized() methods to osg::GraphicsContext.

Added osgcamera example that uses osg::GraphicsContext to create the required
window for rendering too, will eventually use osg::CameraNode to replace usage
of osgUtil::SceneView.
This commit is contained in:
Robert Osfield
2005-08-16 13:29:07 +00:00
parent 75987a045d
commit e8fc5248fa
8 changed files with 182 additions and 10 deletions

View File

@@ -50,7 +50,6 @@ GraphicsContextImplementation::GraphicsContextImplementation(Traits* traits)
_rs->setWindowRectangle(traits->_x, traits->_y, traits->_width, traits->_height);
_rs->useBorder(traits->_windowDecoration);
#if 1
// set the visual chooser
Producer::VisualChooser* rs_vc = _rs->getVisualChooser();
if (!rs_vc)
@@ -71,11 +70,8 @@ GraphicsContextImplementation::GraphicsContextImplementation(Traits* traits)
rs_vc->addAttribute( Producer::VisualChooser::RGBA );
// Always use UseGL
rs_vc->addAttribute( Producer::VisualChooser::UseGL );
#endif
if (traits->_pbuffer)
{
@@ -141,7 +137,7 @@ GraphicsContextImplementation::GraphicsContextImplementation(Traits* traits)
}
// but we share texture objects etc. so we also share the same contextID
_rs->realize( 0, sharedContext->_rs->getGLContext() );
//_rs->realize( 0, sharedContext->_rs->getGLContext() );
}
else
@@ -151,7 +147,7 @@ GraphicsContextImplementation::GraphicsContextImplementation(Traits* traits)
setState( new osg::State );
getState()->setContextID( GraphicsContext::createNewContextID() );
_rs->realize();
//_rs->realize();
}
}
@@ -166,6 +162,28 @@ GraphicsContextImplementation::~GraphicsContextImplementation()
release();
}
bool GraphicsContextImplementation::realize()
{
if (_rs.valid())
{
GraphicsContextImplementation* sharedContext = dynamic_cast<GraphicsContextImplementation*>(_traits->_sharedContext);
if (sharedContext)
{
_rs->realize( 0, sharedContext->_rs->getGLContext() );
}
else
{
_rs->realize();
}
return _rs->isRealized();
}
else
{
return false;
}
}
void GraphicsContextImplementation::makeCurrent()
{
if (!_rs) return;