public void Update() { if (animating) { if (_nextTest != null) { initTest(_nextTest); model.setRunningTest(_nextTest); if (_currTest != null) { _currTest.exit(); } _currTest = _nextTest; _nextTest = null; } timeSpent = beforeTime - updateTime; if (timeSpent > 0) { timeInSecs = timeSpent * 1.0f / 1000000000.0f; updateTime = Stopwatch.GetTimestamp(); frameRate = (frameRate * 0.9f) + (1.0f / timeInSecs) * 0.1f; model.setCalculatedFps(frameRate); } else { updateTime = Stopwatch.GetTimestamp(); } if (_currTest != null && updateBehavior == UpdateBehavior.UPDATE_CALLED) { updateTest(); } frameCount++; afterTime = Stopwatch.GetTimestamp(); timeDiff = afterTime - beforeTime; sleepTime = (1000000000 / targetFrameRate - timeDiff) / 1000000; //if (sleepTime > 0) //{ // Thread.Sleep(TimeSpan.FromMilliseconds(sleepTime)); //} beforeTime = Stopwatch.GetTimestamp(); } }
private void initTest(TestbedTest test) { test.init(model); test.getCamera().getTransform().setExtents(viewportHalfWidth, viewportHalfHeight); model.getPanel().grabFocus(); }
public void testChanged(TestbedTest test, int index) { model.getPanel().grabFocus(); _nextTest = test; }