Classification:  UNCLASSIFIED 
Caveats: NONE

This is how I do it:

        Viewer *viewer = new Viewer;
        viewer->addEventHandler(new StatsHandler);
        viewer->getEventQueue()->keyPress('s'); // repeat as necessary


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Wednesday, October 15, 2008 10:41 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Statistics display without needing a GUIEventHandler

 I previously asked this question about turning on the stats without a key 
process. With osgProducer, I used to do: 
viewerEventHandler->setFrameStatsMode(mode).  

Any chance something could be done with to osgViewer to make turning on the 
Statistics easier.  Seems like others in the OSG community would be interested.

Paul P.

----- Original Message ----
From: Alexander Löffler <[EMAIL PROTECTED]>
To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org>
Sent: Wednesday, October 15, 2008 10:16:02 AM
Subject: Re: [osg-users] Statistics display without needing a GUIEventHandler

Hi Mattias,

Mattias Helsing wrote:
> I do a similar thing with the HelpHandler. I subclassed the 
> HelpHandler like below.
> I then instantiate it and add it to the Viewer (and a osgWidget 
> menuitem). Then I call initialize on it *before* viewer.run() but
> *after* viewer.realize()

Thanks a lot for your reply. Your solution is similar to what I already had for 
my custom StatsHandler, except that I had to include a lot more in the 
initialize method, namely the entire switch statement from
StatsHandler::handle() that distinguishes between the different StatsTypes. I 
had to change that, too, such that it does not depend on having called the 
parts for the previous types when switching on a later type.

I am getting closer now; one thing I still cannot manage to do is display GPU 
stats correctly. This works with the original StatHandler, but not with my 
modified one. This obviously depends on whether the GraphicsContexts of all 
Cameras of the hosting Viewer (just one in my case) support the TimerQuery GL 
extension, which they obviously do in general (since the original StatsHandler 
shows the stats), but not at the time I check in the modified version. This 
seems to be a question of call timing. From what point of rendering progress on 
does the GraphicsContext of a Camera support a GL extension, and why does this 
not work earlier?

Alex.

> //! Simple wrapper of the osgViewer::HelpHandler to let me initialize  
>it before first invocation of it's \c handle()  struct MyHelpHandler : 
>public osgViewer::HelpHandler  {
>    MyHelpHandler(osg::ApplicationUsage* au) : 
>osgViewer::HelpHandler(au) {};
>    void initialize(osgViewer::ViewerBase* viewer)
>    {
>        if (!_initialized && viewer)
>        {
>            setUpHUDCamera(viewer);
>            setUpScene(viewer);
>            if(_camera.valid())
>            {
>                _camera->setNodeMask(0);
>                _helpEnabled = false;
>            }
>        }
>    }
> };
> 
> 
> On 10/15/08, Alexander Löffler <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I am trying to display on-screen statistics as provided by the 
>> osgViewer::StatsHandler without the need for doing this via handling 
>> the key presses first. That is, I want to add a command line options 
>> to my application to either display statistics just as frame rate, 
>> full stats, or not at all.
>>
>> Is there an easy way to do that with the available StatsHandler? I 
>> tried subclassing from the handler with the option to set the StatsType 
>> initially.
>> Currently without success, as there seem to be lots of dependencies 
>> of what parts of OSG have to be set up before collecting of stats is 
>> actually possible.
>> For example, some cameras seem not yet to be set up when I 
>> instantiate my handler, collecting GPU stats is disabled in my HUD, etc..
>>
>> Has anyone ever done something similar before?
>>
>> Thanks a lot in advance,
>> Alex.
>> _______________________________________________
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph
>> .org
>>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.
> org
> 
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



      
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Classification:  UNCLASSIFIED 
Caveats: NONE

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to