Screen/Linux: Fix INTEL_swap_event support.

Use of the extension couldn't get enabled anymore, because our
extension query code failed to detect presence of the extension. This
used to work, then broke. Apparently something was fixed in the
extension query mechanism, which broke our code, or something was
broken in the mechanism which broke our code. Anyway, add additional
checks so we detect support on systems with old style query and new
style query path.

Also allow to force use of extension for ptb low-level debugging if env
variable PSYCH_FORCE_INTEL_swap_event is defined to any value.
Additionally fix some "missing return value" compiler warning.
Screen/Linux: Error detection and workaround for broken Intel ddx.

Add check to make sure that swap scheduling works correctly and never
executes a swap at a 'msc' before the requested 'targetMSC'. If this
fails, switch to swap scheduling fallback path with wait +
glXSwapBuffers and warn user about broken driver. Check is performed
after each swap and during window open startup tests.

This to catch and handle a horrifying bug in all Intel ddx drivers
shipped between June 2011 and at least October 2012. Of course people
who check their Flip timestamps will have noticed this bug, but good to
protect the other ones and to automatically handle the problem.

Screen.mex for 32-Bit Octave from previous commit rebuilt and tested so
far against broken Intel driver. More tests pending.
Screen/Linux: Improve robustness and diagnostic of Screen('Resolution');

Make it more robust against drivers which claim RandR-1.2 support, but
do weird things in mode enumeration, e.g., don't return any modes. Make
it more robust against drivers without RandR-1.2 support at all.

Improve debug diagnostic output to simplfiy debugging of problems with
the function - add more detailed optional debug output about mode
enumeration and matching.
Screen/Linux: Improve interop with apitrace.

Optional env-variable "PSYCH_ALLOW_APITRACE" if defined should make
Linux ptb compatible with apitrace. So far it does disable GLX-1.3
support, as that seems to be one point of pain for apitrace. However,
this is just a start, apitrace still dies when trying to trace.
Screen/Linux: Improve diagnostic messages for Intel ddx bug detection.

Slight cleanup and readability improvements.
Screen/Linux: Make sure new swap scheduling tests only execute for vsynced swaps.

For non-vsynced swaps, skip them, to avoid false positives.
Need to place initial vsync enable before
PsychDetectAndAssignGfxCaps(), as that code triggers the
OML_sync_control correctness tests, which depend on vsync being enabled.
Screen/Linux: Another paranoia check for possible oml-timestamping bugs.

This one has some potential to detect potential future driver bugs in
pageflip completion timestamping on the DRI2/KMS graphics drivers. No
such bug exists yet, but given the amount of work that currently goes
into improving the drivers timestamping/scheduling, this may serve as
an additional correctness check for the graphics stack -- and as a
protection of users against such problems, should they go unnoticed
pre-release.
Screen/Linux: Add additional safety checks via use of INTEL_swap_event ext.

The INTEL_swap_event extension provides one additional bit of
information after each swap: If the swap was performed via pageflip
(good), or via copyswap/blit, or buffer exchange - which would be bad
for timing and timestamping, but can happen on misconfigured systems or
very suboptimal setups.

By default, we now enable event delivery by the extension if the
extension is supported, and check events for this condition: If a
vsync'ed swap on a regular (non-composited) fullscreen window was
performed, it should be a page-flipped swap, otherwise something is
seriously wrong and we output warning messages to the user, telling
that the system is misconfigured or malfunctioning and in need of
attention. On non-vsynced, composited, or non-fullscreen swaps, we
don't check for trouble, as such configs are by definition not
reliable/trustworthy wrt. timing or timestamping in any way, and users
know this -- at least if they read our help ;).

The Screen('GetFlipInfo') function now no longer enables/disables use
of the extension and event delivery, instead it only logically
enables/disables it. The extension is always enabled if supported, the
usercode switch just decides if usercode gets exclusive access to flip
events, or if they are instead directed to our internal trouble
checking code.

Detection of the extension was also improved, to make it robust against
some changes in the extension enumeration mechanism on recent Linux
systems.
Screen: Silence some warnings about beampos queries if OML_sync_control in use.

If we can and do use OML_sync_control timestamping for flip timestamps
and correctness checks, then beamposition queries for beampos
timestamping are redundant/not needed, except for extended debugging or
some special applications.

Therefore silence many of the warnings related to beamposition trouble
in such a case. No need to clutter the console with pretty irrelevant
warnings in such a case. Avoid displaying the warning triangle in such
a case.
Screen: Fix use of OpenML status flags.

Due to wrong use of status flags, disabling the OpenML swap scheduling
accidentally also disabled the use of OpenML timestamping. Fixed.
Screen/Linux: Add some missing lines for INTEL_swap_events checks.

Got lost in previous commit...
Screen: Avoid ugly corrupted startup screen on triple-buffered OpenGL setups.

The Intel graphics drivers on Linux support and enable OpenGL
triple-buffering by default. The existence of a 2nd backbuffer in this
config broke some assumptions of our startup-logo display code, warning
triangle display code, and the initial clearing of the window to
background clear color. This caused the 3rd buffer to get swapped int
uninitialized, containing random pixel trash, which looked really ugly.
Perform 3 init + swapbuffers calls instead of 2 init + swapbuffers call
in logo display, warning display, and initial background color clear in
'OpenWindow' to make startup beautiful again.
Screen for 32-Bit Octave on Linux rebuilt for testing.

For testing of all previously committed changes:

This version can correctly detect and workaround broken Intel-DDX swap
scheduling on Linux. It can properly handle Intel triple-buffering for
artifact free nice startup screens and session startup. All additional
cross-checks work as expected.
Speech(): Add support for Linux and Windows, improve OSX support.

Add Linux and MS-Windows support, and support for some optional
parameters, as well as speaking multiple text strings in succession.

MS-Windows support contributed by Vishal Shah, NYU.
Screen('Openwindow'): Don't init imaging pipeline in single-buffered mode.

It would fail, so don't do it.
Screen/Linux: Enable compatibility with apitrace.

Rebinding vsync related extensions was the culprit for the crashes when
tracing. Fixed. We don't rebind if PSYCH_ALLOW_APITRACE is defined as
env variable.

The wonderful apitrace now works at least under Linux.
Screen for Linux 32/64 Bit Octave and Matlab rebuilt.

To incorporate all the fixes and improvements.