opentk / GLControl

WinForms control for OpenTK 4.x.
https://opentk.net
Other
55 stars 24 forks source link

Initialize Bindings #40

Open Fabi12345 opened 1 month ago

Fabi12345 commented 1 month ago

Hi I get a runtime error when I run the Testform, it says you need to initialize the OpenGL binding first by calling LoadBindings(). Here is the full message:

System.InvalidOperationException: You need to initialize the OpenGL binding first by calling LoadBindings() or creating a compatible OpenGL window.
   at OpenTK.Graphics.BindingsBase.Uninitialized()
   at OpenTK.Graphics.OpenGL4.GL.Viewport(Int32 x, Int32 y, Int32 width, Int32 height)
   at OpenTK.GLControl.TestForm.Form1.glControl_Resize(Object sender, EventArgs e) in C:\Users\Dol_G_000\VisualStudio\repos\GLControl\OpenTK.GLControl.TestForm\Form1.cs:line 216
   at OpenTK.GLControl.TestForm.Form1.glControl_Load(Object sender, EventArgs e) in C:\Users\Dol_G_000\VisualStudio\repos\GLControl\OpenTK.GLControl.TestForm\Form1.cs:line 138
   at OpenTK.GLControl.GLControl.OnLoad(EventArgs e) in C:\Users\Dol_G_000\VisualStudio\repos\GLControl\OpenTK.GLControl\GLControl.cs:line 598
   at OpenTK.GLControl.GLControl.OnCreateControl() in C:\Users\Dol_G_000\VisualStudio\repos\GLControl\OpenTK.GLControl\GLControl.cs:line 587
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Geladene Assemblys **************
System.Private.CoreLib
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.700.22.55902.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Private.CoreLib.dll.
----------------------------------------
OpenTK.GLControl.TestForm
    Assembly-Version: 1.0.0.0.
    Win32-Version: 1.0.0.0.
    CodeBase: file:///C:/Users/Dol_G_000/VisualStudio/repos/GLControl/OpenTK.GLControl.TestForm/bin/Debug/netcoreapp3.1/OpenTK.GLControl.TestForm.dll.
----------------------------------------
System.Runtime
    Assembly-Version: 4.2.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Runtime.dll.
----------------------------------------
System.Windows.Forms
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.800.122.30903.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/3.1.32/System.Windows.Forms.dll.
----------------------------------------
System.ComponentModel.Primitives
    Assembly-Version: 4.2.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.ComponentModel.Primitives.dll.
----------------------------------------
System.Drawing.Primitives
    Assembly-Version: 4.2.1.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Drawing.Primitives.dll.
----------------------------------------
System.Collections.Specialized
    Assembly-Version: 4.1.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Collections.Specialized.dll.
----------------------------------------
OpenTK.Mathematics
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.0.0.
    CodeBase: file:///C:/Users/Dol_G_000/VisualStudio/repos/GLControl/OpenTK.GLControl.TestForm/bin/Debug/netcoreapp3.1/OpenTK.Mathematics.dll.
----------------------------------------
System.Runtime.InteropServices
    Assembly-Version: 4.2.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Runtime.InteropServices.dll.
----------------------------------------
System.Drawing.Common
    Assembly-Version: 4.0.2.3.
    Win32-Version: 4.700.21.51508.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/3.1.32/System.Drawing.Common.dll.
----------------------------------------
System.Threading
    Assembly-Version: 4.1.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Threading.dll.
----------------------------------------
System.Diagnostics.TraceSource
    Assembly-Version: 4.1.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Diagnostics.TraceSource.dll.
----------------------------------------
System.Collections
    Assembly-Version: 4.1.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Collections.dll.
----------------------------------------
System.Runtime.Extensions
    Assembly-Version: 4.2.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Runtime.Extensions.dll.
----------------------------------------
System.Diagnostics.Debug
    Assembly-Version: 4.1.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Diagnostics.Debug.dll.
----------------------------------------
Microsoft.Win32.Primitives
    Assembly-Version: 4.1.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/Microsoft.Win32.Primitives.dll.
----------------------------------------
System.ComponentModel.EventBasedAsync
    Assembly-Version: 4.1.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.ComponentModel.EventBasedAsync.dll.
----------------------------------------
System.Threading.Thread
    Assembly-Version: 4.1.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Threading.Thread.dll.
----------------------------------------
Accessibility
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.800.122.30903.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/3.1.32/Accessibility.dll.
----------------------------------------
System.ComponentModel.TypeConverter
    Assembly-Version: 4.2.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.ComponentModel.TypeConverter.dll.
----------------------------------------
System.Resources.ResourceManager
    Assembly-Version: 4.1.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Resources.ResourceManager.dll.
----------------------------------------
OpenTK.GLControl
    Assembly-Version: 1.0.0.0.
    Win32-Version: 1.0.0.0.
    CodeBase: file:///C:/Users/Dol_G_000/VisualStudio/repos/GLControl/OpenTK.GLControl.TestForm/bin/Debug/netcoreapp3.1/OpenTK.GLControl.dll.
----------------------------------------
OpenTK.Windowing.Common
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.0.0.
    CodeBase: file:///C:/Users/Dol_G_000/VisualStudio/repos/GLControl/OpenTK.GLControl.TestForm/bin/Debug/netcoreapp3.1/OpenTK.Windowing.Common.dll.
----------------------------------------
Microsoft.Win32.SystemEvents
    Assembly-Version: 4.0.2.0.
    Win32-Version: 4.700.19.56404.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/3.1.32/Microsoft.Win32.SystemEvents.dll.
----------------------------------------
System.Collections.Concurrent
    Assembly-Version: 4.0.15.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Collections.Concurrent.dll.
----------------------------------------
System.ComponentModel
    Assembly-Version: 4.0.4.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.ComponentModel.dll.
----------------------------------------
OpenTK.Windowing.Desktop
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.0.0.
    CodeBase: file:///C:/Users/Dol_G_000/VisualStudio/repos/GLControl/OpenTK.GLControl.TestForm/bin/Debug/netcoreapp3.1/OpenTK.Windowing.Desktop.dll.
----------------------------------------
System.Collections.NonGeneric
    Assembly-Version: 4.1.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Collections.NonGeneric.dll.
----------------------------------------
System.Memory
    Assembly-Version: 4.2.1.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Memory.dll.
----------------------------------------
System.Buffers
    Assembly-Version: 4.0.5.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Buffers.dll.
----------------------------------------
System.Resources.Extensions
    Assembly-Version: 4.0.1.0.
    Win32-Version: 4.700.20.21406.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/3.1.32/System.Resources.Extensions.dll.
----------------------------------------
netstandard
    Assembly-Version: 2.1.0.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/netstandard.dll.
----------------------------------------
System.Drawing
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.800.122.30903.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/3.1.32/System.Drawing.dll.
----------------------------------------
System.ObjectModel
    Assembly-Version: 4.1.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.ObjectModel.dll.
----------------------------------------
System.Linq
    Assembly-Version: 4.2.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Linq.dll.
----------------------------------------
System.Windows.Extensions
    Assembly-Version: 4.0.1.0.
    Win32-Version: 4.700.19.56404.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/3.1.32/System.Windows.Extensions.dll.
----------------------------------------
System.Windows.Forms.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.800.122.30903.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/3.1.32/de/System.Windows.Forms.resources.dll.
----------------------------------------
System.Runtime.InteropServices.RuntimeInformation
    Assembly-Version: 4.0.4.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Runtime.InteropServices.RuntimeInformation.dll.
----------------------------------------
System.Diagnostics.Process
    Assembly-Version: 4.2.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Diagnostics.Process.dll.
----------------------------------------
OpenTK.Graphics
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.0.0.
    CodeBase: file:///C:/Users/Dol_G_000/VisualStudio/repos/GLControl/OpenTK.GLControl.TestForm/bin/Debug/netcoreapp3.1/OpenTK.Graphics.dll.
----------------------------------------
System.Private.Uri
    Assembly-Version: 4.0.6.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Private.Uri.dll.
----------------------------------------
System.Diagnostics.StackTrace
    Assembly-Version: 4.1.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Diagnostics.StackTrace.dll.
----------------------------------------
System.Reflection.Metadata
    Assembly-Version: 1.4.5.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Reflection.Metadata.dll.
----------------------------------------
System.IO.FileSystem
    Assembly-Version: 4.1.2.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.IO.FileSystem.dll.
----------------------------------------
System.Collections.Immutable
    Assembly-Version: 1.2.5.0.
    Win32-Version: 4.700.22.56512.
    CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/3.1.32/System.Collections.Immutable.dll.
----------------------------------------

I also have a project which I updated from 3.3.3.0 to 4.0.0.0 and got the same issue.

Windows 10 Radeon RX 580 AMD Ryzen Threadripper 1920X 12-Core Processor 3.50 GHz Tag 4.0.1 (compiled and unmodified)

NogginBops commented 1 month ago

What version of the GLControl are you using? How are you running the code?

Fabi12345 commented 1 month ago

I tried the two latest tags 4.0.0 and 4.0.1, same result. Compiled and run in Visual studio 2022, but also tried the bash file with .nuke. I tried different configurations of the profile and API in the designer form...with no effect.

Fabi12345 commented 1 month ago

When in the glControl_Load(), the glControl.Context is still null, I think this is troublesome. glcontrol variable Bindingcontext is set somehow, but maybe it should bind to OptenTK.IBindingsContext and not System.Windows.Forms.BindingContext, that's at least what it says when I try to bind it manually, cannot convert. image