X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Ffg_os_osgviewer.cxx;h=b58d60664ba7cacc5fd3b1500868d9f5aa4b8b35;hb=571f7301f2b0b493f90769baa0728f82fa8ea731;hp=af92bc82f58f46b647ac924672a4f5830ecdc0f2;hpb=4f185632815514338f575fc23d68c36488a1e7b1;p=flightgear.git diff --git a/src/Main/fg_os_osgviewer.cxx b/src/Main/fg_os_osgviewer.cxx index af92bc82f..b58d60664 100644 --- a/src/Main/fg_os_osgviewer.cxx +++ b/src/Main/fg_os_osgviewer.cxx @@ -59,8 +59,33 @@ #include "WindowBuilder.hxx" #include "WindowSystemAdapter.hxx" -#if (FG_OSG_VERSION >= 19008) -#define OSG_HAS_MOUSE_CURSOR_PATCH +// Static linking of OSG needs special macros +#ifdef OSG_LIBRARY_STATIC +#include +USE_GRAPHICSWINDOW(); +// Image formats +USE_OSGPLUGIN(bmp); +USE_OSGPLUGIN(dds); +USE_OSGPLUGIN(hdr); +USE_OSGPLUGIN(pic); +USE_OSGPLUGIN(pnm); +USE_OSGPLUGIN(rgb); +USE_OSGPLUGIN(tga); +#ifdef OSG_JPEG_ENABLED + USE_OSGPLUGIN(jpeg); +#endif +#ifdef OSG_PNG_ENABLED + USE_OSGPLUGIN(png); +#endif +#ifdef OSG_TIFF_ENABLED + USE_OSGPLUGIN(tiff); +#endif +// Model formats +USE_OSGPLUGIN(3ds); +USE_OSGPLUGIN(ac); +USE_OSGPLUGIN(ive); +USE_OSGPLUGIN(osg); +USE_OSGPLUGIN(txf); #endif // fg_os implementation using OpenSceneGraph's osgViewer::Viewer class @@ -79,9 +104,6 @@ static osg::ref_ptr mainCamera; void fgOSOpenWindow(bool stencil) { - osg::GraphicsContext::WindowingSystemInterface* wsi - = osg::GraphicsContext::getWindowingSystemInterface(); - viewer = new osgViewer::Viewer; viewer->setDatabasePager(FGScenery::getPagerSingleton()); CameraGroup* cameraGroup = 0; @@ -170,6 +192,8 @@ void fgOSMainLoop() ref_ptr manipulator = globals->get_renderer()->getEventHandler(); viewer->setReleaseContextAtEndOfFrameHint(false); + if (!viewer->isRealized()) + viewer->realize(); while (!viewer->done()) { fgIdleHandler idleFunc = manipulator->getIdleHandler(); fgDrawHandler drawFunc = manipulator->getDrawHandler(); @@ -202,7 +226,6 @@ void fgOSFullScreen() { } -#ifdef OSG_HAS_MOUSE_CURSOR_PATCH static void setMouseCursor(osg::Camera* camera, int cursor) { if (!camera) @@ -227,21 +250,34 @@ static void setMouseCursor(osg::Camera* camera, int cursor) mouseCursor = osgViewer::GraphicsWindow::CrosshairCursor; else if(cursor == MOUSE_CURSOR_LEFTRIGHT) mouseCursor = osgViewer::GraphicsWindow::LeftRightCursor; + else if(cursor == MOUSE_CURSOR_TOPSIDE) + mouseCursor = osgViewer::GraphicsWindow::TopSideCursor; + else if(cursor == MOUSE_CURSOR_BOTTOMSIDE) + mouseCursor = osgViewer::GraphicsWindow::BottomSideCursor; + else if(cursor == MOUSE_CURSOR_LEFTSIDE) + mouseCursor = osgViewer::GraphicsWindow::LeftSideCursor; + else if(cursor == MOUSE_CURSOR_RIGHTSIDE) + mouseCursor = osgViewer::GraphicsWindow::RightSideCursor; + else if(cursor == MOUSE_CURSOR_TOPLEFT) + mouseCursor = osgViewer::GraphicsWindow::TopLeftCorner; + else if(cursor == MOUSE_CURSOR_TOPRIGHT) + mouseCursor = osgViewer::GraphicsWindow::TopRightCorner; + else if(cursor == MOUSE_CURSOR_BOTTOMLEFT) + mouseCursor = osgViewer::GraphicsWindow::BottomLeftCorner; + else if(cursor == MOUSE_CURSOR_BOTTOMRIGHT) + mouseCursor = osgViewer::GraphicsWindow::BottomRightCorner; gw->setCursor(mouseCursor); } -#endif static int _cursor = -1; void fgSetMouseCursor(int cursor) { _cursor = cursor; -#ifdef OSG_HAS_MOUSE_CURSOR_PATCH setMouseCursor(viewer->getCamera(), cursor); for (unsigned i = 0; i < viewer->getNumSlaves(); ++i) setMouseCursor(viewer->getSlave(i)._camera.get(), cursor); -#endif } int fgGetMouseCursor()