On Windows, How Does OpenGL Differ From DirectX - Stack Overflow
On Windows, How Does OpenGL Differ From DirectX - Stack Overflow
- Stack Overflow
I don't have any hands on experience with graphics programming. I got this doubt when I was reading
about graphics programming.
13
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.
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.
Share Improve this question Follow edited Sep 10, 2011 at 15:31 asked Sep 10, 2011 at 14:42
Christian Rau Ken
45.7k 11 110 188 133 1 4
From what I understand, because Windows didn't offer DOS like direct hardware access, Direct
X was created.
27
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.
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.
https://stackoverflow.com/questions/7372458/on-windows-how-does-opengl-differ-from-directx?rq=3 1/3
4/7/24, 4:12 PM On Windows, how does OpenGL differ from DirectX? - Stack Overflow
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.
Share Improve this answer Follow edited Sep 11, 2011 at 23:28 answered Sep 10, 2011 at 15:36
datenwolf
161k 13 188 303
+1 For providing an accurate answer in addition to the other not neccessarily incorrect but rather incomplete
answers. – Christian Rau Sep 11, 2011 at 0:21
@Goz: Actually HL1 uses a heavily modified version of the Quake-1 engine. Major changes included switch from
indexed color to RGB color mode to support dynamic illumination, support for multiple WAD texture containers with
differing palettes references by a single map, complete overhaul of the sound system, new AI system (which
integrates with the sound and illumination system – enter a dark room with cockroaches and turn on the lights,
cockroaches will hide in dark corners) and a keyframe interpolation character animation system, that can act on
individual body parts. – datenwolf Feb 20, 2014 at 19:25
Does this mean having installed DirectX driver I am able to call OpenGL functions without explicit GPU driver
supporting OpenGL? – Turkhan Badalov Feb 23, 2018 at 3:09
@TurkhanBadalov: No. It means that you can make DirectX calls. In order to support OpenGL a driver of course
must ship with a OpenGL implementation. However on the topic of APIs (i.e. DirectX, OpenGL, Vulkan, Metal, etc.)
it always comes down to software. The hardware itself is agnostic about the APIs. – datenwolf Feb 23, 2018 at
19:47
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.
5
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.
Share Improve this answer Follow edited Aug 8, 2021 at 8:15 answered Sep 10, 2011 at 14:49
apaderno neodelphi
29.1k 16 77 91 2,746 1 16 22
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.
2
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.
https://stackoverflow.com/questions/7372458/on-windows-how-does-opengl-differ-from-directx?rq=3 2/3
4/7/24, 4:12 PM On Windows, how does OpenGL differ from DirectX? - Stack Overflow
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)
Share Improve this answer Follow edited Aug 3, 2021 at 15:17 answered Sep 10, 2011 at 15:11
Helge Becker Martin Beckett
3,235 1 21 35 95.5k 28 192 266
"GLEW" is not an OpenGL extension. It's a library that makes it easier to use the OpenGL extensions provided by
the GPU manufacturer. The last paragraph is totally biased and also baloney. – Ben Voigt Sep 11, 2011 at 23:44
GLEW is not an openGL ARB_EXT extention but it is an extention to the capabilities of openGL on windows. ps
Just try and run an OpenGL program of any complexity on an Intel embedded graphics chipset – Martin Beckett
Sep 12, 2011 at 3:12
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
2 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.
Share Improve this answer Follow edited Aug 8, 2021 at 8:11 answered Sep 10, 2011 at 14:55
apaderno Steve-o
29.1k 16 77 91 12.8k 2 42 60
I don't understand the first sentence. How was the access possible, through 16 bit emulation mode? – Ken Sep
10, 2011 at 16:32
@Ken DirectX appeared with Windows 95, i.e. when there was limited memory protection. You often have mini-
drivers such as MiniGLX. – Steve-o Sep 10, 2011 at 17:04
https://stackoverflow.com/questions/7372458/on-windows-how-does-opengl-differ-from-directx?rq=3 3/3