开发者

On Windows, how does OpenGL differ from 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 ac开发者_运维技巧cess. 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.


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.


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.


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)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜