Screen/Waffle: Enable home-grown frame sequential stereo and async flips on EGL backends.

With EGL windowing backend, a given surface (==onscreen windows framebuffer)
must only be bound to at most one rendering context. For multi-threaded ops,
we must have the glswapcontext bound inside the flipper-thread and to the
window framebuffer surface. Therefore the main thread and master/gluser
contexts must not be bound to the same window system framebuffer surface,
or rendering and swapping will fail.

If kPsychFrameSequentialStereo is active on a EGL system, we can solve this:

1. kPsychFrameSequentialStereo implies fully active imaging pipeline, ie.,
   masterthread only renders to pipeline drawBufferFBO's, other pipeline
   FBO's and finally into finalizedFBO's. -> No need to ever touch the
   windows system framebuffer -> No need to bind the surface on master thread
   contexts -> swapper thread can bind the surface on its own glswapcontext.

2. If EGL extension KHR_surfaceless_context is supported, then we can make
   contexts current without binding them to a EGL surface.

3. 1 & 2 -> Detach master thread contexts from windows surface immediately
   before exit from Screen('Openwindow') and mark windowRecord so future calls
   to PsychSetGLContext() or PsychSetUserGLContext() will bind respective
   contexts, but never bind them to the EGL backing surface of the window during
   the remaining lifetime of the onscreen window.

If an async flip is requested without frame sequential stereo, we do a handshake
between the async flip thread and masterthread:

1. Before async flip is triggered in flipthread, the masterthread unbinds its contexts
   and sets the veto flag to only allow binding of surfaceless contexts while flip
   is pending.

2. The async flip thread binds its context to the surface then schedules and finally
   executes/finalizes the flip. Then it unbinds its context (from the surface) and
   signals swap completion to master.

3. Master removes its surface-veto and rebinds its context (to the surface).

4. Rendering on master (to the EGL surface) can proceed while flip thread is
   sleeping.

5. Goto 1.

Masterthread contexts can still be bound, but only without attaching to the
backing EGL surface, so only one thread at a time has its context bound to
the EGL surface of the onscreen window.

For async flips we couldn't simply let the helper-thread leave its context
permanently bound, as async flips are supposed to also work without imaging
pipeline active, therefore must work without fbo virtualized framebuffers,
therefore masterthreads contexts must be able to render directly to window
backbuffer (== EGL backing surface) inbetween async flips.

=> This works sort-of on X11/EGL backend with OpenGL-ES1 context. Sort of because
   testing is difficult, as the only test system i have with X11/EGL suppport has
   graphics driver problems with multi-threaded swapping even on the good old
   classic X11/GLX backend, so frameseq-stereo only works for about 1 second before
   crash. The matching error pattern and 1 second success suggests this is a
   driver bug, not a multi-threading bug in ptb's EGL implementation.
Screen/Waffle: Change fallback order to OpenGL->ES1->ES2->ES3

As we currently don't support OpenGL-ES2/3 it makes sense to
have fallback priorities that have a chance of actually working,
ie., prefer OpenGL desktop, fallback to ES-1 on failure.
Screen/Waffle: Temporarily disable eglSwapInterval().

The proprietary desktop OpenGL drivers from NVidia currently
don't support EGL, so we couldn't test OpenGL-ES support on
those if we had eglSwapInterval() as undefined symbol in our code.

PsychOSSetVBLSyncLevel() will be a no-op on EGL backends, but
testing on desktop Linux + NVidia binary blob should be possible.

No big deal, as the default swapinterval of EGL is 1 == what we want
99.9% of the time anyway.
Screen/Waffle: Make moglcore functional.

Screen now exports the finally chosen display backend and rendering
api to the host runtime by setting the same environment variables
that can be used to override its choice of backend/api.

moglcore on Linux checks the PSYCH_USE_DISPLAY_BACKEND variable
and if it exists (== Waffle backend instead of classic X11/GLX backend
in use), what display backend is in use. If the backend isn't GLX,
then it skips glewInit(), which would crash on a non GLX setup, and
instead relies on the fact that the special glewInit() inside Screen()
will have already setup all GL entry points and symbols, exposing them
to the global address space - and thereby moglcore - due to the Screen
re-dlopen() procedure. On other os'es or with glx backend or classic
backend, moglcore performs glewInit() as usual.

-> This makes moglcore functional. However, we basically don't have
   any interesting demos for testing, as almost all of our code
   uses immediate mode glBegin()/glEnd() rendering, which is not
   supported on OpenGL-ES rendering apis.

=> Screen.mex and moglcore.mex for 64-Bit Octave on Linux rebuilt.
Screen/Waffle: Fixes for NVidia proprietary OpenGL-ES implementation.

glOrtho2f() is exposed instead of glOrtho2fOES(), so remap it in
Waffle window glue.

OpenGL-ES 1.0 was misdetected by GLEW as OpenGL-1.0. Fix this by
continuing with enumeration instead of bailing.

-> At least some basic stuff works now on NVidia binary blob.
Screen/Waffle: Make backend switching and exposure more robust.

Make sure that choice of backend stays fixed throughout a Octave/Matlab
session, regardless what usercode or runtime does.

Expose backend types via environment variables more robust - Variables
always reflect type of active display/opengl backends.

moglcore now uses glx vs. non-glx backend info to call glewInit() or
glewContextInit(), just as Screen does internally, to make backend
based enumeration as robust as possible, not only on Octave + embedded
devices, but also on future Matlab + desktop non-GLX backends.

GLEW modified for moglcore as in Screen by copying glew.c from Screen's
version to moglcore's version.

Now backend selection/switching and interop with moglcore works
robust on NVidia proprietary drivers with GLES backends as well.

-> Screen and moglcore mex rebuilt for 64-Bit Octave on Linux.
Screen/GLES: Try to make floating point textures work on ES.

Some fixes and robustness improvements, but still not fully functions,
i think.
Screen/GLES: Try to make FBO support more reliable.

Mark FBO's supported if any of the desktop GL extensions is exposed,
not only if GL_OES_framebuffer_object is present. NVidia binary blob
exposes the "wrong" extension string (desktop instead of OES) for
OES, so make us more accepting here.

Temporarily disable float framebuffer check and just assume that
whenever fbo's + float textures are supported, float fbo's are
supported as well. This to make testable how real implementations
behave here.