gui: Make framerate configurable
Default framerate is 30 FPS
Change-Id: Ia05357663905a3babecb95b1e3531ae45fc854c5
(cherry picked from commit 5d3e488568445b830f11aed39bf9542a8be501bf)
diff --git a/gui/animation.cpp b/gui/animation.cpp
index ed32da4..e8bbd2d 100644
--- a/gui/animation.cpp
+++ b/gui/animation.cpp
@@ -126,7 +126,7 @@
if (mLoop == -2) return 0;
// Determine if we need the next frame yet...
- if (++mUpdateCount > 30 / mFPS)
+ if (++mUpdateCount > TW_FRAMERATE / mFPS)
{
mUpdateCount = 0;
if (++mFrame >= mAnimation->GetResourceCount())
diff --git a/gui/gui.cpp b/gui/gui.cpp
index bb80632..e905812 100755
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -528,9 +528,9 @@
timespec diff = TWFunc::timespec_diff(lastCall, curTime);
- // This is really 2 or 30 times per second
+ // This is really 2 or TW_FRAMERATE times per second
// As long as we get events, increase the timeout so we can catch up with input
- long timeout = got_event ? 500000000 : 33333333;
+ long timeout = got_event ? 500000000 : (1.0 / TW_FRAMERATE * 1000000000);
if (diff.tv_sec || diff.tv_nsec > timeout)
{
diff --git a/gui/libguitwrp_defaults.go b/gui/libguitwrp_defaults.go
index 9d7dcef..472836e 100644
--- a/gui/libguitwrp_defaults.go
+++ b/gui/libguitwrp_defaults.go
@@ -323,6 +323,10 @@
cflags = append(cflags, "-DTW_H_OFFSET="+getMakeVars(ctx, "TW_H_OFFSET"))
}
+ if getMakeVars(ctx, "TW_FRAMERATE") != "" {
+ cflags = append(cflags, "-DTW_FRAMERATE="+getMakeVars(ctx, "TW_FRAMERATE"))
+ }
+
if getMakeVars(ctx, "TW_ROUND_SCREEN") == "true" {
cflags = append(cflags, "-DTW_ROUND_SCREEN")
}
diff --git a/gui/objects.hpp b/gui/objects.hpp
index 89cb742..e965255 100755
--- a/gui/objects.hpp
+++ b/gui/objects.hpp
@@ -49,6 +49,10 @@
#define TW_H_OFFSET 0
#endif
+#ifndef TW_FRAMERATE
+#define TW_FRAMERATE 30
+#endif
+
class RenderObject
{
public: