diff --git a/CMakeLists.txt b/CMakeLists.txt index fd211f5a0..080b9d732 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -297,6 +297,7 @@ FIND_PACKAGE(GDAL) FIND_PACKAGE(CURL) FIND_PACKAGE(ZLIB) FIND_PACKAGE(ITK) +FIND_PACKAGE(LibVNCServer) FIND_PACKAGE(OurDCMTK) SET(wxWidgets_USE_LIBS base core gl net) diff --git a/CMakeModules/FindLibVNCServer.cmake b/CMakeModules/FindLibVNCServer.cmake new file mode 100644 index 000000000..e0308a0da --- /dev/null +++ b/CMakeModules/FindLibVNCServer.cmake @@ -0,0 +1,76 @@ +# Locate gdal +# This module defines +# LIBVNCSERVER_LIBRARY +# LIBVNCSERVER_FOUND, if false, do not try to link to gdal +# LIBVNCSERVER_INCLUDE_DIR, where to find the headers +# +# $LIBVNCSERVER_DIR is an environment variable that would +# correspond to the ./configure --prefix=$LIBVNCSERVER_DIR +# used in building gdal. +# +# Created by Ulrich Hertlein. + +FIND_PATH(LIBVNCSERVER_INCLUDE_DIR rfb/rfb.h + $ENV{LIBVNCSERVER_DIR}/include + $ENV{LIBVNCSERVER_DIR} + $ENV{OSGDIR}/include + $ENV{OSGDIR} + $ENV{OSG_ROOT}/include + ~/Library/Frameworks + /Library/Frameworks + /usr/local/include + /usr/include + /sw/include # Fink + /opt/local/include # DarwinPorts + /opt/csw/include # Blastwave + /opt/include + [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include + /usr/freeware/include +) + +FIND_LIBRARY(LIBVNCCLIENT_LIBRARY + NAMES vncclient + PATHS + $ENV{LIBVNCSERVER_DIR}/lib + $ENV{LIBVNCSERVER_DIR} + $ENV{OSGDIR}/lib + $ENV{OSGDIR} + $ENV{OSG_ROOT}/lib + ~/Library/Frameworks + /Library/Frameworks + /usr/local/lib + /usr/lib + /sw/lib + /opt/local/lib + /opt/csw/lib + /opt/lib + [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib + /usr/freeware/lib64 +) + +FIND_LIBRARY(LIBVNCSERVER_LIBRARY + NAMES vncserver + PATHS + $ENV{LIBVNCSERVER_DIR}/lib + $ENV{LIBVNCSERVER_DIR} + $ENV{OSGDIR}/lib + $ENV{OSGDIR} + $ENV{OSG_ROOT}/lib + ~/Library/Frameworks + /Library/Frameworks + /usr/local/lib + /usr/lib + /sw/lib + /opt/local/lib + /opt/csw/lib + /opt/lib + [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib + /usr/freeware/lib64 +) + +SET(LIBVNCSERVER_FOUND "NO") +IF(LIBVNCSERVER_LIBRARY AND LIBVNCSERVER_INCLUDE_DIR) + SET(LIBVNCSERVER_FOUND "YES") +ENDIF(LIBVNCSERVER_LIBRARY AND LIBVNCSERVER_INCLUDE_DIR) + + diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index adc81da2d..e2fd8836e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -169,8 +169,17 @@ IF(DYNAMIC_OPENSCENEGRAPH) ADD_SUBDIRECTORY(osgwidgetwindow) ENDIF(BUILD_OSGWIDGET) + IF (GLUT_FOUND) + ADD_SUBDIRECTORY(osgviewerGLUT) + ENDIF(GLUT_FOUND) + + IF (LIBVNCSERVER_FOUND) + ADD_SUBDIRECTORY(osgvnc) + ENDIF(LIBVNCSERVER_FOUND) + #ADD_SUBDIRECTORY(osgcegui) + #to add subject to find socket#ADD_SUBDIRECTORY(osgcluster) ELSE(DYNAMIC_OPENSCENEGRAPH) diff --git a/examples/osgforest/osgforest.cpp b/examples/osgforest/osgforest.cpp index 67f1f6b21..42b088df1 100644 --- a/examples/osgforest/osgforest.cpp +++ b/examples/osgforest/osgforest.cpp @@ -43,6 +43,8 @@ #include #include +#include + #include #include @@ -1100,6 +1102,9 @@ int main( int argc, char **argv ) osg::ref_ptr ttm = new ForestTechniqueManager; + // add the stats handler + viewer.addEventHandler(new osgViewer::StatsHandler); + viewer.addEventHandler(new TechniqueEventHandler(ttm.get())); viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet())); diff --git a/examples/osgvnc/CMakeLists.txt b/examples/osgvnc/CMakeLists.txt new file mode 100644 index 000000000..ffd6a1461 --- /dev/null +++ b/examples/osgvnc/CMakeLists.txt @@ -0,0 +1,9 @@ +SET(TARGET_SRC osgvnc.cpp) + +SET(TARGET_EXTERNAL_LIBRARIES ${LIBVNCCLIENT_LIBRARY} ${SDL_LIBRARY} ${ZLIB_LIBRARY} ${JPEG_LIBRARY} ) + +INCLUDE_DIRECTORIES(${LIBVNCCLIENT_INCLUDE_DIR} ${SDL_INCLUDE_DIR}) + +#### end var setup ### +SETUP_EXAMPLE(osgvnc) + diff --git a/examples/osgvnc/osgvnc.cpp b/examples/osgvnc/osgvnc.cpp new file mode 100644 index 000000000..085aa8a26 --- /dev/null +++ b/examples/osgvnc/osgvnc.cpp @@ -0,0 +1,177 @@ +#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(); +} +