• OpenTK第二章: Introduction to OpenTK(简介)


    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都集成了一个通用的数学库并可直接使用。

    Features:特点:
     Written in cross-platform C# and usable by all managed languages (F#, Boo,VB.Net, C++/CLI)。
        用跨平台C#编写,可用于所有托管语言(F#、Boo、VB.Net、C++/CLI)。
     Consistent, strongly-typed bindings, suitable for RAD development。
        一致的强类型绑定,适用于RAD开发。
     Usable stand-alone or integrated with Windows.Forms, GTK#WPF。
        可独立使用或与Windows集成。表格,GTK#,WPF。
     Cross-platform binaries that are portable on .Net and Mono without recompilation。
        跨平台二进制文件,可在.Net和Mono上移植,无需重新编译。
     Wide platform support: Windows, Linux, Mac OS X, with iPhone port in progress。
        广泛的平台支持:Windows、Linux、Mac OS X,iPhone端口正在进行中。

    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)公开所有这些设备。

    You can use OpenTK.DisplayDevice to query available display devices, discover and modify their properties.
    您可以使用OpenTK.DisplayDevice查询可用的显示设备,发现并修改其属性。
    Example 1: discover available devices
    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);
     }
    }
    Example 2: set the resolution of the first device to 800x600x32@60Hz:
    using OpenTK;
    devices[0].ChangeResolution(800, 600, 32,60);

    2.2  The GameWindow class

    2.3 The NativeWindow 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等),那么在编码游戏时,你必须从根本上重新思考。你必须转变成一种心态,“我应该关注什么事件,我应该触发什么事件,什么时候?”

    Why use Windows.Forms+GLControl instead of GameWindow?
    你首先要决定的是:
    “与窗口化的GameWindow相比,我真的需要增加Windows.Forms+嵌入式GLControl的复杂性吗?”
    以下是您希望增加复杂性的一些原因:
    1.您希望使用Windows构建一个GUI丰富/RAD类型的应用程序。窗体控件。例如,级别编辑器或模型查看器/编辑器可能属于这一类,而窗口游戏更倾向于GameWindow类应用程序。
    2.您希望在现有的Windows窗口应用程序中嵌入OpenGL渲染面板。
    3. 您希望能够拖放到渲染面板中,例如将模型文件拖放到模型查看器中。
    假设你至少有一个构建Windows的原因。基于Forms+GLControl的应用程序,以下是步骤、问题和原因。

    参考:\OpenTK.1.0\Documentation\Manual.pdf

  • 相关阅读:
    u-boot器件驱动模型(Device&Drivers)之uclass (转)
    u-boot下的DM驱动模型 阶梯状 (转)
    u-boot-2018.09 DTS上 I2C节点的解析 (转)
    [uboot] (番外篇)uboot串口&console&stdio设备工作流程 (转)
    [uboot] (番外篇)uboot 驱动模型(转)重要
    u-boot DM初始化流程
    【u-boot】u-boot中initf_dm()函数执行流程(转)
    【u-boot】u-boot对设备树的节点解析(转)
    BeanPostProcessor
    一些压力测试结果(Mysql,Zookeeper,Redis,Mongodb)
  • 原文地址:https://www.cnblogs.com/2008nmj/p/16877192.html
Copyright © 2020-2023  润新知