views:

2886

answers:

19

I'm starting a hobby game project on Windows that will make heavy use of 3D graphics effects. It will most likely be written in C++.

Should I use OpenGL or Direct3D for my graphics backend? Why?

Or should I use a ready-made graphics engine such as OGRE 3D? Which one?

Some "how to get started" links would be useful. (On either technology, or both.)

Edit - Yes I really meant Direct3D, not DirectX, thanks to graham.reeds for clarification

Edit - Mihai Lazar pointed out that I could also use a graphics engine such OGRE 3D. Edited the question to reflect this alternative.

+12  A: 

Start with OpenGL because there are good textbooks and other online references on it. Once you get the hang of writing 3D game, you would be able to make the judgment for yourself.

Finishing a game, even if it's really stupid and simple just to get you going, is more important than picking the right library. With glut, you can get some 3D object to show up on your screen in a day. Start with NeHe's tutorials.

eed3si9n
NeHe's tutorials are rather outdated; I wouldn't recommend them. I would recommend the classic OpenGL books as documented on Wikipedia: http://en.wikipedia.org/wiki/OpenGL#Documentation
strager
This TGA loading has got to stop..
bobobobo
I agree with strager that the NeHe tutorials are outdated. But I'd recommend the OpenGL SuperBible over the official OpenGL "red book". It's just better and more useful and concise.
Stefan Monov
A: 

To start with, we've got the Wikipedia comparison of OpenGL and Direct3D.

But I'd really like to hear some practical viewpoints, especially in the light of recent developments of OpenGL 3.0 and DirectX 10.

Antti Sykäri
+3  A: 

Hi, I did my dissertation at uni on a comparison of OpenGL vs Direct3D. The real benefits of Direct3D are that it has a regular release schedule - it's always being updated to take advantage of the latest advances in graphics hardware. How long has it taken between the OpenGL 2.0 and 3.0 releases? Also, a lot of work has been done in extensions for OpenGL, which means only some rendering will work on some cards.

Having said that, OpenGL will be easier to start programming with. As Direct3D is based heavily in COM, it has a steep learning curve.

If it were me, I would be choosing DirectX over OpenGL. That's at the cost of non-platform independance.

Mark Ingram
The latest-and-greatest hardware can be taken advantage of using OpenGL extensions, assuming the driver maker squeezes these in.
strager
The reason OpenGL has a "slow release cycle" is because the API must be maintained for backwards compatability. OpenGL's API is, for the most part, pretty clean, while Direct3D has some gunk still in it.
strager
+2  A: 

Best thing to do would be to abstract over your renderer as much as possible, to make porting to the other technology as painless as possible.

Bernard
This isn't a consideration n00bs should have to make
bobobobo
+6  A: 

You could also base your work on ogre they provide the abstraction themselves and they have really nice tools. Since this is a projects that's been around for over 6 years I think. The base library is not really for beginners since you need to know a bit about software design, but I found a lot of people that have written games using it.

It would be safer and quicker than learning the heavier stuff since it's already been abstracted. Plus after a couple of month you'll be talking 3D jargon anyways. There is also a book to get you started with Ogre, I think it's kinda old by now but a starting point anyways.

Mihai Lazar
+3  A: 

You must remember that DirectX is a collection of technologies - Input, Audio and Graphics. However to most people DX is synonymous with the renderer.

In my opinion D3D (or DirectGraphics) has not really been that hard since DX8. I have not tried DX9 or DX10.

Bernard is right - try to abstract as much as possible. Try to keep DX or OGL calls outside your object classes.

graham.reeds
A: 

@Mark Ingram

Hi, I did my dissertation at uni on a comparison of OpenGL vs Direct3D.

Would your dissertation be available by any chance?

Antti Sykäri
A: 

The suggestions for abstraction of an engine are good, assuming that you know what you are doing. It's difficult to write a good abstraction layer for graphics without having done it already.

I would suggest that you just pick one. You will pick up the concepts from either easily enough -- enough so that you can potentially work on an abstraction layer, or the other library easy enough. But just do it. I really wouldn't worry so much about which is the right one. They are both good, solid performers. DX10 (if you have Vista) may have the slight advantage of more up to date shader models, but for someone starting now, that is pretty irrelevant I think. GL has the advantage that some of the nigglier matrix/vector math operations are either hidden from you, or provided for you (although I think DX has some of these as well.)

Mark
+1  A: 

The thing you should consider is the decision of platform independence. Do you want to tie your game to Windows, or would you like to release it to Mac OS X or Linux at some point. If you decide that you want to support Linux, OS X in the future, you will need to use OpenGL.

There seems to be a lot of goodwill by the Linux community if the game is at least semi-released for Linux.

Redbeard 0x0A
A: 

While OpenGL is by far easy to start with and as some people already wrote - getting a triangle to show on screen and from there move to textures, particles and more can be done within a day.

I do however think that a good question to ask is what is your final goal.
If it is a simple game, no skeletal animation, and simple 3D - OpenGL is definitely the answer. If you aim way higher and don't want to put the time in developing all the technology from scratch (or go hunting for free libraries and putting all together) then DX is a good choice, I would go for DX9c until DX11 comes out.

If you don't mind messing with other languages other than C++ you should also take a look at the XNA development environment - it became quite mature and good.

Just as well, using an already existing engine is good if you know that it'll give you most of what you need, for the right price and will save you the time to develop it yourself, the main problem is that you'd need to go over several game engines (Ogre, Game Studio, Torque, etc..) and then make your choice based on limited experience - read as many reviews from casual developers as you can before you proceed, and try to take a look at the code if you intend to change it.

Hope it helped.

Adi
+1  A: 

To answer this question well requires more information about you:

  • what is your programming ability?

If it's high, I would probably start with Ogre (the best strictly rendering open source engine, IMHO) or another open source game engine, such as Delta3D, if you want additional features (sound, physics, etc.) that a game engine brings.

If you don't want to go with an engine, I would go with Direct3D, because it's being updated much quicker than OpenGL. I don't want to get into all the issues, but version 3.0 of OpenGL was announced during SIGGRAPH and most in the community were very disappointed with it. Direct3D puts you in a much better position to take advantage of shaders and other uses of the programmable pipeline.

If your programming ability is not too high, and you are doing this to learn programming, I would start with OpenGL, because it is easier to learn and there are more resources on the web (see http://nehe.gamedev.net for example).

Perry
+2  A: 

For the situation that you describe, I would recommend Direct3D.

The primary reason to use Direct3D instead of OpenGL is that often video card vendors only do a good job on the OpenGL drivers for their "high end" cards.

The low end game type cards tend to get poor and generally buggy drivers, causing problems on your end user's machines.

If portability is important, then that would be a big reason to look at OpenGL or Ogre instead.

But if you never plan to port, then focus on Direct3D since it is a more widely stable platform with better IHV driver support.

+1  A: 

It is my understanding that in Direct3D you must handle all resource allocation and management yourself, whereas the OpenGL specification leaves this to the driver/implementation rather than the application.

This allows Direct3D developers to use the best allocation and management methods suitable to the application, but is also extra work.

I have done the typical "Hello World" applications in each, and I prefer OpenGL over Direct3D, but that is just my opinion. You should try out both, spend a day or two learning and playing around with each, and decide for yourself.

dreamlax
+3  A: 

I have no previous OpenGL, DirectX or videogame experience and i have made have an open source race videogame with Ogre3d. Is a very good framework to start in videogames: well done code, plenty of docs and info in the net and very good starting tutorials.

The rendering engine is DirectX/OpenGl agnostic, you can later select to render your game with OpenGL or DirectX (withouth changes in your code)

Carlos Gil
Hey, Great game!!, I liked the "Simplicity over Graphics" things, because it actually looks very good :P, the track is solid and really big I liked the concept of several different terrains with a check point each. the only thing i missed was a restore switch for when you fall out a cliff.
levhita
well, it was only a project to start in 3D videogames, is not complete We made it during a videogames master.
Carlos Gil
A very jiggly vehicle it is. This was a fun play! My opponents I did bash them.
bobobobo
+5  A: 

If you're willing to consider C#, take a good look at XNA. For hobby projects, assuming what you want is to actually get a game up and running instead of tinkering with complex API code, I cannot recommend it highly enough. It is increasingly mature, well-documented, and, compared to D3D/OpenGL, very quick and easy to use. As a bonus, with a $100/year Creators Club membership, you can even use it to develop games for the Xbox 360.

lancekt
This is by far the best answer. C# __is__ phenomenal for beginners. You can access OpenGL through C# as well, but D3D via XNA is __by far__ the best way to learn, in my opinion
bobobobo
A: 

You have to think about what you want out of it, as it's a hobby project I'm assuming that "learning stuff" will be a major part of the experience so avoid picking up something that hides things from you and does stuff behind the scenes as this will only give you a fraction of the picture.

I'd go with Direct3D because it's got the better support, I find the docs easy to read and there are decent samples that come with the SDK. You can even use these samples as the base to build on if you want to get a kick start without the initial steep learning curve of getting things set up.

I started with OpenGL for the record, and after about a month went onto Direct3d (version 7 at the time). I found Direct3D forced me to be more aware of what I was wanting to do and how I was setting things up but I preferred this level of understanding.

Importantly IMO, whichever way you choose, take it step by step and get things on screen regularly. There's all sorts of reasons why something isn't on screen (it's transparent, the camera's inside the object, etc...) so by taking baby steps and getting stuff to display regularly you're both verifying things are still moving along and getting a little visual reward.

Gary Buckley
+1  A: 

I really agree with those telling you to learn Ogre3D. You said you'd use C++, so Ogre3D is a great choice. XNA uses C# and you'd have to learn the differences between it and C++, apart from learning the very XNA. Also XNA is neither Open Source nor cross platform, so if you wanna have a wider knowledge about game development, I'd suggest first learning SDL, and then Ogre3D.

A: 

Ogre3D is great if you want to do cross platform coding and if you want to leave all the rendering to the engine. OpenGL is also great for cross platform coding, but it also makes you do all the boring parts -- however it provides greater control.

I would avoid DirectX in case you want to port your game to other platforms. Plan for the future. DirectX 10 may provide some advantages compared to OpenGL, but I really don't think you'll feel them unless you're a professional development. Otherwise, if you're pro-Microsoft, you should use XNA anyway, since as an amateur developer you won't need control provided by DirectX.

I'm coding with OpenGL for quite some time now and with Ogre3D for a few months now and I can't say I want anything else. I recently got a book on DirectX 7 and I consider it messy. Perhaps things changed, but from what I observed I don't find DirectX, and by extrapolation Direct3D, attractive.

Ivan Vučica
A book on DirectX 7? There is massive difference between DX7 and DX8!
graham.reeds
A: 

Don't start with Ogre.

Start with OpenGL GLUT (Win32), and a tutorial or two.

As soon as you can move to Win32 and take a look at this site, which is pretty old now, but still, quite good.

bobobobo
Why not OGRE? You get platform independence, speed, eases of development, and don't have to worry about buggy Windows OpenGL drivers.
Zifre
Its not for beginners
bobobobo