本文整理汇总了C++中osg::WindowRecPtr::addPort方法的典型用法代码示例。如果您正苦于以下问题:C++ WindowRecPtr::addPort方法的具体用法?C++ WindowRecPtr::addPort怎么用?C++ WindowRecPtr::addPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::WindowRecPtr
的用法示例。
在下文中一共展示了WindowRecPtr::addPort方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
//.........这里部分代码省略.........
vp->addForeground(pFG);
vp->addForeground(pFGCheck);
// vp->dump();
// Background
OSG::SolidBackgroundUnrecPtr bkgndFBO = OSG::SolidBackground::create();
bkgndFBO->setColor(OSG::Color3f(1.0,0.5,0.5));
// Viewport
vpFBO = OSG::FBOViewport::create();
vpFBO->setCamera (cam );
vpFBO->setBackground(bkgndFBO );
vpFBO->setRoot (root );
vpFBO->setSize (0, 0, 1, 1);
vpFBO->addForeground(pFGCheck);
OSG::FrameBufferObjectUnrecPtr pFBO = OSG::FrameBufferObject::create();
pTexBuffer = OSG::TextureBuffer::create();
OSG::RenderBufferUnrecPtr pDepthBuffer = OSG::RenderBuffer ::create();
pDepthBuffer->setInternalFormat(GL_DEPTH_COMPONENT24 );
pTexBuffer->setTexture(tx1o);
pFBO->setSize(128, 128);
pFBO->setColorAttachment(pTexBuffer, 0);
pFBO->setDepthAttachment(pDepthBuffer );
pFBO->editMFDrawBuffers()->clear();
pFBO->editMFDrawBuffers()->push_back(GL_COLOR_ATTACHMENT0_EXT);
vpFBO->setFrameBufferObject(pFBO);
// Window
std::cout << "GLUT winid: " << winid << std::endl;
GLint glvp[4];
glGetIntegerv( GL_VIEWPORT, glvp );
gwin = OSG::GLUTWindow::create();
gwin->setGlutId(winid);
gwin->setSize( glvp[2], glvp[3] );
win = gwin;
win->addPort(vpFBO );
win->addPort(vp );
win->init();
// Action
rentravact = OSG::RenderAction::create();
// renact->setFrustumCulling(false);
// tball
OSG::Vec3f pos;
pos.setValues(min[0] + ((max[0] - min[0]) * 0.5),
min[1] + ((max[1] - min[1]) * 0.5),
max[2] + ( max[2] - min[2] ) * 1.5 );
float scale = (max[2] - min[2] + max[1] - min[1] + max[0] - min[0]) / 6;
OSG::Pnt3f tCenter(min[0] + (max[0] - min[0]) / 2,
min[1] + (max[1] - min[1]) / 2,
min[2] + (max[2] - min[2]) / 2);
fprintf(stderr, "Startpos : %f %f %f\n", pos[0], pos[1], pos[2]);
tball.setMode( OSG::Trackball::OSGObject );
tball.setStartPosition( pos, true );
tball.setSum( true );
tball.setTranslationMode( OSG::Trackball::OSGFree );
tball.setTranslationScale(scale);
tball.setRotationCenter(tCenter);
// run...
pPoly = OSG::PolygonChunk::create();
pCOver->subChunk(pPoly);
return 0;
}
示例2: init
//.........这里部分代码省略.........
OSG::Vec3f min,max;
file->getVolume().getBounds( min, max );
std::cout << "Volume: from " << min << " to " << max << std::endl;
OSG::MultiCoreUnrecPtr pMCore = OSG::MultiCore::create();
pCOver = OSG::ChunkOverrideGroup::create();
OSG::TransformRecPtr scene_trans = OSG::Transform::create();
pMCore->addCore(scene_trans);
pMCore->addCore(pCOver );
pPoly = OSG::PolygonChunk::create();
OSG::NodeUnrecPtr sceneTrN = OSG::Node::create();
sceneTrN->setCore (pMCore);
sceneTrN->addChild(file );
dlight->addChild(sceneTrN);
// Camera
OSG::PerspectiveCameraRecPtr cam = OSG::PerspectiveCamera::create();
cam->setBeacon(b1n );
cam->setFov (OSG::osgDegree2Rad(60));
cam->setNear (0.1 );
cam->setFar (400 );
// Background
OSG::SolidBackgroundUnrecPtr bkgnd = OSG::SolidBackground::create();
bkgnd->setColor(OSG::Color3f(0,0,0));
// Viewport
OSG::ViewportRecPtr vp = OSG::Viewport::create();
vp->setCamera (cam );
vp->setBackground(bkgnd );
vp->setRoot (root );
vp->setSize (0, 0, 1, 1);
// Window
std::cout << "GLUT winid: " << winid << std::endl;
GLint glvp[4];
glGetIntegerv(GL_VIEWPORT, glvp);
OSG::GLUTWindowUnrecPtr gwin = OSG::GLUTWindow::create();
gwin->setGlutId(winid);
gwin->setSize( glvp[2], glvp[3] );
win = gwin;
win->addPort(vp);
win->init();
// Action
rentravact = OSG::RenderAction::create();
// renact->setFrustumCulling(false);
// tball
OSG::Vec3f pos;
pos.setValues(min[0] + ((max[0] - min[0]) * 0.5),
min[1] + ((max[1] - min[1]) * 0.5),
max[2] + ( max[2] - min[2] ) * 1.5 );
float scale = (max[2] - min[2] + max[1] - min[1] + max[0] - min[0]) / 6;
OSG::Pnt3f tCenter(min[0] + (max[0] - min[0]) / 2,
min[1] + (max[1] - min[1]) / 2,
min[2] + (max[2] - min[2]) / 2);
fprintf(stderr, "Startpos : %f %f %f\n", pos[0], pos[1], pos[2]);
tball.setMode (OSG::Trackball::OSGObject);
tball.setStartPosition (pos, true );
tball.setSum (true );
tball.setTranslationMode (OSG::Trackball::OSGFree );
tball.setTranslationScale(scale );
tball.setRotationCenter (tCenter );
// run...
return 0;
}
示例3: key
//.........这里部分代码省略.........
OSG::FrameBufferObject::create();
pRenBuffer = OSG::RenderBuffer::create();
OSG::RenderBufferUnrecPtr pDepthBuffer_RB =
OSG::RenderBuffer::create();
pDepthBuffer_RB->setInternalFormat(GL_DEPTH_COMPONENT24 );
pRenBuffer->setInternalFormat(GL_RGBA);
OSG::ImageUnrecPtr pImg_RB = OSG::Image::create();
OSG::UInt32 uiImgSize = 4096;
pImg_RB->set(OSG::Image::OSG_RGB_PF, uiImgSize, uiImgSize);
fprintf(stderr, "Image data : %p\n", pImg_RB->getData());
pRenBuffer->setImage(pImg_RB);
pFBO_RB->setSize(uiImgSize, uiImgSize);
pFBO_RB->setColorAttachment(pRenBuffer, 0);
pFBO_RB->setDepthAttachment(pDepthBuffer_RB );
pFBO_RB->editMFDrawBuffers()->clear();
pFBO_RB->editMFDrawBuffers()->push_back(GL_COLOR_ATTACHMENT0_EXT);
vpFBO_RB->setFrameBufferObject(pFBO_RB);
pRenBuffer ->setReadBack (true);
vpFBO_RB->getFrameBufferObject()->setPostProcessOnDeactivate(true);
win->addPort(vpFBO_RB);
dumpImg_RB = true;
}
break;
case 'v':
rentravact->setVolumeDrawing(!rentravact->getVolumeDrawing());
break;
case 'a':
glDisable( GL_LIGHTING );
std::cerr << "Lighting disabled." << std::endl;
break;
case 's':
glEnable( GL_LIGHTING );
std::cerr << "Lighting enabled." << std::endl;
break;
case 'z':
pPoly->setFrontMode(GL_POINT);
pPoly->setBackMode(GL_POINT);
std::cerr << "PolygonMode: Point." << std::endl;
break;
case 'x':
pPoly->setFrontMode(GL_LINE);
pPoly->setBackMode(GL_LINE);
std::cerr << "PolygonMode: Line." << std::endl;
break;
case 'c':
pPoly->setFrontMode(GL_FILL);
pPoly->setBackMode(GL_FILL);
std::cerr << "PolygonMode: Fill." << std::endl;
break;
case 'p':
示例4: doMain
//.........这里部分代码省略.........
cam = OSG::PerspectiveCamera::create();
{
cam->setBeacon( b1n );
cam->setFov( OSG::osgDegree2Rad( 90 ) );
cam->setNear( 0.1f );
cam->setFar( 100000 );
}
// Background
OSG::SolidBackgroundUnrecPtr bkgnd = OSG::SolidBackground::create();
{
bkgnd->setColor(OSG::Color3f(0.3f, 0.3f, 0.3f));
}
// Viewport
vp = OSG::Viewport::create();
{
vp->setCamera( cam );
vp->setBackground( bkgnd );
vp->setRoot( hdrroot );
// vp->setRoot( root );
vp->setSize( 0,0, 1,1 );
}
// Window
OSG::GLUTWindowUnrecPtr gwin;
GLint glvp[4];
glGetIntegerv(GL_VIEWPORT, glvp);
gwin = OSG::GLUTWindow::create();
{
gwin->setGlutId(winid);
gwin->setSize( glvp[2], glvp[3] );
win = gwin;
win->addPort( vp );
win->init();
}
// Action
rentravact = OSG::RenderAction::create();
rentravact->setVolumeDrawing(true);
// rentravact->setFrustumCulling(false);
// tball
OSG::Vec3f pos;
pos.setValues(min[0] + ((max[0] - min[0]) * 0.5),
min[1] + ((max[1] - min[1]) * 0.5),
max[2] + ( max[2] - min[2] ) * 1.5 );
float scale = (max[2] - min[2] + max[1] - min[1] + max[0] - min[0]) / 6;
OSG::Pnt3f tCenter(min[0] + (max[0] - min[0]) / 2,
min[1] + (max[1] - min[1]) / 2,
min[2] + (max[2] - min[2]) / 2);
fprintf(stderr, "Startpos : %f %f %f\n", pos[0], pos[1], pos[2]);
tball.setMode (OSG::Trackball::OSGObject);
tball.setStartPosition (pos, true );
tball.setSum (true );
tball.setTranslationMode (OSG::Trackball::OSGFree );
tball.setTranslationScale(scale );
tball.setRotationCenter (tCenter );
fprintf(stderr, "Create b1n %p %d %d \n",
b1n.get(),
b1n->getRefCount(),
b1n->getWeakRefCount());
fprintf(stderr, "Create t1n %p %d %d \n",
t1n.get(),
t1n->getRefCount(),
t1n->getWeakRefCount());
fprintf(stderr, "Create dlight %p %d %d \n",
dlight.get(),
dlight->getRefCount(),
dlight->getWeakRefCount());
fprintf(stderr, "Create hdrroot %p %d %d \n",
hdrroot.get(),
hdrroot->getRefCount(),
hdrroot->getWeakRefCount());
fprintf(stderr, "Create root %p %d %d \n",
root.get(),
root->getRefCount(),
root->getWeakRefCount());
return 0;
}