diff --git a/src/osgProducer/Viewer.cpp b/src/osgProducer/Viewer.cpp index 54bb97d7b..9d4c5a9bb 100644 --- a/src/osgProducer/Viewer.cpp +++ b/src/osgProducer/Viewer.cpp @@ -979,6 +979,15 @@ void Viewer::cleanup_frame() ++itr) { (*itr)->releaseGLObjects(); + + ViewerEventHandler* veh = dynamic_cast(itr->get()); + if (veh) + { + // switch off stats so it doesn't try to redraw them. + veh->setFrameStatsMode(ViewerEventHandler::NO_STATS); + veh->setDisplayHelp(false); + veh->setWriteImageOnNextFrame(false); + } } OsgCameraGroup::cleanup_frame(); diff --git a/src/osgProducer/ViewerEventHandler.cpp b/src/osgProducer/ViewerEventHandler.cpp index 09a8fca3d..febeb3db8 100644 --- a/src/osgProducer/ViewerEventHandler.cpp +++ b/src/osgProducer/ViewerEventHandler.cpp @@ -104,11 +104,41 @@ public: virtual void operator()( const Producer::Camera & camera); + typedef std::vector< osg::ref_ptr > TextList; + void releaseTextList(const TextList& list) const + { + for(TextList::const_iterator itr = list.begin(); + itr != list.end(); + ++itr) + { + (*itr)->releaseGLObjects(); + } + } + void releaseGLObjects() const { - { for(TextList::const_iterator itr = _descriptionList.begin(); itr != _descriptionList.end(); ++itr) (*itr)->releaseGLObjects(); } - { for(TextList::const_iterator itr = _optionList.begin(); itr != _optionList.end(); ++itr) (*itr)->releaseGLObjects(); } - { for(TextList::const_iterator itr = _explanationList.begin(); itr != _explanationList.end(); ++itr) (*itr)->releaseGLObjects(); } + releaseTextList(_descriptionList); + releaseTextList(_optionList); + releaseTextList(_explanationList); + releaseTextList(_statsLabelList); + releaseTextList(_infoLabelList); + releaseTextList(_sceneStatsLabelList); + releaseTextList(_cullTimeText); + releaseTextList(_drawTimeText); + releaseTextList(_gpuTimeText); + + if (_frameRateLabelText.valid()) _frameRateLabelText->releaseGLObjects(); + if (_frameRateCounterText.valid()) _frameRateCounterText->releaseGLObjects(); + if (_updateTimeText.valid()) _updateTimeText->releaseGLObjects(); + + if (_positionText.valid()) _positionText->releaseGLObjects(); + if (_orientationText.valid()) _orientationText->releaseGLObjects(); + if (_speedText.valid()) _speedText->releaseGLObjects(); + + if (_numVerticesText.valid()) _numVerticesText->releaseGLObjects(); + if (_numPrimitivesText.valid()) _numPrimitivesText->releaseGLObjects(); + if (_numDrawablesText.valid()) _numDrawablesText->releaseGLObjects(); + } protected: @@ -125,7 +155,6 @@ protected: void displayHelp(); void createHelpText(); - typedef std::vector< osg::ref_ptr > TextList; bool _helpInitialized; TextList _descriptionList; TextList _optionList; diff --git a/src/osgText/Font.cpp b/src/osgText/Font.cpp index fcabca2ca..ee718af3a 100644 --- a/src/osgText/Font.cpp +++ b/src/osgText/Font.cpp @@ -256,12 +256,14 @@ Font::Glyph* Font::getGlyph(unsigned int charcode) void Font::releaseGLObjects(osg::State* state) const { - for(GlyphTextureList::const_iterator itr=_glyphTextureList.begin(); - itr!=_glyphTextureList.end(); - ++itr) - { - (*itr)->releaseGLObjects(state); - } + for(GlyphTextureList::const_iterator itr=_glyphTextureList.begin(); + itr!=_glyphTextureList.end(); + ++itr) + { + (*itr)->releaseGLObjects(state); + } + const_cast(this)->_glyphTextureList.clear(); + const_cast(this)->_sizeGlyphMap.clear(); } osg::Vec2 Font::getKerning(unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType) @@ -280,12 +282,8 @@ bool Font::hasVertical() const void Font::addGlyph(unsigned int width, unsigned int height, unsigned int charcode, Glyph* glyph) { - - //cout << "charcode "<<(char)charcode<<" "<<&_glyphTextureList<releaseGLObjects(state); + getActiveFont()->releaseGLObjects(state); } diff --git a/src/osgWrappers/osg/CullSettings.cpp b/src/osgWrappers/osg/CullSettings.cpp index af92abf14..c9d0d434a 100644 --- a/src/osgWrappers/osg/CullSettings.cpp +++ b/src/osgWrappers/osg/CullSettings.cpp @@ -40,6 +40,7 @@ BEGIN_ENUM_REFLECTOR(osg::CullSettings::VariablesMask) I_EnumLabel(osg::CullSettings::CULL_MASK); I_EnumLabel(osg::CullSettings::CULL_MASK_LEFT); I_EnumLabel(osg::CullSettings::CULL_MASK_RIGHT); + I_EnumLabel(osg::CullSettings::CLEAR_COLOR); I_EnumLabel(osg::CullSettings::NO_VARIABLES); I_EnumLabel(osg::CullSettings::ALL_VARIABLES); END_REFLECTOR diff --git a/src/osgWrappers/osg/Drawable.cpp b/src/osgWrappers/osg/Drawable.cpp index 01b8987f7..24d0ad4fe 100644 --- a/src/osgWrappers/osg/Drawable.cpp +++ b/src/osgWrappers/osg/Drawable.cpp @@ -217,6 +217,7 @@ BEGIN_OBJECT_REFLECTOR(osg::Drawable::DrawCallback) I_Method0(const char *, className); I_Method2(void, drawImplementation, IN, osg::State &, x, IN, const osg::Drawable *, x); I_Method2(void, drawImplementation, IN, osg::RenderInfo &, renderInfo, IN, const osg::Drawable *, drawable); + I_MethodWithDefaults1(void, releaseGLObjects, IN, osg::State *, x, 0); END_REFLECTOR BEGIN_OBJECT_REFLECTOR(osg::Drawable::EventCallback) diff --git a/src/osgWrappers/osg/NodeCallback.cpp b/src/osgWrappers/osg/NodeCallback.cpp index 18a4ad7cf..45e4fbc56 100644 --- a/src/osgWrappers/osg/NodeCallback.cpp +++ b/src/osgWrappers/osg/NodeCallback.cpp @@ -15,6 +15,7 @@ #include #include #include +#include // Must undefine IN and OUT macros defined in Windows headers #ifdef IN @@ -39,6 +40,7 @@ BEGIN_OBJECT_REFLECTOR(osg::NodeCallback) I_Method0(const osg::NodeCallback *, getNestedCallback); I_Method1(void, addNestedCallback, IN, osg::NodeCallback *, nc); I_Method1(void, removeNestedCallback, IN, osg::NodeCallback *, nc); + I_MethodWithDefaults1(void, releaseGLObjects, IN, osg::State *, x, 0); I_Property(osg::NodeCallback *, NestedCallback); I_PublicMemberProperty(osg::ref_ptr< osg::NodeCallback >, _nestedCallback); END_REFLECTOR diff --git a/src/osgWrappers/osgGA/SimpleViewer.cpp b/src/osgWrappers/osgGA/SimpleViewer.cpp index 4a5e9ed54..85fe853e6 100644 --- a/src/osgWrappers/osgGA/SimpleViewer.cpp +++ b/src/osgWrappers/osgGA/SimpleViewer.cpp @@ -55,6 +55,7 @@ BEGIN_OBJECT_REFLECTOR(osgGA::SimpleViewer) I_Method0(void, frameUpdateTraversal); I_Method0(void, frameCullTraversal); I_Method0(void, frameDrawTraversal); + I_Method0(void, releaseAllGLObjects); I_Method0(void, cleanup); I_Method0(void, requestRedraw); I_MethodWithDefaults1(void, requestContinuousUpdate, IN, bool, x, true); diff --git a/src/osgWrappers/osgProducer/Viewer.cpp b/src/osgWrappers/osgProducer/Viewer.cpp index 139c4b01a..92961f17a 100644 --- a/src/osgWrappers/osgProducer/Viewer.cpp +++ b/src/osgWrappers/osgProducer/Viewer.cpp @@ -125,6 +125,7 @@ BEGIN_OBJECT_REFLECTOR(osgProducer::Viewer) I_Method0(osg::Quat, getOrientation); I_Method1(void, getUsage, IN, osg::ApplicationUsage &, usage); I_Method0(void, updatedSceneData); + I_Method0(void, cleanup_frame); I_StaticMethod0(const char *, getDefaultImageFileName); I_Property(osg::AnimationPath *, AnimationPath); I_ReadOnlyProperty(osg::NodePath, CoordinateSystemNodePath); diff --git a/src/osgWrappers/osgProducer/ViewerEventHandler.cpp b/src/osgWrappers/osgProducer/ViewerEventHandler.cpp index 6f9bac0a2..3334d364b 100644 --- a/src/osgWrappers/osgProducer/ViewerEventHandler.cpp +++ b/src/osgWrappers/osgProducer/ViewerEventHandler.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -49,6 +50,7 @@ BEGIN_OBJECT_REFLECTOR(osgProducer::ViewerEventHandler) I_Method1(void, setWriteImageOnNextFrame, IN, bool, writeImageOnNextFrame); I_Method1(void, setWriteImageFileName, IN, const std::string &, filename); I_Method0(const std::string &, getWriteImageFileName); + I_MethodWithDefaults1(void, releaseGLObjects, IN, osg::State *, x, 0); I_Property(bool, DisplayHelp); I_Property(osgProducer::ViewerEventHandler::FrameStatsMode, FrameStatsMode); I_ReadOnlyProperty(osgProducer::OsgCameraGroup *, OsgCameraGroup);