Permalink
Browse files

[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.
  • Loading branch information...
1 parent c657b3d commit 9075129df06973a64440a86c5ed0f02a3b7856b5 @thefiddler thefiddler committed Jun 15, 2014
Showing with 24 additions and 4 deletions.
  1. +24 −4 Source/OpenTK/Platform/X11/X11GLContext.cs
@@ -54,14 +54,34 @@ static X11GLContext()
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);

0 comments on commit 9075129

Please sign in to comment.