• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Fast periodics?

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,414
If you want to run some checks as fast as possible on Android (preferable faster than the screen refresh) how would you go about doing that? Does Update fulfil that task? For example if I wanted to check run a subroutine 100 or higher times a second instead of 60 or lower?
 
At least on Desktop (glfw) mojo OnRender() is evoked as often as possible. Only OnUpdate() is triggered depending on the SetUpdateRate related timer.
 
At least on Desktop (glfw) mojo OnRender() is evoked as often as possible. Only OnUpdate() is triggered depending on the SetUpdateRate related timer.
Not quite to my knowledge. With SetUpdateRate <> 0 Mojo will try to call OnUpdate in the frequency you set it too. If it doesn't have enough time for that, it will skip rendering so it can update faster. When you call SetUpdateRate(0) there is no restriction and it will be called as often as possible. OnRender will ALWAYS be called after OnUpdate. The only restriction here is the VSYNC then.
 
Okay that's a bummer. Many thanks for the feedback.
 
Thanks for the heads up. I just didn't expect the main loop to use some Sleep() to wait for the next update.

BTW This is the code for glfw
C++:
    while( !glfwWindowShouldClose( _window ) ){
    
        RenderGame();
        
        glfwSwapBuffers( _window );
        
        //Wait for next update
        if( _nextUpdate ){
            double delay=_nextUpdate-GetTime();
            if( delay>0 ) Sleep( delay );
        }
        
        //Update user events
        UpdateEvents();

        //App suspended?       
        if( _suspended ){
            continue;
        }

        //'Go nuts' mode!
        if( !_updateRate ){
            UpdateGame();
            continue;
        }
        
        //Reset update timer?
        if( !_nextUpdate ){
            _nextUpdate=GetTime();
        }
        
        //Catch up updates...
        int i=0;
        for( ;i<4;++i ){
        
            UpdateGame();
            if( !_nextUpdate ) break;
            
            _nextUpdate+=_updatePeriod;
            
            if( _nextUpdate>GetTime() ) break;
        }
        
        if( i==4 ) _nextUpdate=0;
    }
 
If you play a long music file, what thread actually plays the music? Is there a special thread for music in the background?
 
With SetUpdateRate <> 0 Mojo will try to call OnUpdate in the frequency you set it too. If it doesn't have enough time for that, it will skip rendering so it can update faster.
Mike is this true for Mojo2 as well?
 
Can you use some kind of Sleep command in Cerberus OnUpdate?
I was thinking, if the routine gets called as much as it can, it would be a good idea to be able to put it too sleep as fast as possible and make it ready for the next frame and even save some battery power. Or does this happen automatically?

C++:
        //Wait for next update
        if( _nextUpdate ){
            double delay=_nextUpdate-GetTime();
            if( delay>0 ) Sleep( delay );
        }
       
        //Update user events
        UpdateEvents();
 
Mike is this true for Mojo2 as well?
Regarding the frequency of calling OnUpdate, Mojo2 uses mojo.app which houses the logic to all this. So the answer is yes.
But in mojo2 you don't need to call SetUpdateRate in the OnCreate method.
 
Does the Millisecs() function give an up to date value when it is called? If so you could spread calls to your subroutine all over Update and Render, and it can check the time and do its thing if enough time has passed.
 
Back
Top Bottom