cocoa: switch to CGL APIs for GL context creation

CGL APIs are lower level thus giving us better control and more options for
the context creation.
cocoa: allow automatic gpu switching

Fixes #820
cocoa: add fallback for automatic GPU switching

Not all the hardware supports kCGLPFASupportsAutomaticGraphicsSwitching
(apparently all Mid-2010 and before MacBooks do not work with it), so fallback
to not asking for this attribute in the GL pixel format.