本文整理汇总了C++中osg::GLUTWindowRecPtr::getPort方法的典型用法代码示例。如果您正苦于以下问题:C++ GLUTWindowRecPtr::getPort方法的具体用法?C++ GLUTWindowRecPtr::getPort怎么用?C++ GLUTWindowRecPtr::getPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::GLUTWindowRecPtr
的用法示例。
在下文中一共展示了GLUTWindowRecPtr::getPort方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: key
void key(unsigned char key, int /*x*/, int /*y*/)
{
switch ( key )
{
case 'd':
window->getPort(0)->getRoot()->dump();
break;
case 's':
OSG::SceneFileHandler::the()->write(
window->getPort(0)->getRoot(),"server.osg");
cleanup();
exit(0);
break;
}
}
示例2: connectCluster
static void connectCluster(void)
{
if(_cluster_win != NULL)
return;
OSG::Viewport *clientvp = _client_win->getPort(0);
// create the viewports for the cluster just a simple one ...
OSG::ViewportUnrecPtr vp = OSG::Viewport::create();
vp->setCamera (_mgr->getCamera());
vp->setBackground(clientvp->getBackground());
vp->setRoot (clientvp->getRoot());
vp->setSize (0,0, 1,1);
// the connection between this client and the servers
_cluster_win = OSG::MultiDisplayWindow::create();
// all changes must be enclosed in beginEditCP and endEditCP
// otherwise the changes will not be transfered over the network.
for(OSG::UInt32 i=0;i<_pipenames.size();++i)
_cluster_win->editMFServers()->push_back(_pipenames[i]);
// dummy size for navigator
_cluster_win->setSize(300,300);
_cluster_win->addPort(vp);
OSG::Thread::getCurrentChangeList()->commitChangesAndClear();
OSG::Thread::getCurrentChangeList()->fillFromCurrentState();
OSG::Thread::getCurrentChangeList()->dump();
// create from the current state a changelist.
// initialize window
_cluster_win->init();
// apply changelist to the servers
_cluster_win->render((OSG::RenderAction *) _mgr->getRenderAction());
// clear changelist
OSG::Thread::getCurrentChangeList()->clear();
glutPostRedisplay();
}
示例3: main
int main(int argc, char **argv)
{
OSG::osgInit(argc,argv);
if(argc > 1 && !strcmp(argv[1],"-s"))
{
show = false;
argv++;
argc--;
}
if(argc > 1 && !strcmp(argv[1],"-d"))
{
debug = true;
argv++;
argc--;
}
if(argc > 1)
{
scene = OSG::Node::create();
OSG::GroupUnrecPtr g = OSG::Group::create();
scene->setCore(g);
for(OSG::UInt16 i = 1; i < argc; ++i)
scene->addChild(OSG::SceneFileHandler::the()->read(argv[i]));
}
else
{
scene = OSG::makeTorus(.5, 3, 16, 16);
}
// GLUT init
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutInitWindowSize(1024, 768);
mainwinid = glutCreateWindow("OpenSG");
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutIdleFunc(idle);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutKeyboardFunc(keyboard);
OSG::GLUTWindowUnrecPtr mainwin=OSG::GLUTWindow::create();
mainwin->setGlutId(mainwinid);
mainwin->init();
// create the SimpleSceneManager helper
mgr = OSG::SimpleSceneManager::create();
// create the window and initial camera/viewport
mgr->setWindow(mainwin);
// tell the manager what to manage
mgr->setRoot (scene);
OSG::commitChanges();
// show the whole scene
mgr->showAll();
mgr->setUseTraversalAction(true);
tact = OSG::RenderAction::create();
#ifdef OSG_OLD_RENDER_ACTION
act = OSG::RenderAction::create();
#endif
debugact = OSG::RenderAction::create();
tact->setOcclusionCulling(true);
// Open the debug window
if(debug)
{
OSG::traverse(scene, initMask);
glutInitWindowSize(800, 400);
debugwinid = glutCreateWindow("OpenSG Occlusion Debugging");
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutIdleFunc(display);
glutKeyboardFunc(keyboard);
debugwin=OSG::GLUTWindow::create();
debugwin->setGlutId(debugwinid);
debugwin->init();
OSG::ViewportUnrecPtr vp = mainwin->getPort(0);
OSG::ViewportUnrecPtr newvp = OSG::Viewport::create();
newvp->setLeft(0);
newvp->setRight(0.5);
newvp->setBottom(0);
newvp->setTop(1);
//.........这里部分代码省略.........
示例4: main
int main(int argc, char *argv[])
{
// Init the OpenSG subsystem
OSG::osgInit(argc, argv);
{
// We create a GLUT Window (that is almost the same for most applications)
int winid = setupGLUT(&argc, argv);
OSG::GLUTWindowRecPtr gwin = OSG::GLUTWindow::create();
gwin->setGlutId(winid);
gwin->init();
// Create the face
std::string family = "SANS";
OSG::TextFace::Style style = OSG::TextFace::STYLE_PLAIN;
OSG::UInt32 size = 32;
OSG::TextPixmapFaceRefPtr face =
OSG::TextPixmapFace::create(family, style, size);
if (face == 0)
{
std::cerr << "ERROR: Cannot create face object!" << std::endl;
return -1;
}
// Lay out one single line of text
std::string text = "Hello World!"; // Use UTF-8 encoding!
OSG::TextLayoutParam layoutParam;
layoutParam.horizontal = true;
layoutParam.leftToRight = true;
layoutParam.topToBottom = true;
layoutParam.majorAlignment = OSG::TextLayoutParam::ALIGN_FIRST;
layoutParam.minorAlignment = OSG::TextLayoutParam::ALIGN_FIRST;
layoutParam.spacing = 1.f;
layoutParam.length.push_back(0.f);
layoutParam.maxExtend = 0.f;
OSG::TextLayoutResult layoutResult;
face->layout(text, layoutParam, layoutResult);
// Render the text into an OpenSG image
OSG::Vec2f offset;
OSG::UInt32 border = 1;
OSG::ImageRecPtr imagePtr = face->makeImage(layoutResult, offset, border);
// Create the geometry which we will assign the texture to
OSG::Real32 width = imagePtr->getWidth();
OSG::Real32 height = imagePtr->getHeight();
OSG::NodeRecPtr plane = OSG::makePlane(width, height, 1, 1);
// Create the texture that will hold the image
OSG::SimpleTexturedMaterialRecPtr tex =
OSG::SimpleTexturedMaterial::create();
tex->setImage(imagePtr);
tex->setEnvMode(GL_MODULATE);
tex->setDiffuse(OSG::Color3f(1, 0, 0));
// Assign the texture to the geometry
OSG::GeometryRecPtr geo =
dynamic_cast<OSG::Geometry *>(plane->getCore());
geo->setMaterial(tex);
// Transform the geometry so that the origin of the text is at
// the origin of the world coordinate system
OSG::NodeRecPtr scene = OSG::Node::create();
OSG::TransformRecPtr transformPtr = OSG::Transform::create();
OSG::Matrix m;
m.setTranslate(offset.x() + width / 2, offset.y() - height / 2, 0);
transformPtr->setMatrix(m);
scene->setCore(transformPtr);
scene->addChild(plane);
// Create and setup the SSM
mgr = new OSG::SimpleSceneManager;
mgr->setWindow(gwin);
mgr->setRoot(scene);
// Create a blue background
OSG::SolidBackgroundRecPtr bg = OSG::SolidBackground::create();
bg->setColor(OSG::Color3f(0.1, 0.1, 0.5));
gwin->getPort(0)->setBackground(bg);
mgr->showAll();
OSG::commitChanges();
}
// Give Control to the GLUT Main Loop
glutMainLoop();
return 0;
}
示例5: main
int main(int argc, char *argv[])
{
// Init the OpenSG subsystem
OSG::osgInit(argc, argv);
{
// We create a GLUT Window (that is almost the same for most applications)
int winid = setupGLUT(&argc, argv);
OSG::GLUTWindowRecPtr gwin = OSG::GLUTWindow::create();
gwin->setGlutId(winid);
gwin->init();
// Create the face
std::string family = "SANS";
OSG::TextFace::Style style = OSG::TextFace::STYLE_PLAIN;
OSG::TextTXFParam txfParam;
txfParam.size = 46;
txfParam.gap = 1;
txfParam.setCharacters("Hello World!");
txfParam.textureWidth = 0;
OSG::TextTXFFaceRefPtr face =
OSG::TextTXFFace::create(family, style, txfParam);
if (face == 0)
{
std::cerr << "ERROR: Cannot create face object!" << std::endl;
return -1;
}
// Lay out one single line of text
std::string text = "Hello World!"; // Use UTF-8 encoding!
OSG::TextLayoutParam layoutParam;
layoutParam.horizontal = true;
layoutParam.leftToRight = true;
layoutParam.topToBottom = true;
layoutParam.majorAlignment = OSG::TextLayoutParam::ALIGN_FIRST;
layoutParam.minorAlignment = OSG::TextLayoutParam::ALIGN_FIRST;
layoutParam.spacing = 1.f;
layoutParam.length.push_back(0.f);
layoutParam.maxExtend = 0.f;
OSG::TextLayoutResult layoutResult;
face->layout(text, layoutParam, layoutResult);
// Create the text geometry
OSG::Real32 scale = 1.f;
OSG::NodeRecPtr scene = face->makeNode(layoutResult, scale);
// Get the texture that contains the characters of the font
OSG::ImageRecPtr image = face->getTexture();
// Create the texture that will hold the image
OSG::SimpleTexturedMaterialRecPtr tex =
OSG::SimpleTexturedMaterial::create();
tex->setImage(image);
tex->setEnvMode(GL_MODULATE);
tex->setDiffuse(OSG::Color3f(1, 0, 0));
// Assign the texture to the geometry
OSG::GeometryRecPtr geo =
dynamic_cast<OSG::Geometry *>(scene->getCore());
geo->setMaterial(tex);
// Create and setup the SSM
mgr = new OSG::SimpleSceneManager;
mgr->setWindow(gwin);
mgr->setRoot(scene);
// Create a blue background
OSG::SolidBackgroundRecPtr bg = OSG::SolidBackground::create();
bg->setColor(OSG::Color3f(0.1, 0.1, 0.5));
gwin->getPort(0)->setBackground(bg);
mgr->showAll();
OSG::commitChanges();
}
// Give Control to the GLUT Main Loop
glutMainLoop();
return 0;
}