From 75bd8e9a1e3101c8399befca79280cf3399f8a3a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 19 Dec 2008 11:36:26 +0000 Subject: [PATCH] Updated wrappers --- applications/osgviewer/osgviewer.cpp | 136 ++++++++++++++--------- src/osgWrappers/genwrapper.conf | 33 ++++++ src/osgWrappers/osg/GL2Extensions.cpp | 7 +- src/osgWrappers/osg/StencilTwoSided.cpp | 7 +- src/osgWrappers/osg/Texture3D.cpp | 42 +------ src/osgWrappers/osg/VertexProgram.cpp | 35 +----- src/osgWrappers/osgAnimation/modified.gw | 3 - 7 files changed, 127 insertions(+), 136 deletions(-) diff --git a/applications/osgviewer/osgviewer.cpp b/applications/osgviewer/osgviewer.cpp index 642233db3..7c6d2f053 100644 --- a/applications/osgviewer/osgviewer.cpp +++ b/applications/osgviewer/osgviewer.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include @@ -29,6 +29,76 @@ #include + +void addEventHandlers(osgViewer::View* view) +{ + // set up the camera manipulators. + view->setCameraManipulator( new osgGA::TrackballManipulator() ); + + // add the state manipulator + view->addEventHandler( new osgGA::StateSetManipulator(view->getCamera()->getOrCreateStateSet()) ); + + // add the thread model handler + view->addEventHandler(new osgViewer::ThreadingHandler); + + // add the window size toggle handler + view->addEventHandler(new osgViewer::WindowSizeHandler); + + // add the stats handler + view->addEventHandler(new osgViewer::StatsHandler); + + // add the record camera path handler + view->addEventHandler(new osgViewer::RecordCameraPathHandler); + + // add the LOD Scale handler + view->addEventHandler(new osgViewer::LODScaleHandler); + + // add the screen capture handler + view->addEventHandler(new osgViewer::ScreenCaptureHandler); +} + + +class AddViewHandler : public osgGA::GUIEventHandler +{ +public: + AddViewHandler(osgViewer::CompositeViewer* viewer, osg::Node* sceneRoot) + : _viewer(viewer), _sceneRoot(sceneRoot) {} + + bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) + { + if (ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN && ea.getKey()== 'a') + { + osgViewer::View* view = new osgViewer::View; + + view->setUpViewInWindow(50, 50, 800, 600); + view->getCamera()->getGraphicsContext()->realize(); + + view->setSceneData(_sceneRoot.get()); + addEventHandlers(view); + + _viewer->stopThreading(); + + _viewer->addView(view); + + osg::notify(osg::NOTICE)<<"osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts()="<< osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts()<getSceneData()->setThreadSafeRefUnref(true); + view->getSceneData()->resizeGLObjectBuffers(osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts()); + + _viewer->startThreading(); + + return true; + } + + return false; + } + +protected: + osg::observer_ptr _viewer; + osg::ref_ptr _sceneRoot; +}; + + int main(int argc, char** argv) { // use an ArgumentParser object to manage the program arguments. @@ -41,7 +111,7 @@ int main(int argc, char** argv) arguments.getApplicationUsage()->addCommandLineOption("--dem ","Load an image/DEM and render it on a HeightField"); arguments.getApplicationUsage()->addCommandLineOption("--login ","Provide authentication information for http file access."); - osgViewer::Viewer viewer(arguments); + osgViewer::CompositeViewer viewer(arguments); unsigned int helpType = 0; if ((helpType = arguments.readHelpType())) @@ -76,55 +146,9 @@ int main(int argc, char** argv) } } - // set up the camera manipulators. - { - osg::ref_ptr keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; - - keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() ); - keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() ); - keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() ); - keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() ); - - std::string pathfile; - char keyForAnimationPath = '5'; - while (arguments.read("-p",pathfile)) - { - osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile); - if (apm || !apm->valid()) - { - unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); - keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm ); - keyswitchManipulator->selectMatrixManipulator(num); - ++keyForAnimationPath; - } - } - - viewer.setCameraManipulator( keyswitchManipulator.get() ); - } - - // add the state manipulator - viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); - - // add the thread model handler - viewer.addEventHandler(new osgViewer::ThreadingHandler); - - // add the window size toggle handler - viewer.addEventHandler(new osgViewer::WindowSizeHandler); - - // add the stats handler - viewer.addEventHandler(new osgViewer::StatsHandler); - - // add the help handler - viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage())); - - // add the record camera path handler - viewer.addEventHandler(new osgViewer::RecordCameraPathHandler); - - // add the LOD Scale handler - viewer.addEventHandler(new osgViewer::LODScaleHandler); - - // add the screen capture handler - viewer.addEventHandler(new osgViewer::ScreenCaptureHandler); + osg::ref_ptr defaultView = new osgViewer::View; + viewer.addView(defaultView.get()); + addEventHandlers(defaultView.get()); // load the data osg::ref_ptr loadedModel = osgDB::readNodeFiles(arguments); @@ -146,13 +170,15 @@ int main(int argc, char** argv) // optimize the scene graph, remove redundant nodes and state etc. - osgUtil::Optimizer optimizer; - optimizer.optimize(loadedModel.get()); + //osgUtil::Optimizer optimizer; + //optimizer.optimize(loadedModel.get()); - viewer.setSceneData( loadedModel.get() ); + defaultView->setSceneData( loadedModel.get() ); + + defaultView->setUpViewInWindow(50, 50, 800, 600); + defaultView->addEventHandler(new AddViewHandler(&viewer, loadedModel.get())); viewer.realize(); return viewer.run(); - } diff --git a/src/osgWrappers/genwrapper.conf b/src/osgWrappers/genwrapper.conf index 8e449531c..2e282e680 100644 --- a/src/osgWrappers/genwrapper.conf +++ b/src/osgWrappers/genwrapper.conf @@ -323,6 +323,39 @@ suppress reflector "osg::ref_ptr< const osgFX::Effect >" # Doxygen incorrectly parses function typedefs as methods +configure reflector "osg::VertexProgram::Extensions" + configure method "__typedef__void__APIENTRY_P1" + replace with "" + end + configure method "__typedef__GLboolean__APIENTRY_P1" + replace with "" + end +end + +configure reflector "osg::StencilTwoSided::Extensions" + configure method "__typedef__void__APIENTRY_P1" + replace with "" + end +end + +configure reflector "osg::Texture3D::Extensions" + configure method "__typedef__void__APIENTRY_P1" + replace with "" + end +end + +configure reflector "osg::GL2Extensions" + configure method "__typedef__void__APIENTRY_P1" + replace with "" + end + configure method "__typedef__GLboolean__APIENTRY_P1" + replace with "" + end + configure method "__typedef__GLuint__APIENTRY_P1" + replace with "" + end +end + configure reflector "osg::BufferObject::Extensions" configure method "__typedef__void__APIENTRY_P1" replace with "" diff --git a/src/osgWrappers/osg/GL2Extensions.cpp b/src/osgWrappers/osg/GL2Extensions.cpp index a60b4564d..eb0382b2b 100644 --- a/src/osgWrappers/osg/GL2Extensions.cpp +++ b/src/osgWrappers/osg/GL2Extensions.cpp @@ -721,12 +721,7 @@ BEGIN_OBJECT_REFLECTOR(osg::GL2Extensions) __void__Set__unsigned_int__GL2Extensions_P1_S, "allows users to override the extensions across graphics contexts. ", "typically used when you have different extensions supported across graphics pipes but need to ensure that they all use the same low common denominator extensions. "); - I_ProtectedMethod1(typedef, GLuint, IN, APIENTRY *, GetHandleProc, - Properties::NON_VIRTUAL, - Properties::NON_CONST, - __typedef__GLuint__APIENTRY_P1, - "", - ""); + I_SimpleProperty(GLuint, CurrentProgram, __GLuint__getCurrentProgram, 0); diff --git a/src/osgWrappers/osg/StencilTwoSided.cpp b/src/osgWrappers/osg/StencilTwoSided.cpp index 9749762af..dce3658ce 100644 --- a/src/osgWrappers/osg/StencilTwoSided.cpp +++ b/src/osgWrappers/osg/StencilTwoSided.cpp @@ -268,12 +268,7 @@ BEGIN_OBJECT_REFLECTOR(osg::StencilTwoSided::Extensions) __void__glActiveStencilFace__GLenum, "", ""); - I_ProtectedMethod1(typedef, void, IN, APIENTRY *, ActiveStencilFaceProc, - Properties::NON_VIRTUAL, - Properties::NON_CONST, - __typedef__void__APIENTRY_P1, - "", - ""); + I_SimpleProperty(bool, StencilTwoSidedSupported, 0, __void__setStencilTwoSidedSupported__bool); diff --git a/src/osgWrappers/osg/Texture3D.cpp b/src/osgWrappers/osg/Texture3D.cpp index 183d8aae8..c28f509e6 100644 --- a/src/osgWrappers/osg/Texture3D.cpp +++ b/src/osgWrappers/osg/Texture3D.cpp @@ -346,42 +346,12 @@ BEGIN_OBJECT_REFLECTOR(osg::Texture3D::Extensions) __void__gluBuild3DMipmaps__GLenum__GLint__GLsizei__GLsizei__GLsizei__GLenum__GLenum__C5_GLvoid_P1, "", ""); - I_ProtectedMethod1(typedef, void, IN, APIENTRY *, GLTexImage3DProc, - Properties::NON_VIRTUAL, - Properties::NON_CONST, - __typedef__void__APIENTRY_P1, - "", - ""); - I_ProtectedMethod1(typedef, void, IN, APIENTRY *, GLTexSubImage3DProc, - Properties::NON_VIRTUAL, - Properties::NON_CONST, - __typedef__void__APIENTRY_P1, - "", - ""); - I_ProtectedMethod1(typedef, void, IN, APIENTRY *, CompressedTexImage3DArbProc, - Properties::NON_VIRTUAL, - Properties::NON_CONST, - __typedef__void__APIENTRY_P1, - "", - ""); - I_ProtectedMethod1(typedef, void, IN, APIENTRY *, CompressedTexSubImage3DArbProc, - Properties::NON_VIRTUAL, - Properties::NON_CONST, - __typedef__void__APIENTRY_P1, - "", - ""); - I_ProtectedMethod1(typedef, void, IN, APIENTRY *, GLCopyTexSubImageProc, - Properties::NON_VIRTUAL, - Properties::NON_CONST, - __typedef__void__APIENTRY_P1, - "", - ""); - I_ProtectedMethod1(typedef, void, IN, APIENTRY *, GLUBuild3DMipMapsProc, - Properties::NON_VIRTUAL, - Properties::NON_CONST, - __typedef__void__APIENTRY_P1, - "", - ""); + + + + + + I_SimpleProperty(GLint, MaxTexture3DSize, 0, __void__setMaxTexture3DSize__GLint); diff --git a/src/osgWrappers/osg/VertexProgram.cpp b/src/osgWrappers/osg/VertexProgram.cpp index 68edd3af8..c1ff5a5c3 100644 --- a/src/osgWrappers/osg/VertexProgram.cpp +++ b/src/osgWrappers/osg/VertexProgram.cpp @@ -257,36 +257,11 @@ BEGIN_OBJECT_REFLECTOR(osg::VertexProgram::Extensions) __void__glProgramLocalParameter4fv__GLenum__GLuint__C5_GLfloat_P1, "", ""); - I_ProtectedMethod1(typedef, void, IN, APIENTRY *, BindProgramProc, - Properties::NON_VIRTUAL, - Properties::NON_CONST, - __typedef__void__APIENTRY_P1, - "", - ""); - I_ProtectedMethod1(typedef, void, IN, APIENTRY *, GenProgramsProc, - Properties::NON_VIRTUAL, - Properties::NON_CONST, - __typedef__void__APIENTRY_P1, - "", - ""); - I_ProtectedMethod1(typedef, void, IN, APIENTRY *, DeleteProgramsProc, - Properties::NON_VIRTUAL, - Properties::NON_CONST, - __typedef__void__APIENTRY_P1, - "", - ""); - I_ProtectedMethod1(typedef, void, IN, APIENTRY *, ProgramStringProc, - Properties::NON_VIRTUAL, - Properties::NON_CONST, - __typedef__void__APIENTRY_P1, - "", - ""); - I_ProtectedMethod1(typedef, void, IN, APIENTRY *, ProgramLocalParameter4fvProc, - Properties::NON_VIRTUAL, - Properties::NON_CONST, - __typedef__void__APIENTRY_P1, - "", - ""); + + + + + I_SimpleProperty(bool, VertexProgramSupported, 0, __void__setVertexProgramSupported__bool); diff --git a/src/osgWrappers/osgAnimation/modified.gw b/src/osgWrappers/osgAnimation/modified.gw index dbdf5eb61..e69de29bb 100644 --- a/src/osgWrappers/osgAnimation/modified.gw +++ b/src/osgWrappers/osgAnimation/modified.gw @@ -1,3 +0,0 @@ -Bone.cpp -LinkVisitor.cpp -RigGeometry.cpp