在 Windows 上,OpenGL 与 DirectX 有何不同?

发布于 2024-12-03 22:21:02 字数 293 浏览 1 评论 0原文

我没有任何图形编程的实践经验。当我阅读有关图形编程的内容时,我产生了这个疑问。

据我了解,由于Windows不提供像DOS一样的直接硬件访问,因此创建了DirectX。这意味着 DirectX 是实现直接硬件访问的唯一可靠方法。我错了吗?

如果我没记错的话,那么 OpenGL 必须使用 DirectX 本身或在 DirectX 之上实现。

那么这是否意味着在 Windows 上 OpenGL 确实是 DirectX?

请注意,我的疑问仅限于标题所说的内容,确切地说,我不感兴趣为什么一个比另一个更好等等。

I don't have any hands on experience with graphics programming. I got this doubt when I was reading about graphics programming.

From what I understand, because Windows didn't offer DOS like direct hardware access, DirectX was created. That means DirectX is the only sure way to achieve direct(ish) hardware access. Am I wrong?

If I am not wrong, then OpenGL must be implemented either using DirectX itself or on top of DirectX.

So doesn't it mean that on Windows OpenGL is really DirectX?

Please note that my doubt is restricted to what the title says, exactly, and I am not interested why is one better than the other etc.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

上课铃就是安魂曲 2024-12-10 22:21:02

据我了解,由于 Windows 不提供像 DOS 这样的直接硬件访问,因此创建了 Direct X。

你说得对,Windows 没有提供像 DOS 这样的直接硬件访问。事实上,没有一个操作系统具有内存保护功能。

是的,DirectX 的创建是为了提供一个 API 以加速访问某些类型的硬件。 DirectX 是一种用于加速硬件访问的 API,而不是那个(唯一的)API。

这意味着 Direct X 是实现直接硬件访问的唯一可靠方法。我错了吗?

错了,因为没有任何东西或没有人阻止您实现另一条加速硬件访问的轨道。负责引导对硬件的访问的软件称为驱动程序。驱动程序在特权模式下运行,这意味着地址空间保护不适用于它们。也就是说,因为驱动程序必须能够与硬件通信。

驱动程序通过 API 与常规程序(即所谓的“用户空间”)进行通信。 API 可能是标准化的,然后可能是严格指定的,或者它们可能是完全专有的。

DirectX是一个指定的API,该规范是由微软编写的。

OpenGL 以类似的方式是一个 API,但它不是由单个实体指定,而是通过多个贡献者的协作以某种形式标准化。

专有 API 的一个例子是 3Dfx 的 Glide,它很大程度上受到 OpenGL 的启发。事实上,有一个名为“minigl”的兼容性包装器,它实现了 Half-Life 1 引擎在 3Dfx/Glide 系统上工作所需的 OpenGL 子集。

GPU 供应商的驱动程序开发人员遵循 API 规范,为 DirectX、OpenGL 或某些专有接口编写驱动程序。这些 API 中的每一个都可以访问驱动程序,从而访问硬件。并且单个资源可能有多个 API。驱动程序可以并行实现 DirectX 3D、OpenGL 和其他任何内容,并将它们全部提供给用户空间。

因此,如果附带 GPU 驱动程序,OpenGL 并不是构建在 DirectX 之上的。 Windows Vista 及更高版本附带构建于 DirectX 之上的 OpenGL-1.4 模拟,但不支持着色器、顶点缓冲区对象以及所有其他功能。一旦安装了支持 OpenGL 的 GPU 驱动程序,就会用实际的低级实现完全取代 OpenGL-1.4 模拟。

From what I understand, because Windows didn't offer DOS like direct hardware access, Direct X was created.

You're right that Windows didn't offer DOS like direct hardware access. In fact no operating system with memory protection does.

And yes, DirectX was created to offer a API for accelerated access to certain kinds of hardware. DirectX is a API for accelerated hardware access, not THE (one and only) one.

That means Direct X is the only sure way to achieve direct(ish) hardware access. Am I wrong?

You are wrong because nothing and nobody prevents you from implementing another track for accelerated hardware access. The pieces of software responsible for channeling access to hardware are called drivers. Drivers run in priviledged mode, which means, address space protection doesn't apply to them. That is, because drivers must be able to communicate with hardware.

Drivers communicate with regular programs, the so called User Space through APIs. APIs may be standardized, then may be tightly specified or they may be completely propritary.

DirectX is a specified API, the specification was written down by Microsoft.

OpenGL in a similar way is an API, but instead of having being specified by a single entity it's in some form standardized in collaboration of several contributors.

One example for a propriatary API was Glide by 3Dfx, which in large parts was inspired by OpenGL. In fact there is a compatibility wrapper called "minigl" implementing the subset of OpenGL required for the Half-Life 1 engine to work on 3Dfx/Glide systems.

The GPU vendors' driver developers follow the APIs' specifications, writing drivers for DirectX, OpenGL or some propriatary interface. Each of those APIs gives access to the driver and thus to the hardware. And there may be multiple APIs to a single resource. A driver may implement DirectX 3D, OpenGL and whatever else in parallel and provide them all to user space.

So no, OpenGL is not built on top of DirectX if shipping with a GPU driver. Windows Vista and above ship with a OpenGL-1.4 emulation built on top of DirectX, but that doesn't support shaders, vertex buffer objects and all the other whistles and bells. As soon as you install a GPU driver with OpenGL support, this completely replaces the OpenGL-1.4 emulation with an actual low-level implementation.

半衬遮猫 2024-12-10 22:21:02

DirectX是使用显卡硬件功能的一层。从Windows Vista开始,默认的OpenGL实现(微软提供的)使用DirectX,所以OpenGL非常慢。

然而,显卡厂商提供了带有OpenGL的驱动程序,直接使用显卡,无需经过DirectX;性能应该是一样的。如果您的集成显卡驱动程序较差,OpenGL 可能会使用 DirectX。

DirectX is a layer to use the graphic card hardware functions. Since Windows Vista, the default OpenGL implementation (the one provided from Microsoft) uses DirectX, so OpenGL is really slow.

However, graphic card manufacturers provides drivers with OpenGL that directly use the graphic card without passing through DirectX; the performance should be the same. If you have an integrated graphic card with a poor driver, OpenGL may use DirectX.

耳根太软 2024-12-10 22:21:02

不会,两种语言都通过显卡制造商编写的驱动程序直接与显卡硬件对话,因此两者都提供相同级别的硬件访问。

Windows 直接支持 DirectX,它是漂亮显示效果所需的操作系统的一部分 - 他们对 OpenGL 的支持相当有限,他们只支持 v1.1(我们现在是版本 4),所以要做任何有用的事情,你需要使用一些额外的东西库(例如glew)或显卡制造商的OpenGL SDK。

从能力上来说。 DirectX 由 MSFT 精心控制 - 因此所有 DirectX 系统都应该表现相同。 OpenGL 允许显卡制造商添加自己的扩展,因此他们可以通过向硬件添加特定功能来产生更高的性能(至少在理论上)。 OpenGL 也是跨平台的,因此您的 Windows OpenGL 代码可以在任何地方运行(理论上)

No, both languages talk directly to the graphics card hardware through a driver written by the card manufacturer so both offer the same level of hardware access.

Windows support DirectX directly, it's part of the OS needed for pretty display effects - their support of OpenGL is rather more limited, they only support v1.1 (we are now on version 4) so to do anything useful you need to use some extra library (such as glew) or the graphics card makers OpenGL SDK.

In terms of capabilities. DirectX is carefully controlled by MSFT - so all DirectX systems should behave identically. OpenGL allows graphics card makers to add their own extentions, so they can produce higher performance by adding specific features to the hardware (at least in theory). OpenGL is also cross platform, so your Windows OpenGL code will run anywhere (in theory)

地狱即天堂 2024-12-10 22:21:02

问题更多的是有直接的硬件访问并且没有方便的抽象层。软件供应商不想花费所有时间为每张新卡编写支持,因此他们敦促微软实现抽象。

选择是 OpenGL 或发明一个新层。多种原因导致了后者。

Vista+可以将OpenGL转换为DirectX,相反Wine可以将DirectX转换为OpenGL。

The problem is more that there was direct hardware access and no convenient abstract layer. Software vendors don't want to spend all their time writing support for each new card so they push Microsoft to implement the abstraction.

The choice was OpenGL or invent a new layer. Various reasons led to the latter.

Vista+ can convert OpenGL to DirectX, and conversely Wine can convert DirectX to OpenGL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文