#include #include #include #include #include #include #include #include extern "C" { #include } struct ButtonMapping { int sdl; int rfb; }; ButtonMapping buttonMapping[]={ {1, rfbButton1Mask}, {2, rfbButton2Mask}, {3, rfbButton3Mask}, {0,0} }; static rfbBool resize(rfbClient* client) { static char first=TRUE; osg::Image* image = (osg::Image*)(rfbClientGetClientData(client, 0)); int width=client->width; int height=client->height; int depth=client->format.bitsPerPixel; std::cout<<"resize "< image = new osg::Image; // image->setPixelBufferObject(new osg::PixelBufferObject(image.get())); osg::notify(osg::NOTICE)<<"image = "<MallocFrameBuffer=resize; client->canHandleNewFBSize = TRUE; client->GotFrameBufferUpdate=update; client->HandleKeyboardLedState=kbd_leds; client->HandleTextChat=text_chat; rfbClientSetClientData(client, 0, image.get()); osg::notify(osg::NOTICE)<<"Before rfbInitClient"<s(); float height = image->t(); osg::Geometry* pictureQuad = osg::createTexturedQuadGeometry(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), xyPlane ? osg::Vec3(0.0f,height,0.0f) : osg::Vec3(0.0f,0.0f,height), 0.0f, flip ? 1.0f : 0.0f , 1.0f, flip ? 0.0f : 1.0f); osg::Texture2D* texture = new osg::Texture2D(image.get()); texture->setResizeNonPowerOfTwoHint(false); texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR); texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); pictureQuad->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); osg::Geode* geode = new osg::Geode; geode->addDrawable(pictureQuad); viewer.setSceneData(geode); viewer.addEventHandler(new osgViewer::StatsHandler); RfbThread rfbThread(client); rfbThread.startThread(); return viewer.run(); }