On Wed, 2008-11-05 at 13:53 -0500, Jean-Sébastien Guay wrote:
> Hi Jeremy,
> 
> > Everyone asks about this, so I'll try and put a comment in the code
> > somewhere to explain it. The bottom line is that it simply isn't
> > possible to create a pixel-aligned 2D interface in OSG without at least
> > initially forcing a window size. Sure, I could rely on whatever size the
> > user sets in their environment, but I need some way to keep the
> > orthorgraphic camera in sync with the actual dimensions of the
> > application window itself.
> > 
> > Normally, you rely on the RESIZE event in osgGA to inform you of this,
> > and for the most part it works (see src/osgWidget/ViewerEventHandlers)
> > for keeping you in sync with the size of the window. However, a RESIZE
> > event isn't generate for the initial size of the window, nor is it
> > generated when the window is asked to go into "fullscreen" mode.
> > 
> > Until there is some global way of "hooking" into the intial (and any
> > subsequent changes thereafter) window dimensions in a reliable way, we
> > simply have no choice. I spent an afternoon trying to get around this
> > with no avail. If someone can tell me how to get the initial window
> > size, I'll be more than happy to patch osgWidget. :) (I've posted asking
> > about this in the past with no response.) Until then, I do the best I
> > can with what I've got.
> 
> The requirement to have the size at startup makes sense. I have no 
> problem with that. (but thanks for explaining, it's always useful to 
> have a better understanding of the "why").
> 
> What I have problems with is putting the window's top-left corner at 
> (0,0). You can change that without affecting the window's size...
> 
>    viewer.setUpViewInSingleScreen(50, 50, w, h);

Yeah, that's no problem. :) I can add this easy.

> As for letting the viewer set itself up, there should be ways of getting 
> the size of the window after viewer.realize():

That's the key though--I wouldn't want to rely on the viewer being
realized, and it would make the code tricky to do properly in the right
order.

The answer, I think, is me hacking osgViewer to report this data via the
RESIZE event properly, I'm just so overwhelmed with a sense of wanting
to "get this done" I haven't had a chance. :) It is something I will do
eventually, of course.

(Wasn't trying to be inflammatory, if it sounded that way. :))

> * Get the viewport of the main viewer camera 
> (viewer.getCamera()->getViewport()).
> * Or get the graphics context and get the size from there.
> * Or ...
> 
> But as I said, my major concern is putting the window at (0,0). I would 
> find it more "polite" if your examples let the viewer decide, but if 
> that's just not possible, at the very least place the window in a sane 
> initial position.
> 
> J-S

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to