camera movement with the fractional time value



  • Hello,

    I am going through an functional opengl application which I shall be trying to move to Qt with QtQuick and C++ integration. I am following the post "OpenGL under QML"

    The typical opengl application has a render function as follows:

      //timing related calcualtion
    
      //store the current time , which is initially ZERO
      last_time = current_time;
    
      //now ge the current time
      current_time = glutGet(GLUT_ELAPSED_TIME)/1000.0f;
    
      //calculate the fractional time difference
      dt = current_time-last_time;
    

    Initially the current_time and last_time is initialized to ZERO. The fractional value dt is then used to do the camera movement within the scene. How do I achieve something similar from Qt Quick. Probably there is a better way to achieve the same issue in QtQuick. Any hint ?

    By the way, is it possible to enable the code highlighter here in the post. I used do it using the [code] ...... [/code] , but it is not working here.

    Thanks

    [edit: add missing coding tags: 3 ` before and after the code SGaist]


  • Moderators

    Hi,
    you can do this in Javascript like this:

    var t0 = new Date()
    var t1 = new Date()
    var dt = t1 - t0; // delta in ms
    

    Cheers!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.