![](/img/trans.png)
[英]'System.AccessViolationException' occurred in OpenTK.dll when loading a texture
[英]System.AccessViolationException in any OpenTK.Graphics.OpenGL4.GL Methods
我目前正在學習OpenTK(v 3.1)。 但有一個問題。 當我調用GL。~~~()函數時,總是拋出System.AccessViolationException。
using System;
using OpenTK.Graphics.OpenGL4;
namespace OpenTKTut
{
internal class Program
{
[STAThread]
private static void Main(string[] args)
{
Console.WriteLine(GL.GetString(StringName.Version)); // where the error is thrown
using (MainWindow mw = new MainWindow())
{
mw.VSync = OpenTK.VSyncMode.Off;
mw.Run(144, 144);
}
}
}
}
錯誤消息(韓語翻譯成英語)
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
location: OpenTK.Graphics.OpenGL4.GL.GetString(StringName name) file I:\work\github\opentk\src\OpenTK\Graphics\OpenGL4\GL4.cs:line 28182
location: OpenTKTut.Program.Main(String[] args) file D:\.vsworkplace\OpenTKTut\OpenTKTut\Program.cs:line 12
我很驚訝文件“ I:\\ work \\ github \\ opentk \\ src \\ OpenTK \\ Graphics \\ OpenGL4 \\ GL4.cs”不在我的計算機或存儲中...
請幫忙!
只有在創建OpenGL上下文之后才能調用GL函數,這是通過打開一個窗口來完成的。
您將需要將GL.GetString
移到using
塊中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.