Hi Alberto, Strictly speaking I would interpret a resize event as one relating to when a resized. When a window is first created it isn't being resized so a resize event isn't probably appropriate. I could see how it might be convenient a resize event for those using it this way.
For tracking the window size you actually need to use a resize event, you should be able to get the window dimensions to the window, osgGA::GUIEventAdapter attaches the pointer to the window that created it. Robert. On 16 September 2013 16:57, Alberto Luaces <[email protected]> wrote: > Hi, > > I need to know the dimensions of the window OSG creates because I have > to adapt the GUI of my program to the proportions of the view. > > An elegant way of doing it is to capture the RESIZE events in order to > get the current dimensions of the window. However, at window creation > OSG creates the event, but somehow it never reaches user code. > > In the following code, the resize event is handled each time the window > is toggled from fullscreen to windowed mode by pressing "f", but the > first resize event (at creation) is missing. > > Is it a bug or something else? > > Thanks, > > --8<---------------cut here---------------start------------->8--- > #Include <osgViewer/Viewer> > #include <osgViewer/ViewerEventHandlers> > #include <iostream> > > class ResizeHandler: public osgGA::GUIEventHandler > { > public: > > virtual bool handle( > const osgGA::GUIEventAdapter&, > osgGA::GUIActionAdapter&, > osg::Object*, > osg::NodeVisitor* > ); > }; > > bool ResizeHandler::handle( > const osgGA::GUIEventAdapter& ea, > osgGA::GUIActionAdapter&, > osg::Object*, > osg::NodeVisitor* > ) > { > if (ea.getEventType() == osgGA::GUIEventAdapter::RESIZE) > std::cerr << "Resize event, time = " << ea.getTime() << "\n"; > } > > int main(int argc, char *argv[]) > { > osgViewer::Viewer v; > > v.addEventHandler(new ResizeHandler); > v.addEventHandler(new osgViewer::WindowSizeHandler); > > v.run(); > > return 0; > } > --8<---------------cut here---------------end--------------->8--- > > > -- > Alberto > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

