OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Statistics display without needing a GUIEventHan


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Alexander Löffler
Guest





PostPosted: Wed Oct 15, 2008 7:39 am    Post subject:
Statistics display without needing a GUIEventHan
Reply with quote

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.


------------------
Post generated by Mail2Forum
Back to top
Mattias Helsing
Guest





PostPosted: Wed Oct 15, 2008 9:37 am    Post subject:
Statistics display without needing a GUIEventHan
Reply with quote

Hi Alex,

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()

hope this helps
Mattias

//! 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 <> wrote:
Quote:
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.




------------------
Post generated by Mail2Forum
Back to top
Alexander Löffler
Guest





PostPosted: Wed Oct 15, 2008 2:18 pm    Post subject:
Statistics display without needing a GUIEventHan
Reply with quote

Hi Mattias,

Mattias Helsing wrote:
Quote:
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.

Quote:
//! 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 <> wrote:
Quote:
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.






------------------
Post generated by Mail2Forum
Back to top
Skylark (Jean-Sébastien Guay)
Professional


Joined: 05 Jan 2009
Posts: 2249

PostPosted: Wed Oct 15, 2008 2:28 pm    Post subject:
Statistics display without needing a GUIEventHan
Reply with quote

Hi Alex,

Quote:
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?

If you're checking for an OpenGL extension, you need to be in a thread
that has a graphics context valid, or use a pre/postdraw camera callback
to do the check. Maybe call the initialize method in a pre-draw callback
which you would put on your main camera?

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay
http://www.cm-labs.com/
http://whitestar02.webhop.org/


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Alexander Löffler
Guest





PostPosted: Wed Oct 15, 2008 3:46 pm    Post subject:
Statistics display without needing a GUIEventHan
Reply with quote

Hi Jean-Sébastien,

Jean-Sébastien Guay wrote:
Quote:
If you're checking for an OpenGL extension, you need to be in a thread
that has a graphics context valid, or use a pre/postdraw camera callback
to do the check. Maybe call the initialize method in a pre-draw callback
which you would put on your main camera?

This helped a lot: as you suggested I call initialize() in a pre-draw callback
of the main camera now, extensions are found and the Stats are displayed nicely.
Thank you!

Alex.



------------------
Post generated by Mail2Forum
Back to top
paul1492
Guest





PostPosted: Wed Oct 15, 2008 4:41 pm    Post subject:
Statistics display without needing a GUIEventHan
Reply with quote

 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 <>
To: OpenSceneGraph Users <>
Sent: Wednesday, October 15, 2008 10:16:02 AM
Subject: Re: Statistics display without needing a GUIEventHandler

Hi Mattias,

Mattias Helsing wrote:
Quote:
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.

Quote:
//! 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 <> wrote:
Quote:
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.











------------------
Post generated by Mail2Forum
Back to top
Buckley, Bob CTR MDA/IC
Guest





PostPosted: Wed Oct 15, 2008 5:45 pm    Post subject:
Statistics display without needing a GUIEventHan
Reply with quote

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: [mailto:] On Behalf Of
Sent: Wednesday, October 15, 2008 10:41 AM
To: OpenSceneGraph Users
Subject: Re: 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 <>
To: OpenSceneGraph Users <>
Sent: Wednesday, October 15, 2008 10:16:02 AM
Subject: Re: Statistics display without needing a GUIEventHandler

Hi Mattias,

Mattias Helsing wrote:
Quote:
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.

Quote:
//! 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 <> wrote:
Quote:
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.

.org


org







Classification: UNCLASSIFIED
Caveats: NONE



------------------
Post generated by Mail2Forum
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Air-Traffic Surveillance Display usin... eskay187 Announcement [ANN] 2 Wed Feb 13, 2019 7:07 am View latest post
No new posts Happy New Year to all OSG Users Chris Hanson General 0 Mon Jan 07, 2019 10:17 am View latest post
No new posts osg-users Digest, Vol 138, Issue 27 Zachary1234 General 0 Tue Jan 01, 2019 1:16 am View latest post
No new posts osgEarth often crashes in multi-displ... xdfanfan General 0 Mon Nov 26, 2018 8:07 am View latest post
No new posts osg-users Digest, Vol 137, Issue 14 poweruserm@live.com.au General 0 Fri Nov 16, 2018 11:16 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP