From 9f13d1b410fc52c84d6969634a089f4e124d5f14 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Fri, 14 Oct 2016 21:35:53 -0400 Subject: [PATCH] Fix inconsistent frame rate of GlutWindow Add comment Update changelog --- CHANGELOG.md | 5 +++++ dart/gui/GlutWindow.cpp | 3 +++ dart/gui/GlutWindow.hpp | 1 + dart/gui/SimWindow.cpp | 8 ++------ dart/gui/SoftSimWindow.cpp | 6 ------ examples/addDeleteSkels/MyWindow.cpp | 4 +--- examples/atlasSimbicon/MyWindow.cpp | 6 ------ examples/bipedStand/MyWindow.cpp | 8 ++------ examples/hybridDynamics/MyWindow.cpp | 6 ------ examples/jointConstraints/MyWindow.cpp | 6 ------ examples/mixedChain/MyWindow.cpp | 6 ------ examples/rigidCubes/MyWindow.cpp | 8 ++------ examples/rigidShapes/MyWindow.cpp | 6 ------ examples/softBodies/MyWindow.cpp | 6 ------ examples/vehicle/MyWindow.cpp | 8 ++------ 15 files changed, 18 insertions(+), 69 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1557cdbd1482a..0b1f4e9abe4b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -171,6 +171,11 @@ ## DART 5 +### Version 5.1.4 (2016-10-14) + +1. Fixed inconsistent frame rate of GlutWindow + * [Pull request #794](https://github.com/dartsim/dart/pull/794) + ### Version 5.1.3 (2016-10-07) 1. Updated to support Bullet built with double precision (backport of [#660](https://github.com/dartsim/dart/pull/660)) diff --git a/dart/gui/GlutWindow.cpp b/dart/gui/GlutWindow.cpp index dce05a921dd90..9a57268df437b 100644 --- a/dart/gui/GlutWindow.cpp +++ b/dart/gui/GlutWindow.cpp @@ -107,6 +107,9 @@ void GlutWindow::initWindow(int _w, int _h, const char* _name) { #endif // TODO: Disabled use of GL_MULTISAMPLE for Windows. Please see #411 for the // detail. + + glutTimerFunc(mDisplayTimeout, refreshTimer, 0); + // Note: We book the timer id 0 for the main rendering purpose. } void GlutWindow::reshape(int _w, int _h) { diff --git a/dart/gui/GlutWindow.hpp b/dart/gui/GlutWindow.hpp index c944180405992..f0614ee402603 100644 --- a/dart/gui/GlutWindow.hpp +++ b/dart/gui/GlutWindow.hpp @@ -46,6 +46,7 @@ class GlutWindow { GlutWindow(); virtual ~GlutWindow(); + /// \warning This function should be called once. virtual void initWindow(int _w, int _h, const char* _name); // callback functions diff --git a/dart/gui/SimWindow.cpp b/dart/gui/SimWindow.cpp index 78252d84f86f7..2cabfdacf6336 100644 --- a/dart/gui/SimWindow.cpp +++ b/dart/gui/SimWindow.cpp @@ -212,17 +212,13 @@ void SimWindow::keyboard(unsigned char _key, int _x, int _y) { switch (_key) { case ' ': // use space key to play or stop the motion mSimulating = !mSimulating; - if (mSimulating) { + if (mSimulating) mPlay = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case 'p': // playBack mPlay = !mPlay; - if (mPlay) { + if (mPlay) mSimulating = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case '[': // step backward if (!mSimulating) { diff --git a/dart/gui/SoftSimWindow.cpp b/dart/gui/SoftSimWindow.cpp index 4bbf53b331ba9..17201d8708a0f 100644 --- a/dart/gui/SoftSimWindow.cpp +++ b/dart/gui/SoftSimWindow.cpp @@ -60,18 +60,12 @@ void SoftSimWindow::keyboard(unsigned char key, int x, int y) case ' ': // use space key to play or stop the motion mSimulating = !mSimulating; if (mSimulating) - { mPlay = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case 'p': // playBack mPlay = !mPlay; if (mPlay) - { mSimulating = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; // case '[': // step backward // if (!mSimulating) diff --git a/examples/addDeleteSkels/MyWindow.cpp b/examples/addDeleteSkels/MyWindow.cpp index c52cbda642611..560565599ae62 100644 --- a/examples/addDeleteSkels/MyWindow.cpp +++ b/examples/addDeleteSkels/MyWindow.cpp @@ -50,10 +50,8 @@ void MyWindow::keyboard(unsigned char _key, int _x, int _y) { switch (_key) { case ' ': // use space key to play or stop the motion mSimulating = !mSimulating; - if (mSimulating) { + if (mSimulating) mPlay = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case 'q': // Spawn a cube case 'Q': { // Spawn a cube diff --git a/examples/atlasSimbicon/MyWindow.cpp b/examples/atlasSimbicon/MyWindow.cpp index dca7bf9654c6c..cd1450b148127 100644 --- a/examples/atlasSimbicon/MyWindow.cpp +++ b/examples/atlasSimbicon/MyWindow.cpp @@ -98,18 +98,12 @@ void MyWindow::keyboard(unsigned char _key, int _x, int _y) case ' ': // use space key to play or stop the motion mSimulating = !mSimulating; if (mSimulating) - { mPlay = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case 'p': // playBack mPlay = !mPlay; if (mPlay) - { mSimulating = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case '[': // step backward if (!mSimulating) diff --git a/examples/bipedStand/MyWindow.cpp b/examples/bipedStand/MyWindow.cpp index c54000e626581..fb2e1c57dc2d9 100644 --- a/examples/bipedStand/MyWindow.cpp +++ b/examples/bipedStand/MyWindow.cpp @@ -75,17 +75,13 @@ void MyWindow::keyboard(unsigned char _key, int _x, int _y) { switch (_key) { case ' ': // use space key to play or stop the motion mSimulating = !mSimulating; - if (mSimulating) { + if (mSimulating) mPlay = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case 'p': // playBack mPlay = !mPlay; - if (mPlay) { + if (mPlay) mSimulating = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case '[': // step backward if (!mSimulating) { diff --git a/examples/hybridDynamics/MyWindow.cpp b/examples/hybridDynamics/MyWindow.cpp index a510e641adf58..b8548a335a5ca 100644 --- a/examples/hybridDynamics/MyWindow.cpp +++ b/examples/hybridDynamics/MyWindow.cpp @@ -84,18 +84,12 @@ void MyWindow::keyboard(unsigned char _key, int _x, int _y) case ' ': // use space key to play or stop the motion mSimulating = !mSimulating; if (mSimulating) - { mPlay = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case 'p': // playBack mPlay = !mPlay; if (mPlay) - { mSimulating = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case '[': // step backward if (!mSimulating) diff --git a/examples/jointConstraints/MyWindow.cpp b/examples/jointConstraints/MyWindow.cpp index e38fbb9874a48..9170fc1a36913 100644 --- a/examples/jointConstraints/MyWindow.cpp +++ b/examples/jointConstraints/MyWindow.cpp @@ -78,18 +78,12 @@ void MyWindow::keyboard(unsigned char key, int x, int y) case ' ': // use space key to play or stop the motion mSimulating = !mSimulating; if(mSimulating) - { mPlay = false; - glutTimerFunc( mDisplayTimeout, refreshTimer, 0); - } break; case 'p': // playBack mPlay = !mPlay; if (mPlay) - { mSimulating = false; - glutTimerFunc( mDisplayTimeout, refreshTimer, 0); - } break; case '[': // step backward if (!mSimulating) diff --git a/examples/mixedChain/MyWindow.cpp b/examples/mixedChain/MyWindow.cpp index 62807c5fc4b3b..d824e6d437d04 100644 --- a/examples/mixedChain/MyWindow.cpp +++ b/examples/mixedChain/MyWindow.cpp @@ -104,18 +104,12 @@ void MyWindow::keyboard(unsigned char key, int x, int y) case ' ': // use space key to play or stop the motion mSimulating = !mSimulating; if (mSimulating) - { mPlay = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case 'p': // playBack mPlay = !mPlay; if (mPlay) - { mSimulating = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case '[': // step backward if (!mSimulating) diff --git a/examples/rigidCubes/MyWindow.cpp b/examples/rigidCubes/MyWindow.cpp index 696755b37f6ce..5aa0dca5a9fbc 100644 --- a/examples/rigidCubes/MyWindow.cpp +++ b/examples/rigidCubes/MyWindow.cpp @@ -56,17 +56,13 @@ void MyWindow::keyboard(unsigned char _key, int _x, int _y) { switch (_key) { case ' ': // use space key to play or stop the motion mSimulating = !mSimulating; - if (mSimulating) { + if (mSimulating) mPlay = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case 'p': // playBack mPlay = !mPlay; - if (mPlay) { + if (mPlay) mSimulating = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case '[': // step backward if (!mSimulating) { diff --git a/examples/rigidShapes/MyWindow.cpp b/examples/rigidShapes/MyWindow.cpp index 2a88cc36cc48d..2abde37d85205 100644 --- a/examples/rigidShapes/MyWindow.cpp +++ b/examples/rigidShapes/MyWindow.cpp @@ -92,18 +92,12 @@ void MyWindow::keyboard(unsigned char key, int x, int y) case ' ': // use space key to play or stop the motion mSimulating = !mSimulating; if (mSimulating) - { mPlay = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case 'p': // playBack mPlay = !mPlay; if (mPlay) - { mSimulating = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case '[': // step backward if (!mSimulating) diff --git a/examples/softBodies/MyWindow.cpp b/examples/softBodies/MyWindow.cpp index 36e84a78c6211..f81cfb2346e58 100644 --- a/examples/softBodies/MyWindow.cpp +++ b/examples/softBodies/MyWindow.cpp @@ -103,18 +103,12 @@ void MyWindow::keyboard(unsigned char key, int x, int y) case ' ': // use space key to play or stop the motion mSimulating = !mSimulating; if (mSimulating) - { mPlay = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case 'p': // playBack mPlay = !mPlay; if (mPlay) - { mSimulating = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case '[': // step backward if (!mSimulating) diff --git a/examples/vehicle/MyWindow.cpp b/examples/vehicle/MyWindow.cpp index 45817095f7fe2..18fd77de26cff 100644 --- a/examples/vehicle/MyWindow.cpp +++ b/examples/vehicle/MyWindow.cpp @@ -78,17 +78,13 @@ void MyWindow::keyboard(unsigned char _key, int _x, int _y) { switch (_key) { case ' ': // use space key to play or stop the motion mSimulating = !mSimulating; - if (mSimulating) { + if (mSimulating) mPlay = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case 'p': // playBack mPlay = !mPlay; - if (mPlay) { + if (mPlay) mSimulating = false; - glutTimerFunc(mDisplayTimeout, refreshTimer, 0); - } break; case '[': // step backward if (!mSimulating) {