Modify Program 2.6 so that it calculates the amount of movement for the triangle based on elapsed

Question:

Modify Program 2.6 so that it calculates the amount of movement for the triangle based on elapsed time, rather than a constant amount as it is currently implemented. One approach for this is to get the current time from Java, and use it to calculate the elapsed time since the previous call to display(). Computing animations in this manner will ensure that they move at the same speed regardless of the speed of the particular computer.

Program 2.6Java/JOGL application: // same imports and declarations as before, plus the following: importpublic void display(GLAutoDrawable drawable) { GL4 gl= (GL4) GLContext.getCurrentGL();} gl.gl ProgramUniform1f(rendering Program, offsetLoc, x); gl.glDrawArrays (GL_TRIANGLES,0,3); } .. //

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Computer Graphics Programming In OpenGL With JAVA

ISBN: 9781683922193

2nd Edition

Authors: V. Scott Gordon PhD, John L. Clevenger PhD

Question Posted: