• Advertisement
Sign in to follow this  

DirectX or OpenGL

This topic is 2352 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[font=arial, verdana, tahoma, sans-serif][size=2][font=arial, verdana, tahoma, sans-serif][size=2][color=#1C2837][size=2]DirectX or OpenGL does make a difference in good game programming??
Which one is good and needed and frequently used in game industry??
[color=#1C2837][size=2]-DirectX have is pure API for game programming[/font]
[color=#1C2837][size=2]-OpenGL does both jobs for graphics and game programming[/font]
[color=#1C2837][size=2]-DirectX interfaces good with hardware
[color=#1C2837][size=2]-DirectX updates according to that.
[color=#1C2837][size=2]-Does OpenGL do same??
[color=#1C2837][size=2]

Share this post


Link to post
Share on other sites
Advertisement
[font="arial, verdana, tahoma, sans-serif"][color="#1C2837"]-OpenGL does both jobs for graphics and game programming[/font]

OpenGL handles only graphics. I assume you meant DirectX here.


For any given platform, there is only one primary API.
Windows/Xbox 360: DirectX.
Macintosh/Linux/iOS: OpenGL or OpenGL ES.
Consoles: Console-specific API.


Pick from this list based on your target.
If your target is Windows then you must be wondering why you would use Direct3D instead of OpenGL.
Direct3D is nearly always faster on Windows due to poor vendor support for OpenGL.
OpenGL does not require vendors to pass certain certifications as DirectX does, so there are frequently bugs on a lot of cards. GeForce 8600 is not able to set boolean uniforms in shaders, for example.
DirectX has better documentation. Tutorials you find in OpenGL are likely to be out-of-date. There are many ways to do everything in OpenGL, especially thanks to extensions, but it is always a hassle trying to find which way is the best way, and you may unknowingly be using a tutorial that was deprecated thanks to newer features.


Ultimately you can overcome the hassles associated with OpenGL, but the same application will never be faster than DirectX on Windows, especially if it is DirectX 11.
I develop both the OpenGL and DirectX sides of my engine in parallel, and from the very start DirectX was a bit faster than OpenGL. But DirectX has more little tricks for optimization, such as padding vertex buffers to the nearest 32 bytes (which is actually harmful to OpenGL), and little-by-little the DirectX side has gained a huge lead over OpenGL (at least 1.34146 times as fast as OpenGL).


L. Spiro

Share this post


Link to post
Share on other sites
Either. Both. Whatever.
(edit: apologies if this sounds a bit flippant - OpenGL vs D3D is a well worn-out topic that has been going on for 15 years and has a high flame war risk)

Each has advantages and disadvantages compared to the other. Pick your preferred coding style, pick your target platform, decide if portability is going to be an objective, evaluate tools, support and documentation, and make a choice from there. Longer term try to learn and use both as you will broaden your knowledge and experience.

Share this post


Link to post
Share on other sites
In case anyone was misunderstanding, I have no biases. I like OpenGL just fine and DirectX has its problems.
OpenGL is especially useful for porting, so you would want to go that way if you do want to reach multiple platforms.

Honestly I think it is best to develop with both of them in tandem, as seeing how they both go about things different ways helps you understand what they are actually doing/how the graphics pipelines actually works.

I am sure I come off as a proponent of DirectX, but in actuality I feel equally happy as I code in both of them. When I add a feature to my engine, I look up either the OpenGL or the DirectX method, implement it, then look up how the other API does it and implement it. At no point do I feel icky about one or happier about the way one does something. I just move on to the next feature.


But I do encounter difficulties in both too. I am right to be disgusted when I find out a simple boolean flag cannot be set in a shader on several NVidia cards. But I am disgusted at NVidia, not OpenGL. DirectX is faster on Windows, but I don’t blame OpenGL. I blame vendors.
I do blame OpenGL for one thing though: No quality assurance guidelines to keep vendors in check.

In DirectX, using D3DXFilterTexture() on a D3DPOOL_DEFAULT texture will take you ages. Literally over 7 seconds for a texture that, in OpenGL, takes 0.03 seconds to mipmap. In this case I am disgusted at DirectX, but luckily I have to write my own set of resampling filters for mipmap generation anyway because I want the same mipmaps in both OpenGL and DirectX.


In the end, it is not the fault of OpenGL, but thanks to sloppy vendors, outdated tutorials, etc., you would be better off going DirectX when you can, at least until you are fairly skilled and patient (knowing how to and having the patience to implement fallbacks when you find a faulty NVidia driver, etc.)
But if someone wants to go OpenGL I would not stop him or her either.


L. Spiro

Share this post


Link to post
Share on other sites

I like DirectX because "D" comes before "O".

Fight the man. Reject the established order. Have a vowel movement.

Share this post


Link to post
Share on other sites
Fight the man. Reject the established order. Have a vowel movement.
Totally agreed. Consider U. So much awesomeness.

Share this post


Link to post
Share on other sites
All I can say is DOH! I started in Opengl and only ever used directsound to play sounds.


I was tempted to go opengl and openal but damn. If DirectX really is performing better I'll have to learn that system.

Correct me if I am recalling poorly. Doesn't Direct3D use a LHS while Opengl uses a RHS or vice versa.. the point being they use different orientations for x,y,z?

Share this post


Link to post
Share on other sites
Modern D3D (D3D10, D3D11) and GL (core GL3, core GL4) don't care about LHS and RHS. They leave that (matrix manipulations) to the user.

Share this post


Link to post
Share on other sites
Likewise D3D8 and 9; they both feature -LH and -RH versions of their matrix functions. In fact it's fair to say that neither OpenGL nor D3D enforce any matrix handedness - the OpenGL matrix stack functions might, but glLoadMatrix (and the modern GLSL equivalent) don't.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement