Reputation: 41
I have an OpenGL program running on a few Android devices, without any issues. However, when I run my app on a Kindle Fire, my call to eglSwapInterval()
returns EGL_BAD_PARAMETER
.
My call looks like:
eglSwapInterval( eglGetDisplay( EGL_DEFAULT_DISPLAY ), 1 );
I understand that 1 is the default value, and that values outside of the accepted min and max values will be silently clamped. This is why I'm confused as to why "1" is a bad parameter. My code allows for other values to be passed in, based on an init structure, but the error I'm debugging right now results from passing in 1.
Any ideas?
Thanks.
Upvotes: 0
Views: 2620
Reputation: 892
It looks like the Kindle's EGL implementation has a bug. I'll describe why, and then suggest a workaround.
The default swap interval is indeed 1. From the EGL 1.4 spec, Section 3.9.3 Posting Semantics:
EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint
interval);
[...]
The default swap interval is 1.
And that section also states
interval is silently clamped to minimum and
maximum implementation dependent values before being stored; these values are
defined by EGLConfig attributes EGL_MIN_SWAP_INTERVAL and EGL_MAX_-
SWAP_INTERVAL respectively.
Therefore, eglSwapInterval
is required to accept interval=1
, even if the implementation doesn't support it. The implementation is required to silently clamp it without error.
I suspect that the Kindle emits EGL_BAD_PARAMETER
when interval
is outside the range [EGL_MIN_SWAP_INTERVAL, EGL_MAX_INTERVAL]
. You can discover query the range with eglGetConfigAttrib
.
As a workaround, I suggest that your application query the swap interval bounds, and manually clamp the desired interval to those bounds before calling eglSwapInterval
.
In reply to Clyde: Even in composited environments, such as Android, the swap interval does have meaning and does what you expect. If the vsync interval is 60Hz and the context's swap interval is 2, then eglSwapBuffers will throttle to 30Hz.
Upvotes: 0
Reputation: 271
Maybe this will help:
Currently you can never draw directly to the screen, so this isn't meaningful. You are always drawing into a surface flinger surface, which is composited to the screen when you are done, and screen compositing is vsynced. https://groups.google.com/forum/#!topic/android-developers/HvMZRcp3pt0
(Meant this as a possible reference that it does nothing. But I cannot comment on answers yet.)
Upvotes: 1
Reputation: 7549
As far as I am aware, eglSwapInterval does nothing on Android anyway. So there is probably little point in calling it, and the Kindle implementation may simply throw an error for any call to it if it is unimplemented.
Upvotes: 0