本文整理汇总了C++中osg::GLUTWindowRecPtr::init方法的典型用法代码示例。如果您正苦于以下问题:C++ GLUTWindowRecPtr::init方法的具体用法?C++ GLUTWindowRecPtr::init怎么用?C++ GLUTWindowRecPtr::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::GLUTWindowRecPtr
的用法示例。
在下文中一共展示了GLUTWindowRecPtr::init方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
OSG::osgInit(argc,argv);
{
int winid = setupGLUT(&argc, argv);
OSG::GLUTWindowRecPtr gwin = OSG::GLUTWindow::create();
gwin->setGlutId(winid);
gwin->init();
if (argc > 1)
scene = createScenegraph(argv[1]);
else
scene = createScenegraph("Data/brick_quads.wrl");
mgr = new OSG::SimpleSceneManager;
mgr->setWindow(gwin );
mgr->setRoot (scene);
mgr->showAll();
OSG::commitChanges();
}
glutMainLoop();
return 0;
}
示例2: main
int main(int argc, char **argv)
{
OSG::osgInit(argc,argv);
{
int winid = setupGLUT(&argc, argv);
OSG::GLUTWindowRecPtr gwin = OSG::GLUTWindow::create();
gwin->setGlutId(winid);
gwin->init();
scene =createScenegraph();
mgr = new OSG::SimpleSceneManager;
mgr->setWindow(gwin );
mgr->setRoot (scene);
mgr->showAll();
OSG::Navigator * nav = mgr->getNavigator();
nav->setFrom(nav->getFrom()+OSG::Vec3f(0,50,0));
OSG::commitChanges();
}
glutMainLoop();
return 0;
}
示例3: doMain
// Initialize GLUT & OpenSG and set up the scene
int doMain(int argc, char **argv)
{
std::cout << "start a cluster server with './testClusterServer -w pipe0'\n"
"press 'c' to connect to the servers.\n"
"press 'd' to disconnect from the servers.\n"
"press 'n' to delete current scene.\n"
"press 't' to create a torus.\n"
"press 'l' to load scene 'tie.wrl'.\n"
<< std::endl;
// OSG init
OSG::osgInit(argc,argv);
OSG::VTKPolyDataMapper::getClassType().dump();
// GLUT init
int winid = setupGLUT(&argc, argv);
// the connection between GLUT and OpenSG
_client_win = OSG::GLUTWindow::create();
_client_win->setGlutId(winid);
_client_win->init();
_client_win->setSize(300,300);
for(OSG::Int32 i=0;i<argc-1;++i)
{
if(argv[i+1] != NULL)
_pipenames.push_back(argv[i+1]);
}
if(_pipenames.empty())
_pipenames.push_back("pipe0");
_root = OSG::Node::create();
_root->setCore(OSG::Group::create());
// create default scene
// NodePtr scene = makeTorus(.5, 2, 16, 16);
OSG::NodeUnrecPtr scene = initVTK();
_root->addChild(scene);
// create the SimpleSceneManager helper
_mgr = OSG::SimpleSceneManager::create();
// tell the manager what to manage
_mgr->setWindow(_client_win );
_mgr->setRoot (_root);
// show the whole scene
_mgr->showAll();
return 0;
}
示例4: main
int main(int argc,char **argv)
{
int winid;
// initialize Glut
glutInit(&argc, argv);
glutInitDisplayMode( GLUT_RGB |GLUT_DEPTH | GLUT_DOUBLE);
if(!argv[1])
{
std::cout << "No name was given!" << std::endl;
return -1;
}
// init OpenSG
OSG::osgInit(argc, argv);
winid = glutCreateWindow(argv[1]);
glutDisplayFunc(display);
glutIdleFunc(display);
glutReshapeFunc(reshape);
glutSetCursor(GLUT_CURSOR_NONE);
ract = OSG::RenderAction::create();
window = OSG::GLUTWindow::create();
window->setGlutId(winid);
window->init();
window->resize(512, 512);
//create a new server that will be connected via multicast
//argv[1] is the name of the server (at least it should be...)
server = new OSG::ClusterServer(window, argv[1], "StreamSock", "");
server->start();
glutMainLoop();
return 0;
}
示例5: main
int main(int argc, char **argv)
{
OSG::osgInit(argc,argv);
{
int winid = setupGLUT(&argc, argv);
OSG::GLUTWindowRecPtr gwin = OSG::GLUTWindow::create();
gwin->setGlutId(winid);
gwin->init();
scene = createScenegraph();
mgr = OSG::SimpleSceneManager::create();
mgr->setWindow(gwin );
mgr->setRoot (scene);
mgr->showAll();
OSG::commitChanges();
}
glutMainLoop();
return 0;
}
示例6: 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);
//.........这里部分代码省略.........
示例7: main
int main(int argc,char **argv)
{
const char *name ="ClusterServer";
const char *connectionType="StreamSock";
// const char *connectionType="Multicast";
bool fullscreen =true;
std::string address ="";
int width=-1,height=300,x=0,y=0;
bool doStereo=false;
char *str;
for(int i = 1 ; i < argc ; ++i)
{
if(argv[i][0] == '-')
{
switch(argv[i][1])
{
case 'm':
connectionType="Multicast";
break;
case 's':
doStereo=true;
break;
case 'w':
fullscreen=false;
break;
case 'e':
exitOnError=true;
break;
case 'a':
address=&(argv[i][2]);
break;
case 'g':
if(argv[i][2] != '\0')
str=argv[i]+2;
else
str=argv[++i];
if(sscanf(str,"%d,%d,%d,%d",
&width,&height,&x,&y)!=4)
{
SWARNING << "Wrong args in -g. Use -gw,h,x,y"
<< std::endl;
cleanup();
exit(0);
}
break;
case 'p':
if(argv[i][2] != '\0')
servicePort=atoi(argv[i]+2);
else
servicePort=atoi(argv[++i]);
break;
case 'j':
if(argv[i][2] != '\0')
serviceGroup=argv[i]+2;
else
serviceGroup=argv[++i];
break;
case 'h':
std::cout << argv[0]
<< "-m "
<< "-s "
<< "-w "
<< "-e "
<< "-g w,h,x,y "
<< "-a Address "
<< "-j group "
<< "-p servicePort "
<< std::endl;
std::cout << "-m use multicast" << std::endl;
std::cout << "-s enable stereo" << std::endl;
std::cout << "-w no fullscreen" << std::endl;
std::cout << "-e exit after closed connection"
<< std::endl;
std::cout << "-g geometry" << std::endl;
std::cout << "-a Address Server network address"
<< std::endl;
std::cout << "-m Address wait for requests on "
<< "multicast group" << std::endl;
std::cout << "-p port wait for requests on port"
<< std::endl;
return 0;
}
}
else
{
name=argv[i];
}
}
try
{
OSG::osgInit (argc, argv);
OSG::ClusterServer::init(argc, argv);
glutInit(&argc, argv);
if(doStereo)
glutInitDisplayMode( GLUT_STEREO |
GLUT_RGB |
//.........这里部分代码省略.........
示例8: 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;
}
示例9: doMain
//.........这里部分代码省略.........
createContainer(composerType.c_str());
OSG::ImageComposer *icPtr =
dynamic_cast<OSG::ImageComposer *>(fcPtr.get());
if(icPtr != NULL)
{
if(dynamic_cast<OSG::PipelineComposer *>(icPtr) != NULL)
{
if(subtilesize>0)
dynamic_cast<OSG::PipelineComposer *>(icPtr)->setTileSize(subtilesize);
dynamic_cast<OSG::PipelineComposer *>(icPtr)->setPipelined(pipelinedBufferRead);
}
if(dynamic_cast<OSG::BinarySwapComposer *>(icPtr) != NULL)
{
if(subtilesize>0)
dynamic_cast<OSG::BinarySwapComposer *>(icPtr)->setTileSize(subtilesize);
}
icPtr->setStatistics(info);
// icPtr->setShort(false);
sortlast->setComposer(icPtr);
}
}
clusterWindow=sortlast;
break;
#ifdef FRAMEINTERLEAVE
case 'I':
frameinterleave=OSG::FrameInterleaveWindow::create();
clusterWindow=frameinterleave;
if(compose)
frameinterleave->setCompose(true);
else
frameinterleave->setCompose(false);
break;
#endif
case 'P':
sortfirst=OSG::SortFirstWindow::create();
sortfirst->setCompose(false);
clusterWindow=sortfirst;
break;
}
if(!autostart.empty())
clusterWindow->editMFAutostart()->push_back(autostart);
for(i=0 ; i<int(servers.size()) ; ++i)
clusterWindow->editMFServers()->push_back(servers[i]);
if(cols < 0)
cols = clusterWindow->getMFServers()->size32() / rows;
switch(type)
{
case 'M':
multidisplay->setHServers(cols);
multidisplay->setVServers(rows);
break;
case 'X':
balancedmultidisplay->setHServers(cols);
balancedmultidisplay->setVServers(rows);
// balancedmultidisplay->setShowBalancing(true);
// balancedmultidisplay->setShowBalancing(info);
break;
}
#ifdef FRAMEINTERLEAVE
clusterWindow->setInterleave(interleave);
#endif
// create client window
clientWindow=OSG::GLUTWindow::create();
// glutReshapeWindow(800,600);
glutReshapeWindow(winwidth,winheight);
clientWindow->setGlutId(winid);
clientWindow->init();
// init scene graph
init(filenames);
// init client
clusterWindow->setConnectionType(connectionType);
// needs to be called before init()!
clusterWindow->setConnectionParams(connectionParameters);
if(clientRendering)
{
clusterWindow->setClientWindow(clientWindow);
}
clusterWindow->setConnectionDestination(connectionDestination);
clusterWindow->setConnectionInterface(connectionInterface);
clusterWindow->init();
if(serverx > 0)
clusterWindow->resize(serverx,servery);
else
clusterWindow->resize(winwidth,winheight);
clientWindow->resize(winwidth,winheight);
// OSG::FieldContainerFactory::the()->dump();
OSG::commitChanges();
glutMainLoop();
return 0;
}
示例10: 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;
}