Should I go with directX or openGL

Started by
22 comments, last by mike4 11 years, 9 months ago
My goal is to create a 2d game and I want to be as much in control as possible. That's why I'm currently learning C++ and eventually I will take the road of learning a graphics API and writting my own engine. My question to those who have had experience with both is, which should I go for? Is one language better then the other? more versatile? easier, harder to use?
Advertisement
dont write your own engine.. write your own game ;) When you have your game you can extract good parts into an engine when you make your next game..

If you're just starting out as a programmer you might want to consider some 2d lib instead of using ogl or dx right away as you will progress faster to make your first game.. I havent used any of them as I started with ogl at university, but others could help with that or it shouldn't be to hard to find some info.

If you still want to go with an API you probably want to start with opengl.. Its easer to get help and its an easier interface to start off with..
You could also go with SFML http://www.gamefromscratch.com/page/Game-From-Scratch-CPP-Edition.aspx < That is a fantastic tutorial with SFML and C++ showing off how to make a Pong clone with the graphic library SFML. It's really worth checking out and very easy to understand. From what i've seen with DX and OpenGL both of them aren't terribly bad to understand but starting out you'll wanna go with something simple to get a good foundation down. SFML can do that and it did for me. :D
ok I'll try that. thank you for the suggestion. Maybe I'll learn opengl sometime later.
As a matter of fact I can understand you wanting to write a program that interfaces with a gfx api such as OpenGL or DirectX. But take note that you should not write your own engine. You can play around with the 2 to know what it's like communicating with a graphics card, but later you should really go for a readymade engine to create your game; that way you spend more time creating your game than doing side irrelevant stuff. The idea is that first you realize your concept quickly by creating a prototype with a readymade engine, then you can decide to create your real final game whichever way you like, using lowlevel APIs and the like.
SDL is great for 2D or OpenGL, because it's cross platform. Personally I use Ogre with C++.
Having experience with both, here's my take on it.

Ultimately you should learn both - neither is 100% superior to the other and having knowledge of both will give you a more well-rounded perspective. Learning one will not prevent you from learning the other, and there are a lot of core concepts that are common to both.

Each has a subtle but significant difference in approach. D3D tends to expose what's on the hardware and only what's on the hardware whereas OpenGL tends to abstract things a little more. There are advantages and disadvantages to each approach, with D3D needing slightly more work here and there but OpenGL making it a little harder to find the fast path owing to software fallbacks.

The quality of D3D drivers tends to be higher but OpenGL is a better option if portability is important to you.

D3D has vastly superior tools and documentation available; unfortunately OpenGL just can't compete in this respect. OpenGL is also hampered by the fact that a lot of the info and tutorials available on the web are seriously out of date (many were never much good to begin with) and will lead you into bad habits.

In terms of ease of use there is next to no difference whatsoever between the modern versions of each API. You'll be writing almost the exact same kind of code with GL3.x+ as you will with D3D10/11, and the main differences will be just in the API calls (e.g. glMapBufferRange vs ID3D11DeviceContext::Map) - the surrounding C++ code will be effectively identical.

OpenGL does have an older "immediate mode" which many may find easier to get started with and which D3D has no equivalent of, and also still retains a fixed pipeline option (deprecated in modern versions but in practice it will always be available - at least for the foreseeable future) which modern D3D has done away with (it's still in version 9 though). Be cautioned that this is only easier for relatively trivial operations (the number of glTexEnv/etc calls you need to get the equivalent of one line of shader code can be quite staggering), you will be getting poor performance from it, and overall it's considered one of those "bad habits" I mentioned earlier.

Many older versions of D3D do come with helper interfaces for easier handling of sprites, meshes, shaders and so on, but these are being phased out in more recent versions.

So, as for which of the two to pick up first, you can more or less flip a coin. Each is an excellent introduction provided you avoid the more common pitfalls.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Thanks for all the replies. I'm very much a noob when it comes to game creation. What are SDL and SFML? Are they a graphics language similar to Opengl and DirectX?

Anyway, I'm thinking of doing that pong game in SFML and take it to completion just to get a basic idea of what's involved in making a full game.
Thanks MHagain. The game I want to make is completely 2D using animated sprites. I don't suppose that makes much of a difference right? Anyway. You said to pick one so I think I'll start with openGL a little later on after I've completed that Pong game in SFML, and eventually move on to D3D.

So, as for which of the two to pick up first, you can more or less flip a coin. Each is an excellent introduction provided you avoid the more common pitfalls.


Could you tell us some good tutorials for both? please

This topic is closed to new replies.

Advertisement