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 

Question about idle event handling in the wxWidgets example


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
ollydbg
Newbie


Joined: 03 Oct 2019
Posts: 1

PostPosted: Thu Oct 03, 2019 9:41 am    Post subject:
Question about idle event handling in the wxWidgets example
Reply with quote

Hi, in the examples\osgviewerWX\osgviewerWX.cpp

I see such code snippet:

Code:

void MainFrame::OnIdle(wxIdleEvent &event)
{
    if (!_viewer->isRealized())
        return;

    _viewer->frame();

    event.RequestMore();
}


This makes the frame() function call runs continuously.

I just change the code by those steps:

1, first, I comment out all the statements in the "void MainFrame::OnIdle(wxIdleEvent &event)", and this means the OnIdle() function just does nothing.

2, second, I add some code snippet to some event handling function like:

Code:


void OSGCanvas::OnMouseWheel(wxMouseEvent &event)
{
    int delta = event.GetWheelRotation() / event.GetWheelDelta() * event.GetLinesPerAction();

    if (_graphics_window.valid()) {
        _graphics_window->getEventQueue()->mouseScroll(
            delta>0 ?
            osgGA::GUIEventAdapter::SCROLL_UP :
            osgGA::GUIEventAdapter::SCROLL_DOWN);
    }

    // those code were added by me, which force a refresh of the view
    MainFrame * f = (MainFrame *)GetParent();

    if (!f->_viewer->isRealized())
        return;

    f->_viewer->frame();

}



My question is: My thought was remove the idle event handling, because it waste some CPU resource to refresh the OpenGL window again and again. My change is try to only update the view when some true event happens. Any ideas?

Thank you!
Back to top
View user's profile Send private message
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 Keyboard event: Remove time between k... sedeki General 0 Thu Nov 07, 2019 1:10 am View latest post
No new posts I have a question about the shading p... newlife958 General 0 Thu Oct 10, 2019 7:12 am View latest post
No new posts How to handlle the window closing eve... blackball General 1 Wed May 01, 2019 9:10 am View latest post
No new posts osgViewer GraphicsWindowX11 Event Han... ericstancliff General 4 Wed Apr 24, 2019 9:43 pm View latest post
No new posts Question about method of building osgQt trexmsuee Build system [build] 1 Thu Apr 11, 2019 2:22 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