diff --git a/examples/osgcamera/osgcamera.cpp b/examples/osgcamera/osgcamera.cpp index 26d18c4e5..f8ebfddbb 100644 --- a/examples/osgcamera/osgcamera.cpp +++ b/examples/osgcamera/osgcamera.cpp @@ -222,32 +222,32 @@ int main( int argc, char **argv ) while (arguments.read("--write-config", configfile)) { osgDB::writeObjectFile(viewer, configfile); } -#if 0 - - ModelHandler* modelHandler = new ModelHandler; - for(int i=1; iadd(arguments[i]); + ModelHandler* modelHandler = new ModelHandler; + for(int i=1; iadd(arguments[i]); + } + + viewer.addEventHandler(modelHandler); + } + else + { + // load the scene. + osg::ref_ptr loadedModel = osgDB::readNodeFiles(arguments); + + if (!loadedModel) loadedModel = osgDB::readNodeFile("cow.osg"); + + if (!loadedModel) + { + std::cout << argv[0] <<": No data loaded." << std::endl; + return 1; + } + + viewer.setSceneData(loadedModel.get()); } - viewer.addEventHandler(modelHandler); - -#else - - // load the scene. - osg::ref_ptr loadedModel = osgDB::readNodeFiles(arguments); - - if (!loadedModel) loadedModel = osgDB::readNodeFile("cow.osg"); - - if (!loadedModel) - { - std::cout << argv[0] <<": No data loaded." << std::endl; - return 1; - } - - viewer.setSceneData(loadedModel.get()); -#endif - viewer.realize(); unsigned int numFrames = 0; diff --git a/examples/osgstaticviewer/CMakeLists.txt b/examples/osgstaticviewer/CMakeLists.txt index 5f4f07156..4e447bd78 100644 --- a/examples/osgstaticviewer/CMakeLists.txt +++ b/examples/osgstaticviewer/CMakeLists.txt @@ -1,6 +1,6 @@ #this file is automatically generated -SET(TARGET_ADDED_LIBRARIES osgdb_ive ) +SET(TARGET_ADDED_LIBRARIES osgdb_ive osgdb_freetype ) SET(TARGET_SRC osgstaticviewer.cpp ) #### end var setup ### diff --git a/examples/osgstaticviewer/osgstaticviewer.cpp b/examples/osgstaticviewer/osgstaticviewer.cpp index 3b64cf9b8..c938ee842 100644 --- a/examples/osgstaticviewer/osgstaticviewer.cpp +++ b/examples/osgstaticviewer/osgstaticviewer.cpp @@ -29,15 +29,15 @@ #include +// include the plugins we need USE_OSGPLUGIN(ive); +USE_OSGPLUGIN(freetype); -// extern "C" void graphicswindow_X11(void); +// include the platform specific GraphicsWindow implementation. +USE_GRAPHICSWINDOW(); int main(int argc, char** argv) { - - // graphicswindow_X11(); - // use an ArgumentParser object to manage the program arguments. osg::ArgumentParser arguments(&argc,argv); diff --git a/include/osgDB/Registry b/include/osgDB/Registry index 7b47b7082..4319b9eb3 100644 --- a/include/osgDB/Registry +++ b/include/osgDB/Registry @@ -573,14 +573,9 @@ class RegisterReaderWriterProxy }; -class PluginFunctionProxy +struct PluginFunctionProxy { -public: - - PluginFunctionProxy(CPluginFunction function) - { - (function)(); - } + PluginFunctionProxy(CPluginFunction function) { (function)(); } }; #define USE_OSGPLUGIN(ext) \ @@ -589,7 +584,7 @@ public: #define REGISTER_OSGPLUGIN(ext, classname) \ extern "C" void osgdb_##ext(void) {} \ - static RegisterReaderWriterProxy g_proxy_##classname; + static osgDB::RegisterReaderWriterProxy g_proxy_##classname; } diff --git a/include/osgViewer/GraphicsWindow b/include/osgViewer/GraphicsWindow index e46e78c41..85034a27e 100644 --- a/include/osgViewer/GraphicsWindow +++ b/include/osgViewer/GraphicsWindow @@ -22,6 +22,11 @@ #include +extern "C" +{ + typedef void (* CGraphicsWindowFunction) (void); +} + namespace osgViewer { /** Base class for providing Windowing API agnostic access to creating and managing graphisc window and events. @@ -204,6 +209,23 @@ class GraphicsWindowEmbedded : public GraphicsWindow virtual void grabFocusIfPointerInWindow() {} }; +struct GrapicsWindowFunctionProxy +{ + GrapicsWindowFunctionProxy(CGraphicsWindowFunction function) { (function)(); } +}; + +#define USE_GRAPICSWINDOW_IMPLEMENTATION(ext) \ + extern "C" void graphicswindow_##ext(void); \ + static osgViewer::GrapicsWindowFunctionProxy graphicswindowproxy_##ext(graphicswindow_##ext); + +#if defined(_WIN32) + #define USE_GRAPHICSWINDOW() USE_GRAPICSWINDOW_IMPLEMENTATION(Win32) +#elif defined(__APPLE__) + #define USE_GRAPHICSWINDOW() USE_GRAPICSWINDOW_IMPLEMENTATION(Carbon) +#else + #define USE_GRAPHICSWINDOW() USE_GRAPICSWINDOW_IMPLEMENTATION(X11) +#endif + } #endif diff --git a/src/osgPlugins/freetype/ReaderWriterFreeType.cpp b/src/osgPlugins/freetype/ReaderWriterFreeType.cpp index 2b2d333d3..5b3b74d1f 100644 --- a/src/osgPlugins/freetype/ReaderWriterFreeType.cpp +++ b/src/osgPlugins/freetype/ReaderWriterFreeType.cpp @@ -56,4 +56,4 @@ class ReaderWriterFreeType : public osgDB::ReaderWriter // now register with Registry to instantiate the above // reader/writer. -osgDB::RegisterReaderWriterProxy g_readerWriter_FreeType_Proxy; +REGISTER_OSGPLUGIN(freetype, ReaderWriterFreeType)