I have been looking at this example 
(http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/examples/osgcompositeviewer/osgcompositeviewer.cpp)
 and written code similar to the parts that I think are relevant but all I get 
inside my window is a plain black background. I have set it to display a blue 
background and given it a capsule to render but none of that is displayed. Have 
I missed something really obvious?


Code:
osg::ref_ptr<osgViewer::CompositeViewer> viewer = new 
osgViewer::CompositeViewer;

osg::ref_ptr<osg::GraphicsContext::Traits> traits = new 
osg::GraphicsContext::Traits;
traits->x = 100;
traits->y = 100;
traits->width = 800;
traits->height = 600;
traits->depth = 16;
traits->windowDecoration = true;
traits->supportsResize = false;
traits->windowName = "TEST";

osg::ref_ptr<osg::GraphicsContext> graphicscontext = 
osg::GraphicsContext::createGraphicsContext(traits);

if (graphicscontext.valid())
{
        graphicscontext->setClearColor(osg::Vec4f(0.2f, 0.2f, 0.6f, 1.0f));
        graphicscontext->setClearMask(GL_COLOR_BUFFER_BIT | 
GL_DEPTH_BUFFER_BIT);
}

osg::ref_ptr<osg::Group> root = new osg::Group();
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
osg::ref_ptr<osg::Capsule> capsule = new osg::Capsule(osg::Vec3(), 1, 2);
osg::ref_ptr<osg::ShapeDrawable> drawable = new osg::ShapeDrawable(capsule);
geode->addDrawable(drawable);
root->addChild(geode);

osg::ref_ptr<osgViewer::View> view = new osgViewer::View;
viewer->addView(view);
view->setSceneData(root);
view->getCamera()->setGraphicsContext(graphicscontext);

viewer->run();



Thanks!

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=15397#15397





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to