diff --git a/src/Avalonia.OpenGL/Egl/EglPlatformOpenGlInterface.cs b/src/Avalonia.OpenGL/Egl/EglPlatformOpenGlInterface.cs index a6d8c1e98d..a1ac2a9d37 100644 --- a/src/Avalonia.OpenGL/Egl/EglPlatformOpenGlInterface.cs +++ b/src/Avalonia.OpenGL/Egl/EglPlatformOpenGlInterface.cs @@ -44,10 +44,13 @@ namespace Avalonia.OpenGL.Egl public IGlContext CreateContext() => Display.CreateContext(null); public IGlContext CreateSharedContext() => Display.CreateContext(PrimaryEglContext); - + public EglSurface CreateWindowSurface(IntPtr window) { + if (window == IntPtr.Zero) + throw new OpenGlException($"Window {window} is invalid."); + using (PrimaryContext.MakeCurrent()) { var s = Display.EglInterface.CreateWindowSurface(Display.Handle, Display.Config, window,