OpenGL & DirectX

Started by
12 comments, last by LilBudyWizer 18 years, 5 months ago
Hi. I know much of DirectX and when MS released DX9 I found very nice stuff in it. After googling the net I found almost none tutorial for DirectX for some advance programing, like shaders, HDR and stuff. Meanwhile I noticed that there are lot of examples for OpenGL but also I didn't found lot of shader examples. Few years ago almost every noticable FPS game was writen in OpenGL, and almost none in DirectX. And that games runned like hell on my Pentium II. Well I buyed new PC, and not so long ago a new graphic card (ATI9800Pro) and tried Half-Life2 (DX9), FarCry(DX9), and Doom3(OpenGL). Not to mention that DX games runned on max details with decent fps, and doom3 with medium details on 20fps (I was unable to set it in higher setting). My curiosity for OpenGL raised, I dl lot of examples for OpenGL and every example was detailed so people can learn from it much. And now I don't know what to do...I need BSP, octrees, lightmaps, and that stuff I can find for OpenGL and for DX nothing!!! I was thinking to port my whole engine into OpenGL, but then I didn't find lot of shader examples for OpenGL, nor HDR lighting... But on the other hand new engines runs poor on OpenGL, and fast on DirectX... I don't know what to do! I thought that two APIs are similar and that both are good. But what is the truth? Please someone give me a guideline. Thanks in advance
Advertisement
Quote:Original post by streamer
I thought that two APIs are similar and that both are good. But what is the truth?


If you are talking about Direct3D and OpenGL, then that is the truth (depending on what you mean by "similar").
See also the wikipedia article, directx vs. opengl.
Quote:Original post by Roboguy
Quote:Original post by streamer
I thought that two APIs are similar and that both are good. But what is the truth?


If you are talking about Direct3D and OpenGL, then that is the truth (depending on what you mean by "similar").


Yes I was thinking about Direct3D (DX9 droped support for DirectDraw), but if that is the truth why Doom3 is so "hardware eating engine". I don't think that Id software have some newbie programers in team, they proved a lot in past. But for example Half-life 2 looks beautifull! and two engines take best of hardaware they can.
For example I looked at code that MS use for skinning meshes. It was awfull!! I didn't understand a thing at first look. But f.e. when I looked at code for rendering md3 format for OpenGL everything looked understandable even if I don't know OpenGL!

And I don't want to start Directx vs OpenGL war.
Can you tell me what are the weak spots and what are advantages of OpenGL?
1)Both APIs are just as good and powerful. There are some issues with NVidia having better OpenGL support, and ATI better D3D, but IMO it's not a big deal. Doom3 runs slower because it uses a much more complex shading model(100% dynamic, while HL2 uses for the most part precalculated radiosity maps). If you're looking for a reason to choose between GL and D3D, you won't find it in performance. Make your pick based on your personal preferences and coding style.
That's why noone can tell you what are the "weak spots" of each one; it's up on you. For me, OpenGL being procedural is a pro, for others is a con.

2)BSPs,octrees,lightmaps are all techniques irrelevant of the API. If you know the API syntax well enough you can implement them easily.

3)There exist plenty Shader examples, but shaders(and especially HDR) are relatively new, so it's logical that they're fewer shader examples than those that use fixed-function pipeline. Again, for someone that knows the syntax, translating from D3D to OpenGL is trivial.

In sort, stop dwelling on this thought that one API is better than the other, and it's important that you find out which one is it, so it will magically make you a better programmer and your games run faster. Just pick one(or both) and learn. They're both deserve the time you'll spend on them.
Quote:Original post by mikeman
Make your pick based on your personal preferences and coding style.


Portability might be a factor in your choice also.
First of all, you really can't compare HL2 on D3D to Doom3 on OGL, and expect the comparison to mean anything about the performance. Both games look great, granted, but Doom3 does a LOT of pixel shading effects, where this is generally more limited in HL2.

Both APIs in their current version (and with appropriate extensions in GL's case) expose identical, or nearly identical features in the very least. The bottom Line is that an API is only that, choosing one or the other when they're so similar is not going to make any application better or worse, its about how you use it.

GL has some advantages, such as cross-platform compatibility, that DirectX doesn't even attempt to touch. Moving to the future, the PS3 used OpenGL|ES as its graphics API, and Nintendo reportedly uses a custom GL-like api, Macs and any non-Microsoft OS also use GL. Microsoft and its Xboxen are the only players promoting/using DX, so basically its MS and DirectX versus everyone else and OpenGL. Granted that due the massive windows user base, one could argue that the two are neck-and-neck, but GL has more supporters, especially in console games which are what really drive the industry.

Also, any GOOD engine should abstract the 3D API away from the game code, and developing an equivilant renderer for the other API is possible (and IMHO, should always be done.)


The bottom line though, is that you should use whatever one you are more comfortable with, and that is purely personal preference and up to you.

throw table_exception("(? ???)? ? ???");

I'll start with the easy ones.

HDR in OpenGL courtesy of humus.ca
Lots of shaders in Cg, GLSL, vp/fp, HLSL, etc

These people are right, the only reason that Doom3 runs slower then the other games is the full per-pixel realtime lighting. The performance difference between OpenGL and Direct3D is virtually zero.

I would argue, however, that OpenGL can be easier to learn for a beginner. It allows you to easily render geometry to at least get something up on the screen (I'm referring to glVertex3f and friends). Direct3D doesn't have support for so-called "immediate" mode rendering like this. While a production game or 3d application will probably never use immediate mode rendering because of the inherent slowness, it is helpful to get the concepts down.

Thanx guys [smile] you help a lot, but now I'm even more messed up.
I know D3D very well, and OpenGL not. I understand difference between engines (now). I have thoughts (for about week or two) that OpenGL is better in some way, and thats why I posted here. I have found articles on net of chaos in OpenGL extensions for newest stuff support. Is that true? Or things are better? And is there OpenGL 2.0?

This topic is closed to new replies.

Advertisement