本文整理汇总了C++中ViewportPtr::setTop方法的典型用法代码示例。如果您正苦于以下问题:C++ ViewportPtr::setTop方法的具体用法?C++ ViewportPtr::setTop怎么用?C++ ViewportPtr::setTop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewportPtr
的用法示例。
在下文中一共展示了ViewportPtr::setTop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
//.........这里部分代码省略.........
示例2: serverRender
//.........这里部分代码省略.........
#endif
{
clientStereoPort =
dynamic_cast<StereoBufferViewportPtr>(clientPort);
cleft = (Int32)(clientPort->getPixelLeft() * scaleCWidth) ;
cbottom = (Int32)(clientPort->getPixelBottom() * scaleCHeight) ;
cright = (Int32)((clientPort->getPixelRight()+1) * scaleCWidth) -1;
ctop = (Int32)((clientPort->getPixelTop()+1) * scaleCHeight)-1;
if(cright < left ||
cleft > right ||
ctop < bottom ||
cbottom > top )
{
// invisible on this server screen
continue;
}
// calculate overlapping viewport
l = osgMax(cleft ,left ) - left;
b = osgMax(cbottom,bottom) - bottom;
r = osgMin(cright ,right ) - left;
t = osgMin(ctop ,top ) - bottom;
if(serverWindow->getPort().size() <= sv)
{
serverPort =
dynamic_cast<ViewportPtr>(clientPort->shallowCopy());
deco = TileCameraDecorator::create();
serverWindow->addPort(serverPort);
serverPort->setCamera(deco);
}
else
{
serverPort = serverWindow->getPort()[sv];
deco = dynamic_cast<TileCameraDecoratorPtr>(
serverPort->getCamera());
if(serverWindow->getPort()[sv]->getType() !=
clientPort->getType())
{
// there is a viewport with the wrong type
serverPort =
dynamic_cast<ViewportPtr>(clientPort->shallowCopy());
serverWindow->replacePort(sv,
serverPort);//[sv] = serverPort;
serverPort->setCamera(deco);
}
else
{
deco = dynamic_cast<TileCameraDecoratorPtr>(
serverPort->getCamera());
}
}
// update changed viewport fields
updateViewport(serverPort,clientPort);
// set viewport size
serverPort->setSize(Real32(l),Real32(b),Real32(r),Real32(t));
// use pixel even if pixel = 1
if(serverPort->getLeft() == 1.0)
serverPort->setLeft(1.0001);
if(serverPort->getRight() == 1.0)
serverPort->setRight(1.0001);
if(serverPort->getTop() == 1.0)
serverPort->setTop(1.0001);
if(serverPort->getBottom() == 1.0)
serverPort->setBottom(1.0001);
// calculate tile parameters
deco->setFullWidth ( cright-cleft );
deco->setFullHeight( ctop-cbottom );
deco->setSize( ( l+left-cleft ) / (float)( cright-cleft ),
( b+bottom-cbottom ) / (float)( ctop-cbottom ),
( r+left-cleft ) / (float)( cright-cleft ),
( t+bottom-cbottom ) / (float)( ctop-cbottom ) );
deco->setDecoratee( clientPort->getCamera() );
}
sv++;
}
// remove unused ports
while(serverWindow->getPort().size()>sv)
{
serverWindow->subPort(sv);
}
Inherited::serverRender(serverWindow,id,action);
}