Hi Robert, Yes, I understand it is not properly a resize, but this usage is common in some frameworks in order to know the initial dimensions of the window and properly initialize projection matrices, etc. Besides that, OSG indeed creates the event —at least on X11 (osgGA::EventQueue::windowResize called from osgViewer::GraphicsWindowX11::createWindow)—, but it cannot be retrieved from the outside in this first time. Maybe it is removed on purpose, but I couldn't spot where in the code it is done.
This event management would save me to do special trickery about having to wait until the graphics context is valid in order to be then able to query the exact dimensions of the window. Nevertheless, if it was never meant to work that way, it is fine for me. Thanks, Alberto Robert Osfield writes: > 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 > > -- Alberto _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

