Forum

Modify FPS display in json

12 October 2016 17:43 #12668
Hi,

For my project, I use .json export format and I noticed that we want display FPS, we can use :

exports.init = function () {
        m_app.init({
            canvas_container_id: "main_canvas_container",
            callback: init_cb,
            physics_enabled: true,
            show_fps: true
        });
    }

So : "show_fps: true".

My question is the following :

Is there a way to display fps but in a controlled manner?
I wish I could change where it appears, font color, font size…
It's possible ?

Thanks in advance.
12 October 2016 17:46 #12669
Hi!

Sure, you can do this by registering an fps callback and updating the value of your custom HTML element.
Development Lead | Twitter
13 October 2016 11:13 #12680
Ok thanks, I managed to recover fps.
For interested :
function fps_cb(fps_avg, phy_fps_avg) {
        console.log(fps_avg);
    }

    function load_cb(data_id) {   
        m_main.set_fps_callback(fps_cb);
        ...
    }


Now, I noticed in the main.js some interesting things :

- get_rendered_info() –> What is exactly this infos ? How display or exploit this ?

- pause() –> This method pauses the application but what exactly ? The refresh ? The shadow calculation ? Events ? Everithing ?

pause() is interesting if it release computer capacity, so I want paused my app if the user is in a other webpage and replay if the user come back. How know if the app (or web page) is active ?

Thanks.
14 October 2016 11:03 #12711
- get_rendered_info() –> What is exactly this infos ? How display or exploit this ?
You can just call this function and check the output. But not all browsers support the required extension. Chrome does support it.

- pause() –> This method pauses the application but what exactly ? The refresh ? The shadow calculation ? Events ? Everithing ?
Yes. Basically it pauses everything: graphics/physics/logics. But you don't need to track if the page is active. Browsers are managing this for us. So the page doesn't make any calculations.
Blend4Web developer
14 October 2016 11:29 #12713
Oh, it's very impressive.
In this case, I don't need to do anything, cool
 
Please register or log in to leave a reply.