Open philstopford opened 2 years ago
OpenGL is only supported in GTK at the moment, thanks to the complexity of setting up a GL context in each platform. OpenTK had been used, earlier in the project's life, to do the heavy lifting there, but its complexity and lack of .NET Core support (in the 3.x branch, anyway) led to it being dropped. This was practical since D3D is assumed to be available in Windows, Metal in macOS, and GTK has the built-in GLArea control to set up an OpenGL context for us.
In future it's not theoretically impossible to do the work of creating/managing contexts ourselves on platforms like Windows, but it's a non-trivial task as I understand it, and is beyond at least my abilities.
OK, so should we consider throwing an error to indicate the absence of support if the user attempts to request this backend?
I think that's a worthwhile idea, I hate wasting time on errors like this too. Sorry I didn't think of it way back when.
I guess each platform handler would need to have some sort of property listing the supported backends, and then check against that? Maybe somewhere in InitializeGraphicsBackend. I don't have a design immediately in mind for this, but I'm sure we can come up with something.
Under WIndows, for WinForms or WPF, I get an error if I try to use the OpenGL backend by forcing it in the MainForm constructor :
Hardware tested is a laptop targeted 3070 running 471.96 drivers, and also a desktop 1070 with the same drivers. Both fail in the same manner. Direct3D11 and Vulkan backends work without issue, I see the same crash for the PR that attempts to make OpenGL work with GTK
Crash is :
System.InvalidCastException: Unable to cast object of type 'Eto.Veldrid.Wpf.WpfVeldridSurfaceHandler' to type 'IOpenGL'. at Eto.Veldrid.VeldridSurface.get_OpenGL() in D:\development\git\Eto.Veldrid\src\Eto.Veldrid\VeldridSurface.cs:line 54 at Eto.Veldrid.VeldridSurface.InitializeGraphicsBackend(InitializeEventArgs e) in D:\development\git\Eto.Veldrid\src\Eto.Veldrid\VeldridSurface.cs:line 154 at Eto.Veldrid.VeldridSurface.Callback.OnInitializeBackend(VeldridSurface s, InitializeEventArgs e) in D:\development\git\Eto.Veldrid\src\Eto.Veldrid\VeldridSurface.cs:line 33 at Eto.Veldrid.Wpf.WpfVeldridSurfaceHandler.Control_Loaded(Object sender, RoutedEventArgs e) in D:\development\git\Eto.Veldrid\src\Eto.Veldrid.Wpf\WpfVeldridSurfaceHandler.cs:line 58 at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e) at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent) at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root) at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks() at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks() at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget) at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget) at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget) at System.Windows.Interop.HwndTarget.OnResize() at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam) at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)