本文整理汇总了C++中ViewportPtr::setParent方法的典型用法代码示例。如果您正苦于以下问题:C++ ViewportPtr::setParent方法的具体用法?C++ ViewportPtr::setParent怎么用?C++ ViewportPtr::setParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewportPtr
的用法示例。
在下文中一共展示了ViewportPtr::setParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
// OSG init
glutInit(&argc, argv);
osgInit(argc, argv);
std::string fontfile("testfont.ttf");
std::string testtext("Test Text");
UInt32 drawmode;
if(argc > 1)
testtext = argv[1];
if(argc > 2)
fontfile = argv[2];
if(argc < 4 || sscanf(argv[3], "%d", &drawmode) != 1 )
drawmode = FTGLFont::Outline;
// GLUT
int winid = setupGLUT(&argc, argv);
GLUTWindowPtr gwin= GLUTWindow::create();
gwin->setId(winid);
gwin->init();
// Create the Cubes node
NodePtr scene = makeCoredNode<Group>();
beginEditCP(scene);
scene->addChild( makeBox(200,200,200, 1,1,1) );
// scene->addChild( SceneFileHandler::the().read("tie.wrl") );
endEditCP(scene);
// Create the text
FTGLFontPtr font = FTGLFont::create();
beginEditCP(font);
font->setName(fontfile);
font->setDrawType(drawmode);
font->setSize(40);
font->setRes(72);
font->setDepth(20);
endEditCP(font);
FTGLTextPtr text;
NodePtr tnode = makeCoredNode<FTGLText>(&text);
beginEditCP(text);
text->setFont(font);
text->setText(testtext);
text->setPosition(Pnt3f(0,300,0));
text->setMaterial(getDefaultMaterial());
endEditCP(text);
beginEditCP(scene);
scene->addChild(tnode);
endEditCP(scene);
// create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// tell the manager what to manage
mgr->setWindow(gwin );
mgr->setRoot (scene);
// show the whole scene
mgr->showAll();
// copy to second window
int winid2 = setupGLUT(&argc, argv);
gwin2= GLUTWindow::create();
gwin2->setId(winid2);
gwin2->init();
ViewportPtr ovp = gwin->getPort()[0];
ViewportPtr vp = Viewport::create();
beginEditCP(vp);
vp->setLeft(0);
vp->setRight(400);
vp->setBottom(0);
vp->setTop(400);
vp->setCamera(ovp->getCamera());
vp->setRoot(ovp->getRoot());
vp->setBackground(ovp->getBackground());
vp->setParent(gwin2);
endEditCP(vp);
beginEditCP(gwin2);
gwin2->getPort().push_back(vp);
endEditCP(gwin2);
// GLUT main loop
//.........这里部分代码省略.........