On Windows, how does OpenGL differ from DirectX?

前端 未结 4 889
粉色の甜心
粉色の甜心 2020-12-28 09:16

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 Wind

相关标签:
4条回答
  • 2020-12-28 09:31

    DirectX is a layer to use the hardware functions of the graphic card. Since Windows Vista, default OpenGL implementation (the one provided from Microsoft) uses DirectX, so OpenGL is really slow. However, graphic card manufacturers provides drivers with OpenGL using directly using the graphic card and not passing through directX, so performances should be the same. If you have an integrated graphic card with poor driver, OpenGL may uses DirectX.

    0 讨论(0)
  • 2020-12-28 09:32

    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 讨论(0)
  • 2020-12-28 09:33

    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 extentions (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)

    In practice the only OpenGL drivers on Windows that aren't completely useless are NVidia - so high performance OpenGl apps on windows pretty much require an NVidia card. This means that it's easy to program OpenGL on Windows - you just stick to NVidias docs.

    0 讨论(0)
  • 2020-12-28 09:39

    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.

    0 讨论(0)
提交回复
热议问题