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