[X11] Throw exception if GLX is not supported

You cannot create an X11/OpenGL context without the GLX extension.
OpenTK will now throw a `NotSupportedException` when this condition is
encountered.

In some cases, it may be possible to enable the EGL backend by passing
`GraphicsContextFlags.Embedded` to the `GraphicsContext` constructor.
This commit is contained in:
thefiddler 2014-06-15 14:30:23 +02:00
parent c657b3d11e
commit 9075129df0

View file

@ -54,14 +54,34 @@ namespace OpenTK.Platform.X11
if (window == null)
throw new ArgumentNullException("window");
// Do not move this lower, as almost everything requires the Display
// property to be correctly set.
Display = ((X11WindowInfo)window).Display;
// Check that GLX is supported. We cannot proceed to create
// an OpenGL context without the GLX extension.
int error_base;
int event_base;
int glx_major;
int glx_minor;
using (new XLock(Display))
{
bool supported = Glx.QueryExtension(Display, out error_base, out event_base);
supported &= Glx.QueryVersion(Display, out glx_major, out glx_minor);
if (supported)
{
Debug.Print("[X11] GLX supported. Version is {0}.{1}", glx_major, glx_minor);
}
else
{
throw new NotSupportedException("[X11] GLX extension is not supported.");
}
}
Mode = ModeSelector.SelectGraphicsMode(
mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples,
mode.AccumulatorFormat, mode.Buffers, mode.Stereo);
// Do not move this lower, as almost everything requires the Display
// property to be correctly set.
Display = ((X11WindowInfo)window).Display;
currentWindow = (X11WindowInfo)window;
currentWindow.VisualInfo = SelectVisual(Mode, currentWindow);