First of all, what is OpenTK?
首先,什么是OpenTK?
Simply put, the Open Toolkit is a free project that allows you to use OpenGL, OpenGL|ES, OpenCL and OpenAL APIs from managed languages.
简而言之,Open Toolkit是一个免费项目,允许您使用托管语言中的OpenGL、OpenGL|ES、OpenCL和OpenAL API。
OpenTK started life as an experimental fork of the Tao framework before during the summer of 2006. It's original intention was to provide a cleaner wrapper than Tao.OpenGL, but it quickly grew in focus: right now, it provides access to various Khronos and Creative APIs and handles the necessary initialization logic for each API. As such, the Open Toolkit is most similar to projects like Tao, SlimDX, SDL or GLFW.
OpenTK在2006年夏天开始作为Tao框架的实验分支。它的初衷是提供比Tao.OpenGL更干净的包裹器,但它很快成为焦点:现在,它提供了对各种Khronos和Creative API的访问,并为每个API处理必要的初始化逻辑。因此,开放工具包(OpenToolKit,即为opentk)与Tao、SlimDX、SDL或GLFW等项目最为相似。
Unlike similar libraries, OpenTK attempts provide a consistent interface that utilizes the superior managed runtime. Instead of untyped pointers, OpenTK provides generics. Instead of plain constants, OpenTK uses strongly-typed enumerations. Instead of plain function lists, OpenTK separates functions per extension category. A common math library is integrated and directly usable by each API.
与类似的库不同,OpenTK尝试提供一个利用高级托管运行时的一致接口。OpenTK提供泛型,而不是非类型化指针。OpenTK使用强类型枚举代替普通常量。OpenTK不是简单的函数列表,而是按扩展类别分离函数。每个API都集成了一个通用的数学库并可直接使用。
The Open Toolkit is suitable for games, scientific visualizations and all kinds of software that requires advanced graphics, audio or compute capabilities. It's license makes it suitable for both free and commercial applications.
开放工具包(opentk)适用于游戏、科学可视化和需要高级图形、音频或计算能力的各种软件。它的许可证使它适用于免费和商业应用。
2.1 The DisplayDevice class
There are three main types of display devices: monitors, projectors and TV screens. OpenTK exposes all of them through the same interface: OpenTK.DisplayDevice.
显示设备有三种主要类型:监视器、投影仪和电视屏幕。OpenTK通过同一个接口(OpenTK.DisplayDevice)公开所有这些设备。
using OpenTK; foreach (DisplayDevice device in DisplayDevice.AvailableDisplays) { Console.WriteLine(device.IsPrimary); Console.WriteLine(device.Bounds); Console.WriteLine(device.RefreshRate); Console.WriteLine(device.BitsPerPixel); foreach(DisplayResolution res in device.AvailableResolutions) { Console.WriteLine(res); } }
using OpenTK; devices[0].ChangeResolution(800, 600, 32,60);
2.2 The GameWindow class
2.4 Building a Windows.Forms + GLControl based application
注1:本教程有些过时。例如,在VisualStudio的设计视图中不再看到“垃圾”。默认颜色是米色,而不是黑色。除了这些(次要)问题,本教程将帮助您开始使用OpenTK+Windows.Forms。
注2:如果您有一些空闲时间并希望为OpenTK项目做出贡献,请更新以下页面(登录时单击上面的“编辑”链接)以反映OpenTK的当前状态。
本教程假定您熟悉Windows。在Visual Studio 2005/C#中进行表单应用程序开发,至少具备OpenGL的基本知识。它还假定从上到下的通读;这是一个指南,而不是参考。
首先,在Windows中使用GLControl设计游戏/应用程序时,这是一种截然不同的方法。窗体与使用GameWindow相比。GLControl比GameWindow更低级,因此您必须自己控制例如时间测量。在GameWindow中,您可以免费获得更多!
就像在GameWindow中一样,GLControl使用系统的默认OpenGL驱动程序,因此安装了正确的驱动程序后,它将得到硬件加速。然而,对于大窗口,它将比相应的全屏GameWindow慢,因为底层窗口系统是如何工作的[有比我更详细的知识的人可能想详细说明这一点。]。
如果你来自一个“主循环背景”(C/SDL/Allegro等),那么在编码游戏时,你必须从根本上重新思考。你必须转变成一种心态,“我应该关注什么事件,我应该触发什么事件,什么时候?”
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
2021-11-10 利用 Heading、Pitch 、Roll 计算 Omega、Phi、Kappa
2020-11-10 MIKE 11 GIS是什么?
2019-11-10 Applied Spatiotemporal Data Mining应用时空数据挖掘
2015-11-10 AirplaceLogger源代码解析