Sign in to follow this  
CodeMachine

OpenGL or DirectX?

Recommended Posts

Hello mates If I want to start programming 3D-games, which enging is to prefer then? OpenGL or DirectX? And maybe anyone can recommend one or several GOOD books? Thanks

Share this post


Link to post
Share on other sites
I'm pretty sure an FAQ around here answers this question in detail. It might be the For Beginner's one. Anyhow, the answer is that it doesn't really matter unless you plan on programming for Linux or Mac, in which case use OpenGL. otherwise, it's pretty arbitrary. OpenGL is generally considered a tad easier to learn, but overall they're going to be roughly the same amount of work for the same amount of results. And they both have plenty of good information regarding them, so that's pretty fair too. It comes down to choice or platforms.

Oh, and about the books. Beginning OpenGL Game Programming is excellent. This is assuming that you already have a firm grip on C++. If not, work on that first (or work on the language of your choice, all major languages have OpenGL bindings).

Share this post


Link to post
Share on other sites
I would recommend OpenGL, if only because of it's universality (compared to DirectX) and it's open-source nature. I am personally a big fan of open-source programs and APIs, and I love OpenGL.

And if you're looking for OpenGL help, try the Redbook. It's available at http://www.glprogramming.com/red/ .

Share this post


Link to post
Share on other sites
Quote:

I would recommend OpenGL, if only because of ... it's open-source nature.

OpenGL is not open source. It's a standard, which is freely available, however to claim that OpenGL is open source implies that the source code to the implementation must be available. It's not.

That said, to the OP: Look at them both, pick the one you like best. They both do the same thing, in the end, there is really little difference that you need to be worried about at this point in your career.

Quote:

And maybe anyone can recommend one or several GOOD books?

Avoid books that cater to specific APIs (unless they're free, like the OpenGL Red Book) as they become outdated quickly and aren't worth the money. Avoid books that claim to teach you "beginning game programming" in a specific API.

I generally recommend people acquire "Fundamentals of Computer Graphics, 2nd Ed." and possibly also "The Geometry Toolbox" (understanding the math is critical to writing nontrivial 3D applications) to get a solid understand of the API-agnostic theory. That theory can be supplemented with the excellent online documentation available for either OpenGL or D3D.

Share this post


Link to post
Share on other sites
In my opinion I think DirectX is more complex than OpenGL. DirectX have many different versions(I mean that there is 7.x, 8.x or 9.x, etc...) and it's built upon you have to create object devices (tag struct's). But in OpenGL there's just one main version of it, it's basically just global function calls except for some objects.

Share this post


Link to post
Share on other sites
Quote:
Original post by CodeMachine
Hello mates

If I want to start programming 3D-games, which enging
is to prefer then? OpenGL or DirectX?

And maybe anyone can recommend one or several GOOD books?

Thanks


I might add that it's not entirely necessary to even make this decision, if you go with the option of using an already-heavily-developed graphics library like CrystalSpace, Irrlicht, or my own personal favorite, Ogre3D, you can bypass much of the 'graphics engine' development part of your game's progress (as well as some other components which those libraries offer you), in the name of focusing on game elements instead.

Best of luck,




Share this post


Link to post
Share on other sites
Quote:
Original post by jpetrie
Quote:

I would recommend OpenGL, if only because of ... it's open-source nature.

OpenGL is not open source. It's a standard, which is freely available, however to claim that OpenGL is open source implies that the source code to the implementation must be available. It's not.


Let me correct you:

- Mesa 3d - linux opengl implementation of opengl is opensource..
- SGI offers a opengl reference software implementation under opensource license as well.

Share this post


Link to post
Share on other sites
Quote:

Let me correct you:

- Mesa 3d - linux opengl implementation of opengl is opensource..
- SGI offers a opengl reference software implementation under opensource license as well.


That's worth mentioning, of course, but that isn't a "correction" to what I said. Those are implementations of OpenGL. Not OpenGL itself. I can write an implementation that conforms to the Direct3D interface and make that open source, but that does not make Direct3D itself open source.

OpenGL is a standard, and that standard does not stipulate that an OpenGL implementation must be open source. Consequently, OpenGL is not open source. You won't find the source to Microsoft's implementation, for example. When people talk about OpenGL, they usually mean any or all implementations of the OpenGL standard (it's kind of nonsensical to call a standard "open source," after all). But there is no stipulation that all implementations must be open source (many are not) and it is therefore inaccurate to claim that OpenGL is open source. I never said anything about particular implementations, after all (although the implementations that will be used by the majority of the game-playing market will be closed source).

Share this post


Link to post
Share on other sites
"I want to start programming 3D-games"

Well up to a certain extent it doesn't matter if you get started from opengl or direct x for the simple reason that you will never program a game this way :)

Use a game engine, beleive me
The question is : An opengl or a direct.x based engine ?

Although opengl is multiplatform I would suggest a direct x engine
Graphic cards manufactures suppport more direct x than opengl, right or wrong it is a matter of fact

If you want to make graphic programming ( dont confuse game and graphic programming ) than I would prefer opengl , its architecture being more intuitive

Share this post


Link to post
Share on other sites
I wont tell you if one's better than the other, but I learned OpenGL in 6 months, and DirectX was a bit harder to learn. However, I have been told that in the games industry DirectX is more widely used, and considered to be more powerful.

The PS3 uses OpenGL-ES, (ES is for Embedded Systems) whereas the XBox 360 uses (no surprises here) DirectX 10.

The truth of the matter is that niether is better, they're just different.

I was also told that OpenGL is on the up, and that more games companies are using it as time goes by, but I'm not so sure...

Good luck dude, and if you pick OGL, have a look at the NeHe tutorials on [url]NeHe.Gamedev.net[/url] -they rock!

Share this post


Link to post
Share on other sites
Quote:
Original post by Delfi
Quote:
Original post by jpetrie
Quote:

I would recommend OpenGL, if only because of ... it's open-source nature.

OpenGL is not open source. It's a standard, which is freely available, however to claim that OpenGL is open source implies that the source code to the implementation must be available. It's not.


Let me correct you:

- Mesa 3d - linux opengl implementation of opengl is opensource..
- SGI offers a opengl reference software implementation under opensource license as well.


By that logic, DirectX is also open source, thanks to the efforts of the Wine project. Only I think their implementation can actually use hardware some.

Share this post


Link to post
Share on other sites
I have not read any of the responses yet, but going off of statistics and the fact that I'm an opengl user, I suggest Opengl.

Statistics:
Opengl: 134,766
Directx: 253,504

# of topics on gamedev.net forums. Obviously directx is less intuitive. (or maybe it's more popular, intriguing? who knows)

Share this post


Link to post
Share on other sites
Yeah, a sticky would be good, but only with comparisons, arguments about open source (although valid) ahouldn't be included in a sticky.

And to that particular argument, i'd like to add that OpenGL, although not open source, has been embraced by the open source community to a further extent (i.e. there's more open source programs in OpenGL than DirectX)

I digress, however. Sticky it, but with more emphasis on the comparison and technical comparison :)

Share this post


Link to post
Share on other sites
Quote:
Original post by TheUmpteenth
I wont tell you if one's better than the other, but I learned OpenGL in 6 months, and DirectX was a bit harder to learn. However, I have been told that in the games industry DirectX is more widely used, and considered to be more powerful.

The PS3 uses OpenGL-ES, (ES is for Embedded Systems) whereas the XBox 360 uses (no surprises here) DirectX 10.

The truth of the matter is that niether is better, they're just different.

I was also told that OpenGL is on the up, and that more games companies are using it as time goes by, but I'm not so sure...

Good luck dude, and if you pick OGL, have a look at the NeHe tutorials on [url]NeHe.Gamedev.net[/url] -they rock!


I believe the 360 uses a derivative/variation of D3D9. No D3D10 or DX10 for that matter.

Share this post


Link to post
Share on other sites
I use OpenGL because:

1. It's portable: it works on Windows, Linux, Mac OS and Playstation, amongst many others.

2. It's forwards compatible: each version of DirectX introduced slight changes to the existing API: to use new features of the current version you have to fix your program so it works with the new one. OpenGL is designed so that even decades old OpenGL programs have the same behaviour on the latest hardware.

This doesn't just mean that you can upgrade your graphics without having to port the entire thing to a new version: if your game allows mods to access OpenGL extensions, then mods can use OpenGL features which didn't exist when you wrote the game.

3. I find its design aesthetically pleasing.

I think (1) and (2) are genuine advantages. Of course, (1) only applies if you care about writing portable code, and (2) only applies if you care about making your game moddable.

Share this post


Link to post
Share on other sites
Hiya, just wanted to clarify something, and then suggest a book!

First, the OpenGL-ES that PS3 uses...erm, it's more like 'SonyGL', given that they had to hack it up so they could have a nice programmable pipeline. This will probably mean nothing to OP, but is a useful distinction I think -- but has similarities in many respects to vanilla OGL.

Meanwhile, before tackling choice of which API is pre-eminent (neither, both have uses/platforms they work on better), might want to think about pre-requisites. That is, do you know the stuff that most graphics texts expect you to know before you start? First is math, Linear Algebra, maybe some differential equation stuff. I found:

3D Math Primer for graphics and game development, by Dunn & Parberry to be an excellent resource. I already -knew- the math, but this book is a great 'ready reference', in case you forget just exactly how to do something -- plus also great for people who know -no- math...takes easy steps :)

The other thing is a programming language. C++ is pretty darn common around here, though you can use others. I'm not going to recommend one over another, but bear in mind that if you wanted a job doing this later, C++ is industry standard right now (this could change!).

Anyway, food for thought.

~Shiny

Share this post


Link to post
Share on other sites
Quote:
Original post by programering
In my opinion I think DirectX is more complex than OpenGL. DirectX have many different versions(I mean that there is 7.x, 8.x or 9.x, etc...) and it's built upon you have to create object devices (tag struct's). But in OpenGL there's just one main version of it, it's basically just global function calls except for some objects.


One could probably argue that Direct3D is more complex than OpenGL, but not for reason of versioning. While it's true that there are several versions of Direct3D, the same is also true of OpenGL, which has gone through versions 1.0, 1.1, 1.2, 1.3, 1.4, 1.5 and 2.0 with 2.1 and 3.0 on the way before the end of the year. Its generally true that point revisions are backwards compatible, and that GL point revisions are more frequent and perhaps more drastic than Direct3D point revisions. One could argue that OpenGL, with its extension mechanism, is actually more complex to deal with than Direct3D's versions, though they're probably equal with the realities of the Cap Bits mechanism up through D3D 9. Direct3D has gone through 7 major revisions (Direct3D 3, 5, 6, 7, 8, 9 & now 10) compared to OpenGL's current 2 (though you could argue that the addition of shaders was a big enough addition to consider it a new (but backwards compatible) version).


Quote:
Original post by programering
Check this out: http://www.xmission.com/~legalize/d3d-vs-opengl.html


A comparison of OpenGL 1.2 to Direct3D 7 and 8 (The former of which sucked, and the later of which sucked less) is hardly relevant any more.

Quote:
Original post by TheUmpteenth
The PS3 uses OpenGL-ES, (ES is for Embedded Systems) whereas the XBox 360 uses (no surprises here) DirectX 10.


Niether point is quite on-target.

The PS3 supports 2 low-level 3D APIs, Most AAA games now are using the lowest-level API called CTM (Close To the Metal) which is basically a software API which accesses the nVidia Graphics hardware with very minimal abstraction, the second API is called PSGL, which is based on, but is clearly not, OpenGL|ES. The reason PSGL differs from OpenGL|ES is that OpenGL|ES (in version 1.x at the time) did not yet have provisions for vertex or pixel shaders, which the PS3 supports, and there's little use for the fixed-point functions on such powerful hardware, which AFAIK were removed. Sony used ES as a base, but signifigantly tweaked it for their needs. Its probably just as accurate to call PSGL a stripped-down OpenGL than it is to call it an expanded OpenGL|ES. OpenGL|ES 2.0 now exists and includes shader support using GLSL (as opposed to Cg in PSGL), Sony has said that they would create a PSGL 2.0, based on OpenGL|ES 2.0 and GLSL, if enough developer interest was shown.

The 360, on the other hand, does not use Direct3D10 as its base API either. I'll refer to it as X3D for lack of a better name. Its very much an analogue to PSGL in many respects: PSGL is to OpenGL|ES as X3D is to Direct3D 9. They took Direct3D 9 and tailored it to their hardware by cutting out what they don't need and adding what they did. Feature-wise, it sits somewhere between Direct3D 9 and Direct3D 10, its shader support goes beyond 3.0, but does not meet 4.0 in all areas; there are no geometry shaders, for instance. Both X3D and PSGL are console-tuned versions of their parent APIs; the love-child of each console and their respective API legacies.


Anyhow... Back to the original question. Which is better? The answer is impossible to provide. While they accomplish the same task, the syntax is quite different and the APIs are running neck-and-neck in terms of features, as they have for some time and will likely continue to do. Frankly, the best idea is to try both out and see which one jives with your personal preferences. Most newbies are more comfortable with OpenGL's C-based API, since its not hidden away behind layers of C++ classes and interfaces like Direct3D is. Once you get over that hurdle, you might actually like the way D3D is arranged. Try them both, and as other's have said, learn the fundamentals. The future may hold something entirely different, Real-time ray-tracing for instance, and a whole new API to go with it. APIs come and go, but fundamentals are forever.

Share this post


Link to post
Share on other sites
I like OpenGL myself because it's so easy to use straight out of the box. You can build a quick application easily within an hour.

I also like their matrix stack implementation, and other 'utilities' (glu). But many things aren't supported natively with openGL. DirectX has extensions to support basic quaternions, vectors and matrices for example. Also, DirectX caters for audio, music, inputs (steering wheels, joypads...). There are many 3rd party libraries you can use to work with openGL and provide all that functionality, or you can even use DirectInput or audio directly with it as well.

All in all, I don't think it matters. It depends on the books, platform, development environment, language, ect... Will you be working with XNA? C++? C#?...

Share this post


Link to post
Share on other sites
I am pretty sure the FAQs directly forbid this type of post, but since it is all nice and polite I guess it doesn't matter...

Really, it is comes down to one pragmatic reality: OpenGL runs pretty much everywhere except the XBox, and Directx is only available on Windows and XBox. If you can live with only Windows, then it is purely a matter of personal choice, give them both a spin, check out sample programs for each, and go with whichever you like better.

It is also worth mentioning that DirectX compromises a lot more than OpenGL (which is functionally equivalent to only Direct3D), so with OpenGl you will need to learn a few other APIs in addition.

And DarkHorizon is right, unless you feel a burning need to learn how to initialise a window in 10 different APIs and hand code coloured triangles, you may as well start out with something substantial, and preferably higher level, such as CrystalSpace with CELstart.

If you do intend to start from the bottom, then you will probably have to learn both sooner or later, and anyway, APIs are simple to learn compared to, say 3D math or script-compilers :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this