OpenTK NotImplementedException教程

时间:2016-10-24 15:58:22

标签: c# winforms visual-studio opentk

我正在尝试创建一个带有openGL画布的Windows窗体,或者更确切地说是一个GLControl,因此我使用的是openTK。因为我还不熟悉,所以我决定尝试以下tutorial

我花了一段时间才找到允许我在Visual Studio工具箱中添加GLControl的版本;许多不同的版本给了我一个错误(" C中没有组件:... \ OpenTK.GLControl.dll可以放在工具箱上)

使用官方github的当前版本终于让那部分为我工作了。

private void glControl1_Resize(object sender, EventArgs e)
{
   int w = glControl1.Width;
   int h = glControl1.Height;
   glControl1.MakeCurrent();
   GL.MatrixMode(MatrixMode.Projection);
   GL.LoadIdentity();
   GL.ClearColor(Color.SkyBlue);
   GL.Ortho(-w / 2, w / 2, -h / 2, h / 2, -1, 1);
   GL.Viewport(0, 0, w, h);
   GL.End();
   glControl1.SwapBuffers();
}

然而,当我从我的表单中的教程实现它并将该方法分配给设计器中的GLControl时,我得到一个NotImplementedException。 glControl1_Paint(和glControl1_Load)也是如此 我也尝试将这些方法分配给表单本身,但它产生了同样的错误。

我从运行应用程序得到的输出是

'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded  'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\Users\Algernon\documents\visual studio 2015\Projects\AnalogClockTutorial\AnalogClockTutorial\bin\Debug\AnalogClockTutorial.vshost.exe'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
 'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
 'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
 'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
 'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
 'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Deployment\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
 'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0x2c10 has exited with code 0 (0x0).
The thread 0x2b70 has exited with code 0 (0x0).
'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\Users\Algernon\documents\visual studio 2015\Projects\AnalogClockTutorial\AnalogClockTutorial\bin\Debug\AnalogClockTutorial.exe'. Symbols loaded.
'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\Users\Algernon\documents\visual studio 2015\Projects\AnalogClockTutorial\AnalogClockTutorial\bin\Debug\OpenTK.GLControl.dll'. Symbols loaded.
'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\Users\Algernon\documents\visual studio 2015\Projects\AnalogClockTutorial\AnalogClockTutorial\bin\Debug\OpenTK.dll'. Symbols loaded.
'AnalogClockTutorial.vshost.exe' (CLR v4.0.30319: AnalogClockTutorial.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
GraphicsMode.Default = Index: , Color: 32 (8888), Depth: 16, Stencil: 0,  Samples: 0, Accum: 0 (0000), Buffers: 2, Stereo: False
Detected configuration: Windows / .Net
Loaded opengl32.dll: 1794703360
Exception thrown: 'System.DllNotFoundException' in OpenTK.dll
Creating GraphicsContext.
GraphicsMode: Index: , Color: 32 (8888), Depth: 16, Stencil: 0, Samples: 0,   Accum: 0 (0000), Buffers: 2, Stereo: False
IWindowInfo: Windows.WindowInfo: Handle 4130538, Parent (null)
GraphicsContextFlags: Default
Requested version: 1.0
DisplayDevice 1 (secondary) supports 275 resolutions.
DisplayDevice 2 (secondary) supports 92 resolutions.
DisplayDevice 3 (primary) supports 92 resolutions.
[WGL] Creating temporary context to load extensions
Setting pixel format... [WGL] ChoosePixelFormatARB not supported on this  context
10
OpenGL will be bound to window:4130538 on thread:10
Setting pixel format... Exception thrown: 'System.NotImplementedException'  in OpenTK.dll

有没有人碰巧知道造成这个问题的原因以及我该如何解决? 提前谢谢!

1 个答案:

答案 0 :(得分:0)

使用我发布的预发布版本,使用bin \ debug中的.dll副本将GLControl放入我的工具箱,而不是使用NuGet时解决方案中包含的paket文件夹中的那个。

注意:我已将OpenTK.dll,OpenTK.dll.Config和OpenTK.GLControl.dll复制到调试文件夹

指向预发布的链接:

OpenTK.GLControl

OpenTK

安装openTK.GLControl.Next将自动安装OpenTK.Next。由于我无法轻易找到答案,因此我将其发布在此处,而不是删除此问题。