1

I am builing an interactive application using the latest wxWidgets(3.0.1) and OpenGL(3.3) on Windows. I have gotten to the point where I have a wxGLcanvas rendering onto a wxPanel and it works fine. The rendering is done in the paint event for that GLcanvas. However, I now want to perform simulations with an accurate delta time between updates.

So essentially I would like some sort of functionality that would allow me to have a method like

void Update(float dt)
{
  // Update simulation with accurate time-step
}

I have come across timers but I'm not sure how I could incorporate it into my application to get an accurate dt. Some have mentioned creating a separate thread for that panel to update independently from the rest of the application. Is this an option and roughly how is it implemented if that is the case?

John
  • 619
  • 2
  • 9
  • 24

2 Answers2

0

Timer precision should be good enough to achieve at least ~50 FPS, so they should be good enough for your purpose. You need to use a timer to get regular calls to your timer event handler which can then use a more accurate method (as timers are not guaranteed to be perfectly regular) to determine whether an updated is needed, e.g. using wxDateTime::UNow(), and queue a Refresh() in this case.

Notice that you still will not be able to guarantee regular window refreshes using normal GUI frameworks.

VZ.
  • 21,740
  • 3
  • 39
  • 42
0

What operating system are you using? There is no way in Windows to guarantee an accurate time for an event. Unix, however is a real time operating system ( RTOS ) and it is possible to guarantee event times.

What range of delta times do you care about? The distinction between RTOS's and Windows only matters for times less than 2 to 3 milliseconds ( unless windows becomes ridiculously overloaded ) Since any worthwhile 3D scene will take more that 3 milliseconds to render, this is probably a non-issue!

Of most significance in this kind of question is the response time of human vision. Watching a dynamic diagram such as a plot, people are unaware of any refresh rate faster than 300 ms. If you want to attempt a video realistic effect, you might need a refresh rate approaching 25 ms - but then your problem will not be the accuracy of your timer, but the speed of your scene rendering. So, once again, this is a non-issue.

ravenspoint
  • 19,093
  • 6
  • 57
  • 103