Archived

This topic is now archived and is closed to further replies.

IndirectX

Not exactly D3D vs OGL, but...

Recommended Posts

I am relatively new to 3D programming. It happened so that I learned Direct3D instead of OpenGL (I didn''t know about NeHe when I started, and DXSDK''s tutorials were the best source I had). Now as I read D3D vs OGL forums, I get the feeling that I should at least try doing GL instead of D3D. But: If OpenGL is so much better, as people say, why are (many?) games built using Direct3D? Why do many commercial graphics software (games and not games) use Direct3D? Also, as I was running a demo from this forum with debug Direct3D runtime on my WinXP, the debug spew was labeled ''Direct3D8''. The program never loaded d3d.dll or d3d8.dll, but it did load ddraw.dll and (as debug output suggests) created DirectDraw surface, etc. So is OpenGL implemented using DirectDraw on Windows? If so, is it (theoretically) slower than Direct3D which does (I think) not rely on DirectDraw? Thank you for your insights into this.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Aaaahhh !! Dave, HEEELP !! Where is that FAQ !?

Share this post


Link to post
Share on other sites
bah......................................................

OK... Lemme see... OpenGL isn''t necessarily better than D3D. They are somewhat different. OpenGL would be better IF Microsoft wasn''t such a beast. But the way things are, new graphics card features work their way into D3D sooner than OpenGL, so that''s a plus.

OpenGL was always much simpler to use than Direct3D, but with D3D8 the difference is more or less negligible.

More graphics cards supposed D3D, but ALL high-end cards, and most slower cards, support both.

BUT... Direct3D is for Windoze only. So, if you wanna programme for multiple OS''s, you need OpenGL.

I''m writing my 3D engine to support both, so that windows users can use Direct3D if they so desire.

I hope this answered some of your questions.

Share this post


Link to post
Share on other sites
quote:
Original post by dusik
But the way things are, new graphics card features work their way into D3D sooner than OpenGL, so that''s a plus.



That is incorrect. In D3D you need to wait for a new version to get the newer features that graphics cards are supporting. With OpenGL, they are almost immediately available through extensions.

As is said on every single of these threads, try it out, and see if you like it not. If you like it, use it, if you don''t, don''t use it. Period ''.''

Share this post


Link to post
Share on other sites
The only OS I''ve ever programmed for is Windows, so cross-platform compatibility does not matter to me, at least not in foreseeable future.

I''ve just finished wrapping a few D3D8 interfaces to throw exceptions instead of returning HRESULTs, so I''d hate to do this for GL if I didn''t like it.

Since I already spent quite some time learning D3D, I think learning GL will not be a problem.

As for extensions, I''m just trying to put some triangles on the screen. I guess I have to wait a while before I''m ready to use one of those.

That said, my question still stands: if so many people say D3D is inferior, why do many games and other software (ie, benchmarks) still use it?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by python_regious
[quote]Original post by dusik
But the way things are, new graphics card features work their way into D3D sooner than OpenGL, so that''s a plus.



That is incorrect. In D3D you need to wait for a new version to get the newer features that graphics cards are supporting. With OpenGL, they are almost immediately available through extensions.



Except that OpenGL requires you to own that peice of hardware to expirement with the feature, and the extensions are different on every card. Many GL extensions are quite difficult to use. When you start seeing register diagrams of the internal hardware and commands look suspicously like things which send keywords to certain ports on the card, the argument that this is the nice pretty OpenGL api we love is hard to make.

D3D does not trail hardware features, it moves in tandem with them. It is more likely that D3D supports a feature before the hardware is out, then vice versa. Take matrix palette skinning for example, D3D supported this more then a year before hardware came out that did. (actually, I beleive that the GF4 still doesn''t techinically support it. They expect that you would do this in the vertex shader).

Vertex shaders were an even more pronounced example of this. Developers could proto-type shaders before hardware was available, and could write them for hardware that didn''t even support them.


Share this post


Link to post
Share on other sites
>>If OpenGL is so much better, as people say, why are (many?) games built using Direct3D? Why do many commercial graphics software (games and not games) use Direct3D? <<

according to this weeks top10 in the usa NPD the number of games that use d3d exclusively are 0. opengl has one exclusive game (at number 1 no less)

>>Also, as I was running a demo from this forum with debug Direct3D runtime on my WinXP, the debug spew was labeled ''Direct3D8''. The program never loaded d3d.dll or d3d8.dll, but it did load ddraw.dll and (as debug output suggests) created DirectDraw surface, etc. So is OpenGL implemented using DirectDraw on Windows? If so, is it (theoretically) slower than Direct3D which does (I think) not rely on DirectDraw?<<

directdraw is used to do the actual drawing this occurs no speed lose. ie the d3d or opengl drivers both do this.
FWIW doing the same stuff.
opengl is usually faster than d3d on nvidia cards
d3d is usually faster than opengl on ati cards.
technically opengl should be slightly faster on all cards but driver writers are sloppy + this is not the case

http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites
> d3d is usually faster than opengl on ati cards.
technically opengl should be slightly faster on all cards but driver > writers are sloppy + this is not the case

Though ATi is getting better. Just look at the number of extensions they brought out the last 4 months, compared on what they did the years before. But no one is going to beat nVidia (yet), when it comes to the quality and speed of OpenGL drivers.

Share this post


Link to post
Share on other sites
One plus for Direct3D is it is completey object Oriented. OpenGL however isn''t and you usually end up doing your own classes.. eg CTexture ... not that is a bad thing or not...

Oh yeah.. and Quake 2/3 are OpenGl so that''s cool too... :D

Share this post


Link to post
Share on other sites
***Article coming out in a few days which discusses all of this***

Anyway, I personally think it''s a bad idea to write for any API exclusively. Most commercial games now have D3D, OGL, and a software renderer, often one of the QuakeGL engines. Carmack''s been really stubborn about writing D3D, ie he wont do it. However, he does use DirectSound, DirectInput, because those APIs are the best in the industry.

Most 3D graphics editing software is written natively in OpenGL and then D3D support is added, which is usually pretty shoddy anyway.

All in all, it comes down to personal preference. I''m learning both at the same time, and I have no problems. I have no preference either...

Share this post


Link to post
Share on other sites
The majority of us programmers ( I think ) use OGL for the graphics, DSound for the sound, and DInput (sometimes) for input. Last poster was right, they are just the best in the industry so far.


Complete amatures whose only relevant skill is programming undertake to design games with no further preparation than their own experience as game players. Those who overrate their own understanding undercut their own potential for learning.

Share this post


Link to post
Share on other sites
There is not a lot of functional difference between OpenGL and Direct3D. There is definately a trade off and difference in the ease of use.

Direct3D, for instance, has many helpful functions such as SIMD accelerated vector and matrix classes, functions to load and save all kinds of texture images, and functions to load, save, optimize, and render meshes. For OpenGL you either have to write it yourself or use a 3rd party library. DirectX is also has sound, multiplayer, and input support. Again this is all third party or do it yourself in OpenGL.

That said, many people find OpenGL to be conceptually easier to program. You don''t have to worry about losing your surfaces and dealing with COM interfaces or arcane HRESULTS. If you use GLUT, you can even completely insulate yourself from the joys of having to deal with Win32 API programming. Plus OpenGL is cross platform (or more cross platform, since DirectX kind of (subset) runs on Xbox).

Which API you pick to start with at the beginning doesn''t matter all that much. (Its easier to get a triangle on the screen in OpenGL, but then its easier to get a textured mesh up on direct3D, so I''m not sure who wins here.) Really its not that difficult to convert between the two.

I think most CAD/Modeling/Scientific/Acedemic apps use openGL because it runs on Unix, has a richer feature set (quadrics, evaluators, picking etc.)for supporting these kinds of applications, and for historical reasons (thats really what OpenGL was originally intended for before consumer 3D was practicle). Games seem to be using Direct3D more and more ( http://www.ati.com/na/pages/gamesupport/ ). The last 3 I played are all Direct3d (empire earth, aliens vs predator, and Warcraft 3 beta). Part of this is probably because if you program on windows you are going to end up using Direct Sound and Direct Input anyways (which means dealing with com and HRESULTS and the win32 API) and its less effort just to stick to one style and API than mix in OpenGL. Plus I think that many companies probably tend to trust using microsoft functions for SIMD math etc. instead of relying on 3 party programming or doing it themselves.

Share this post


Link to post
Share on other sites
Good question, I''ve been wondering the same thing myself, and am in much the same situation. Why does everyone glorify opengl then turn around and use D3D of games. Very odd indeed. Hope you get an answer because I want to know too.

Share this post


Link to post
Share on other sites
quote:
Original post by invective
Direct3D, for instance, has many helpful functions such as SIMD accelerated vector and matrix classes...

That''s somewhat misleading. OpenGL is meant to handle that for you. If the video card supports it in hardware, then the hardware does it for you. If it doesn''t, then the drivers are meant to use the SIMD accelerated versions for you.
quote:
Original post by invective
Part of this is probably because if you program on windows you are going to end up using Direct Sound and Direct Input anyways...

quote:
Original post by raklar
Good question, I''ve been wondering the same thing myself, and am in much the same situation. Why does everyone glorify opengl then turn around and use D3D of games.

You can completely avoid DirectSound and DirectInput if you''d like. I''m doing just that fairly easily through OpenAL and SDL. It''s nice not having to maintain two codebases just to write a portable engine.

Share this post


Link to post
Share on other sites
quote:

That''s somewhat misleading. OpenGL is meant to handle that for you.


OpenGL hadles projection, view, and world transforms. Most people still need vectors and matrices for things like spatial partitioning, physics, collision detection and AI. Its nice to have these functions SIMD accelerated. You can actually link in the DirectX Math library on your windows OpenGL projects (I always do, and I wrote a similar unaccelerated math library that drop in under linux).

quote:

You can completely avoid DirectSound and DirectInput if you''d like. I''m doing just that fairly easily through OpenAL and SDL.

True, if SDL functionality is sufficient for your application (haven''t tried openAL). OpenGL and Direct3D have roughly equivalent functionality. SDL and Direct X Audio / Input are not even in the same catagory.

Share this post


Link to post
Share on other sites
What''s better ... apples or oranges?

Does that seem like a dumb question? I hope so. So does the ''what''s better'' OpenGL or Direct3D question? Basically use whatever is more appropriate for you.

As to the argument that D3D uses the SIMD instruction set - I think you''ll find that better games use their own functions (in assembly) anyway. Never assume that a library that ships with any API is fully optomised. If you wanna avoid writing code, then use GLUT. If you wanna have a good 3D app (incl. games) then be prepared to do the hardwork yourself. Lets face it, most people would say that VB is ineffectual for most games - why? Because these people want to have better control as to the way the software works. A natural progression is to do all the time consuming functions yourself in assembly. Look on a recent thread on one of the other gamedev forums about fast trig functions. Don''t assume because someone else wrote some software it''s better than what you can do. It''s a matter of learning about optomisations etc.

Anyway - I''m waffling. At the end of the day D3D and OpenGL are directly comparible. Any differences are minor. If you want more speed - do it yourself!

Share this post


Link to post
Share on other sites
quote:
Original post by invective
OpenGL hadles projection, view, and world transforms. Most people still need vectors and matrices for things like spatial partitioning, physics, collision detection and AI.

That''s why I said somewhat.

Share this post


Link to post
Share on other sites
quote:
Original post by invective
Direct3D has many helpful functions such as SIMD accelerated vector and matrix classes, functions to load and save all kinds of texture images, and functions to load, save, optimize, and render meshes.


I''d hate to do all of this myself.
quote:

That said, many people find OpenGL to be conceptually easier to program.


I tried writing a Windows Shell Namespace Extension to allow something like network neighborhood over Internet. After that, D3D does not frighten me
quote:

You don''t have to worry about losing your surfaces and dealing with COM interfaces or arcane HRESULTS.


I write my wrappers that convert HRESULTs to exceptions and have nice macros that give me error string when something fails. That''s a bit of work (I wrap every method), but after that it''s like c run-time code. And I can restore surfaces just like I reacquire devices in DInput.
quote:

If you use GLUT, you can even completely insulate yourself from the joys of having to deal with Win32 API programming.


As a matter of fact, I like programming Win32.
quote:

Plus OpenGL is cross platform


Since I''m using MFC for my UI, this is not really an issue.
quote:

Really its not that difficult to convert between the two.


But writing code twice is not the same as writing it once.

BTW: Is GetProcAddress() the only way to get GL extension entry points? MSVC 6 has this great feature called dll delay-loading, and it would really be very applicable here. Is there a header to include that gives you all known extensions?

I guess I''ll stick with D3D for now. There''s something appealing in vertex buffers as opposed to glBegin to me...

Share this post


Link to post
Share on other sites
Well It's your choice but if I were you I'd run through about the first 15 of Nehe's tutorials before you decide. You might change you're mind

quote:

There's something appealing in vertex buffers as opposed to glBegin to me...



I thought vertex arrays and vertex buffers were very similar anyway.

IMO it's always better to learn as many different ways fo doing things as possible so YOU can compare them yourself. Then choose.

Lukerd



"To err is human, to really mess up requires a computer"

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. "
- Albert Einstein


Edited by - Lukerd on February 19, 2002 5:23:19 AM

Share this post


Link to post
Share on other sites
> vertex buffers as opposed to glBegin

Vertex arrays, perhaps ?

And there is something very appealing in VAR as opposed to vertex buffers...

Share this post


Link to post
Share on other sites
Invective

Compliment ... this is the correct answer , in my opinion ,to the endless flame war ,opengl vs direct x.

the only point I do not agree with you is about the best choice for beginners and\or amateurs .
Personally I would suggest opengl , unless he\she is a beginner as graphic programmer but a windows \ c++ guru.

Share this post


Link to post
Share on other sites