Frame rate limiter

This commit is contained in:
Charles J. Cliffe
2014-11-16 23:20:48 -05:00
parent 3614c2ad9f
commit a7d7ec0d93
9 changed files with 412 additions and 6 deletions
+8 -2
View File
@@ -22,9 +22,10 @@ wxEND_EVENT_TABLE()
ScopeCanvas::ScopeCanvas(wxWindow *parent, int *attribList) :
wxGLCanvas(parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize,
wxFULL_REPAINT_ON_RESIZE), parent(parent) {
wxFULL_REPAINT_ON_RESIZE), parent(parent), frameTimer(0) {
glContext = new ScopeContext(this, &wxGetApp().GetContext(this));
timer.start();
}
ScopeCanvas::~ScopeCanvas() {
@@ -75,5 +76,10 @@ void ScopeCanvas::OnKeyDown(wxKeyEvent& event) {
}
void ScopeCanvas::OnIdle(wxIdleEvent &event) {
Refresh(false);
timer.update();
frameTimer += timer.lastUpdateSeconds();
if (frameTimer > 1.0/30.0) {
Refresh(false);
frameTimer = 0;
}
}