Merge pull request #165 from kleinerm/master

PTB BETA RELEASE "Hammertime!"

* PTB for 32-Bit Matlab on Windows now uses and requires the GStreamer SDK instead of OSSBuilds GStreamer.
* Bugfix for GStreamer on Windows for special pixelformat >= 6.
* Bugfix for Linux + PsychHID.
* Bugfix for OSX crash at window close due to Apple CVDisplayLink bugs on Matlab R2013b.
* OpenGL context sharing support between windowed and fullscreen windows on OSX.
* Improved GUI window support.
* Low-level support for latest AMD GPU's on Linux and with OSX PsychtoolboxKernelDriver.
* WinTabMex support now also for 64-Bit Matlab on Windows.
* And in PlayMoviesDemo's cool section: "Stop! Hammertime!"
Merge pull request #167 from kleinerm/master

Hammertime!
Fix bug in ComputeNakaRushton.  This was not a pretty bug.  Not sure when it was introduced.

The code was dividing the contrast in the numerator by sigma before exponentiation.  This made no sense and is not what the comments said the routine did.  I fixed it to match the comments (which correctly describe the Naka-Rushton.)

If there is code somewhere that counts on this bug, that code will now break.  But it probably should rather than trying to preserve backwards compatibility with what this routine was doing.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Remove dependence on degtorad, radtodeg.  These are in a Matlab toolbox that not everyone has.  Didn't actually test, but I think they should be OK.

Signed-off-by: David Brainard <brainard@psych.upenn.edu>
Screen/PsychImaging: Add support for display rotation via panelfitter.

Extend the Screen() panelfitter to handle rotation of the framebuffer:
Imaging pipelines identity blitter now also accepts optional paramters
for rotation of the final image by some 'Rotation:%f' angle around a
'RotCenter:%f:%f' cx,cy center and applies it if a non-zero angle is
specified.

The panelfitter code takes advantage of this rotation. It adds angle,
cx and cy as new optional parameters for the Screen('PanelFitter')
parameter vector to set those params. If a non-zero angle is requested,
the fallback path with texture blitting via kPsychIdentityBlitChain is
used, instead of the faster glFramebufferBlit code, which is incapable
of rotations.

PsychImaging has new high-level setup code for rotation during panel
fitting, as exposed in PsychImaging('UsePanelFitter') via a new
optional 'angle' parameter, and for convenience, via a new
PsychImaging('UseDisplayRotation') function for display rotation only.
The current setup code has bugs or limitations: It only handles either
scaling/fitting or rotation well, and usually also only rotation by 90
degree increments. Iow. it handles the most common use case right, but
fails in various ways for more exotic or complex demands.

-> Screen for 64-Bit Matlab on OSX rebuilt and tested.
-> A new demo PanelFitterDemo.m demonstrates use of the panelfitter for
display rotation, scaling and panel fitting.
Screen: Allow use of multisample textures for multisample anti-aliasing.

If GL_ARB_texture_multisample extension is supported, then preferrably
create and use multisample textures as color attachments for the
imaging pipeline drawBufferFBO's if multisampling is requested. Only
fallback to good ol' multisampled renderbuffers if textures fail or are
unsupported.

Multisample textures have the advantage that they can be used with the
imaging pipelines identity blit chain, and thereby by the panelfitter
fallback code. This should allow to provide framebuffer rotation for
multisampled framebuffers via the panelfitter.

It also provides yet another fallback for multisample resolve if scaled
multisample resolves are not supported.

So far the theory. In practice the code-path is only compile-tested,
because Apple's crappy os doesn't expose the needed extension under
OpenGL 2.1, despite the gpu being perfectly capable of supporting it.
-> Will need reboot to a real os for testing.
Screen: Disable beamposition queries for Intel gpu's under OSX and Linux.

In light of the latest insights about Intel hw design defects and
possible hard lockups/crashes of Intel chipsets if register reads
aren't serialized on the gpu, use of our homegrown beamposition
implementation via MMIO register direct access is no longer safe, as we
can't serialize access with the os kernel graphics driver.

-> Disable use of PsychtoolboxKernelDriver instances for Intel on OSX
and of direct mmap() MMIO mapping on Linux. This can be overriden via
setenv('PSYCH_ALLOW_DANGEROUS', '1') for testing by the really brave.

-> This is no loss on Linux, as the DRI2/Intel-KMS graphics driver
provides high quality OpenML timestamping anyway.
-> This is a kiss of death on OSX for Intel GPU's if precision timing
is needed, as OSX CGDisplayBeamposition() is not and was not ever
supported on Intel IGP's.
-> On MS-Windows we can continue to use DirectDraw GetScanLine() in the
hope that the MS-Windows Intel gpu drivers properly serialize their
accesses. However, the most likely implementation they have chosen will
make beampos queries less robust and accurate, thereby reducing the
effectiveness of beampos timestamping on Windows as well.

-> Linux as the last bastion of Intel graphics for vision science.
Rebuild ftgl drawtext text rendering plugins for desktop Linux and OSX.

32/64-Bit Linux, 64-Bit OSX rebuilt with latest enhancements.
Screen mex file for all desktop platforms rebuilt.

All except Linux+ARM. This syncs up panelfitter enhancements,
multisample texture support, Intel GPU disablement, Drawtext plugin
support etc.
PanelFitterDemo: Add test code for multisampling + rotation.

For testing on Linux. We know the fallbacks and error handling work,
but not yet if multisample textures bring the expected advantages of
MSAA + framebuffer rotation.
-> Test pending.
Screen/OSX: Fix Intel + No beampos for good.

Make sure we don't spill pointless warnings on hybrid-graphics MBP's
but silently give up on Intel instead.
-> Screen for 64-Bit Octave/Matlab on OSX rebuilt and tested.
Screen: Fix multisample texture support for good.

Testing on Linux showed that the multisample textures can't get
used by the fixed function pipeline! The only way to access texture
data, apart from a glBlitFrameBuffer() call, is via binding of a
special texel fetch shader.

Implement support for such a fetch shader for "manual" multi-sample
resolve during texture blitting in PsychBlitterIdentity(). This is a
bit of a hack, like all things multisample texture related. However,
they need special treatment and they are only sampled from within the
panel fitter support code, either for rotated blits or as a fallback,
so i guess this hack is ok.

-> Screen for 64-Bit Octave on Linux rebuilt and tested.
-> Screen mex not included in this commit, to not interfere with
   release process.
-> Will not rebuild all Screen mex files before release. Too much
   work for the benefit of such a fringe feature. This improvement
   will be rolled out with the beta release after the upcoming release,
   ie., when the mex files get rebuild the next regular time.

-> Now that multisampled framebuffer rotation has been successfully
   tested, remove the test code in PanelFitterDemo.m before the release.
Rebuild all Screen mex files for multisampling + display rotation support.

Rebuilt for all platforms except the ARM-32 Bit target to incorporate
multisample texture support for rotated, anti-aliased stimulus display.
Updated "help PanelFitterDemo" to describe less restrictive situation
with MSAA.
help BeampositionQueries and help SyncTrouble - update and reformat.
Download/UpdatePsychtoolobx - Update and reformat help text.
help Psychtoolbox reformatted and clarified.
Screen, PsychHID, ftgles drawtext plugin rebuilt for Nexus/ARM Linux.

Sync with current state of code.
SuperShapeDemo: Disable on ARM OpenGL-ES due to lack of display lists.
BitsPlusImagingPipelineTest: Make more lenient for acceptable errors.

Tolerance for small conversion errors can now be set via optional
'acceptableerror' parameter. It defaults to 1 unit of output luminance
or color intensity, ie., an allowable conversion error of up to 1 part
in 65535 or an error in the least significant bit of the 16 bit output
signal.

Improve plotting, diagnostic, help text etc.

-> Lenience for a 1 unit error allows Intel HD (Gen 5 "Ironlake"
family) gpu's to pass the test without detrimental effects on actual
experiments. This makes this card useable for such purpose in principle.
GazeContingentDemo - fix small bug.