OpenTK-GL不存在

问题描述

嗨,所以我从OpenTK开始,仅遵循this website上的教程,而我则this tutorial,它说要编写代码:

protected override void OnLoad(EventArgs e)
{
    GL.ClearColor(0.2f,0.3f,1.0f);

    base.OnLoad(e);
}

但是当我尝试编写GL时,它并不会出现在智能和生成GL的输出中:/directory/that/the/file/is/in/Game.cs(13,13): Error CS0103: The name 'GL' does not exist in the current context (CS0103) (OpenTKProject)。我正在使用所有OpenTK命名空间,但是它不起作用。我正在使用Visual Studio for Mac版本8.7.4(内部版本34)和MacOS 10.13.6 Heigh Sierra,并通过带有警告的NuGet安装了OpenTK和OpenTK.GLControl,并显示警告:

/Users/User/Projects/OpenGLProject/OpenGLProject/OpenGLProject.csproj: Warning NU1701: Package 'OpenTK 3.2.0' was restored using '.NETFramework,Version=v4.6.1,.NETFramework,Version=v4.6.2,Version=v4.7,Version=v4.7.1,Version=v4.7.2,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project. (NU1701) (OpenGLTK)

/Users/User/Projects/OpenTKProject/OpenTKProject/OpenTKProject.csproj: Warning NU1701: Package 'OpenTK.GLControl 3.1.0' was restored using '.NETFramework,Version=v3.1'. This package may not be fully compatible with your project. (NU1701) (OpenGLTK)

谢谢!

解决方法

据我所知,在dotnet5(也称为.NetCore)中完全实现/支持程序包方面仍然存在差距,而且我也不太了解在哪里可以找到比较备忘单等。我认为.NET 4.8或不管是最后一个LTS Windows发行版的.NET是什么,将来它们似乎都将重点放在大量跨平台可用性上,因此可能需要一段时间。

经验丰富的.NET专家的其他贡献也许可以使我们对此有所了解。

,

你的函数声明应该有一个对象。它应该是这样的:

void OnLoad(EventArgs e,Object o)
{
//your code here
}

如果这不是问题,您是否使用 OpenTK.Graphics.OpenGL?如果不是,那将是你的问题!还要确保您使用的是 OpenTK。

//Insert this code into the top of the file :)
using OpenTK;
using OpenTK.Graphics.OpenGL;

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...