[osg-users] I want to use VncClient

2010-10-21 Thread Jianfeng Zhang
Hi all,

I download a file just like:

#include osgWidget/VncClient
#include osgViewer/Viewer
#include osgViewer/ViewerEventHandlers
class EscapeHandler : public osgGA::GUIEventHandler
{
public:
EscapeHandler() {}

bool handle(const osgGA::GUIEventAdapter
ea,osgGA::GUIActionAdapter aa)
{
if (ea.getHandled()) return false;

switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYUP):
{
if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Escape)
{
osgViewer::View* view =
dynamic_castosgViewer::View*(aa);
if (view) view-getViewerBase()-setDone(true);

return true;
}
}

default:
return false;
}
return false;
}
};

int main(int argc,char** argv)
{
osg::ArgumentParser arguments(argc, argv);
osgViewer::Viewer viewer(arguments);

osgWidget::GeometryHints hints(osg::Vec3(0.0f,0.0f,0.0f),
   osg::Vec3(1.0f,0.0f,0.0f),
   osg::Vec3(0.0f,0.0f,1.0f),
   osg::Vec4(1.0f,1.0f,1.0f,1.0f),

osgWidget::GeometryHints::RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO);

osg::ref_ptrosg::Group group = new osg::Group;

for(int i=1; iarguments.argc(); ++i)
{
if (!arguments.isOption(i))
{
osg::ref_ptrosgWidget::VncClient vncClient = new
osgWidget::VncClient;
if (vncClient-connect(arguments[i], hints))
{
group-addChild(vncClient.get());

hints.position.x() += 1.1f;
}
}
}

viewer.setSceneData(group.get());

viewer.addEventHandler(new osgViewer::StatsHandler);

// add a custom escape handler, but disable the standard viewer one to
enable the vnc images to handle
// the escape without it getting caught by the viewer.
viewer.addEventHandler(new EscapeHandler);
viewer.setKeyEventSetsDone(0);

return viewer.run();
}


Then ,I use command g++ osgv.cpp -o osgv -losg -lvncclient -lvncserver
-losg -losgViewer -losgWidget

./osgv 127.0.0.1:0

output Warning: Could not find plugin to read objects from file 127.0.0.1:
insecure.vnc.

How can I connect vnc?

Thanks very much
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] I want to use VncClient

2010-10-21 Thread Robert Osfield
Hi Jianfeng? Zhang?  Could you sign with the name you wish to be
addressed as, thanks.

As for using the vnc support, you'll need the libvncserver dependency
and then reconfigure the build system to compile that OSG's vnc
plugin.

Robert.

On Thu, Oct 21, 2010 at 8:30 AM, Jianfeng Zhang zjf.ha2...@gmail.com wrote:
 Hi all,

 I download a file just like:

 #include osgWidget/VncClient
 #include osgViewer/Viewer
 #include osgViewer/ViewerEventHandlers
 class EscapeHandler : public osgGA::GUIEventHandler
 {
     public:
     EscapeHandler() {}

     bool handle(const osgGA::GUIEventAdapter
 ea,osgGA::GUIActionAdapter aa)
     {
     if (ea.getHandled()) return false;

     switch(ea.getEventType())
     {
     case(osgGA::GUIEventAdapter::KEYUP):
     {
     if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Escape)
     {
     osgViewer::View* view =
 dynamic_castosgViewer::View*(aa);
     if (view) view-getViewerBase()-setDone(true);

     return true;
     }
     }

     default:
     return false;
     }
     return false;
     }
 };

 int main(int argc,char** argv)
 {
     osg::ArgumentParser arguments(argc, argv);
     osgViewer::Viewer viewer(arguments);

     osgWidget::GeometryHints hints(osg::Vec3(0.0f,0.0f,0.0f),
    osg::Vec3(1.0f,0.0f,0.0f),
    osg::Vec3(0.0f,0.0f,1.0f),
    osg::Vec4(1.0f,1.0f,1.0f,1.0f),

 osgWidget::GeometryHints::RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO);

     osg::ref_ptrosg::Group group = new osg::Group;

     for(int i=1; iarguments.argc(); ++i)
     {
     if (!arguments.isOption(i))
     {
     osg::ref_ptrosgWidget::VncClient vncClient = new
 osgWidget::VncClient;
     if (vncClient-connect(arguments[i], hints))
     {
     group-addChild(vncClient.get());

     hints.position.x() += 1.1f;
     }
     }
     }

     viewer.setSceneData(group.get());

     viewer.addEventHandler(new osgViewer::StatsHandler);

     // add a custom escape handler, but disable the standard viewer one to
 enable the vnc images to handle
     // the escape without it getting caught by the viewer.
     viewer.addEventHandler(new EscapeHandler);
     viewer.setKeyEventSetsDone(0);

     return viewer.run();
 }


 Then ,I use command g++ osgv.cpp -o osgv -losg -lvncclient -lvncserver
 -losg -losgViewer -losgWidget

 ./osgv 127.0.0.1:0

 output Warning: Could not find plugin to read objects from file
 127.0.0.1:insecure.vnc.

 How can I connect vnc?

 Thanks very much




 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org