在 C# 中使用 OpenGL? [英] Using OpenGl with C#?
问题描述
C# 有免费的 OpenGL 支持库吗?如果是这样,我应该使用哪一个?在哪里可以找到示例项目?
Is there free OpenGL support libraries for C#? If so, which one do I use and where do I find sample projects?
C# 是否为 OpenGL 提供类?
Does C# provide classes for OpenGL?
推荐答案
OpenTK 是对Tao API,因为它使用具有重载、强类型枚举、异常和标准 .NET 类型的惯用 C# 风格:
OpenTK is an improvement over the Tao API, as it uses idiomatic C# style with overloading, strongly-typed enums, exceptions, and standard .NET types:
GL.Begin(BeginMode.Points);
GL.Color3(Color.Yellow);
GL.Vertex3(Vector3.Up);
与仅反映 C API 的 Tao 相反:
as opposed to Tao which merely mirrors the C API:
Gl.glBegin(Gl.GL_POINTS); // double "gl" prefix
Gl.glColor3ub(255, 255, 0); // have to pass RGB values as separate args
Gl.glVertex3f(0, 1, 0); // explicit "f" qualifier
这使得移植更加困难,但使用起来非常好.
This makes for harder porting but is incredibly nice to use.
作为奖励,它提供字体渲染、纹理加载、输入处理、音频、数学......
As a bonus it provides font rendering, texture loading, input handling, audio, math...
2016 年 1 月 18 日更新:今天 OpenTK 维护者 来自项目,使其未来充满不确定性.论坛里充斥着垃圾邮件.维护者建议改用 MonoGame 或 SDL2#.
Update 18th January 2016: Today the OpenTK maintainer has stepped away from the project, leaving its future uncertain. The forums are filled with spam. The maintainer recommends moving to MonoGame or SDL2#.
2020 年 6 月 30 日更新:OpenTK 的新维护者已经有一段时间了,并且有一个活跃的 Discord 社区.因此,之前使用其他库的建议不一定正确.
Update 30th June 2020: OpenTK has had new maintainers for a while now and has an active discord community. So the previous recommendation of using another library isn't necessarily true.
这篇关于在 C# 中使用 OpenGL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!