diff --git a/examples/osgdistortion/osgdistortion.cpp b/examples/osgdistortion/osgdistortion.cpp index 6cba18fb7..b3181c632 100644 --- a/examples/osgdistortion/osgdistortion.cpp +++ b/examples/osgdistortion/osgdistortion.cpp @@ -100,6 +100,58 @@ struct CommandLineOptions } }; + +class WindowResizedHandler : public osgGA::GUIEventHandler +{ +public: + WindowResizedHandler() + { + } + + virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv) + { + osg::Camera* camera = dynamic_cast(object); + if (!camera) return false; + + const osg::FrameStamp* fs = nv->getFrameStamp(); + + if (ea.getEventType()==osgGA::GUIEventAdapter::RESIZE) + { + OSG_NOTICE<<"Window resized event context="<setTextureSize(width, height); + texture2D->dirtyTextureObject(); + } + } + } + } + return false; + } + +}; + osg::Node* createDistortionSubgraph(CommandLineOptions& options, osg::Node* subgraph, const osg::Vec4& clearColour) { osg::Group* distortionNode = new osg::Group; @@ -141,6 +193,8 @@ osg::Node* createDistortionSubgraph(CommandLineOptions& options, osg::Node* subg camera->addChild(subgraph); distortionNode->addChild(camera); + + camera->addEventCallback(new WindowResizedHandler()); } // set up the hud camera