mono/MonoGame — pull request #2398 by thefiddler (2014-04-22 10:05:10+00:00)
Title: WindowsGL & Linux: implement backbuffer color, depth, stencil, multisampling

This PR implements supports for setting the correct OpenGL backbuffer format based on the selected `GraphicsDevice.PresentationParameters`. It also implements support for `PresentInterval`.

The involves two changes:
1. Context construction (foreground and background) is moved from `OpenTKGameWindow` to `GraphicsDevice.OpenGL`. This is required because (a) `GraphicsDevice.PresentationParameters` are not yet available when the `GameWindow` is initialized and (b) both foreground and background contexts must have the same pixel format, or context construction and/or sharing may fail. It is also a good idea in general, because context construction is an extremely heavy operation (e.g. up to 1sec on my rmbp because it has to power up the discrete GPU) - non-graphical applications should not pay this cost.
2. The desired `PresentationParameters` are translated to OpenGL attributes and passed to the context constructor.

`PresentInterval.Immediate`, `One` and `Two` are mapped to OpenGL swap intervals of 0, 1 and 2, respectively (see [EXT_swap_control](http://www.opengl.org/registry/specs/EXT/swap_control.txt)). `PresentInterval.Default` is mapped to OpenGL swap interval -1, which enables adaptive vsync if [EXT_swap_control_tear](http://www.opengl.org/registry/specs/EXT/wgl_swap_control_tear.txt) is supported - if not, OpenTK falls back to regular vsync instead.

Note that this PR is for the backbuffer only (aka default framebuffer). It does not affect multisampling in RenderTexture2D.