OpenGL or Direct3D for a new Windows game project? Or something else?
Asked Answered
K

20

10

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.

Klinger answered 2/9, 2008 at 9:28 Comment(1)
Voting to close as too broad or opinion based.Kaiser
T
14

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.

Trinitrobenzene answered 2/9, 2008 at 9:32 Comment(3)
NeHe's tutorials are rather outdated; I wouldn't recommend them. I would recommend the classic OpenGL books as documented on Wikipedia: en.wikipedia.org/wiki/OpenGL#DocumentationSuspire
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.Filbert
Once you get the basics I recommend this set of tutorials. They really helped me with the more advanced stuff.Sway
A
8

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.

Apprehension answered 17/9, 2008 at 17:46 Comment(1)
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 opinionAdorne
C
7

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.

Charmine answered 2/9, 2008 at 10:37 Comment(0)
L
4

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.

Litigable answered 2/9, 2008 at 10:39 Comment(0)
L
3

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)

Lorenzoloresz answered 16/9, 2008 at 21:39 Comment(3)
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.Galenic
well, it was only a project to start in 3D videogames, is not complete We made it during a videogames master.Slot
A very jiggly vehicle it is. This was a fun play! My opponents I did bash them.Adorne
M
2

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.

Musil answered 2/9, 2008 at 9:40 Comment(2)
The latest-and-greatest hardware can be taken advantage of using OpenGL extensions, assuming the driver maker squeezes these in.Suspire
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.Suspire
P
2

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.

Peavy answered 2/9, 2008 at 10:8 Comment(1)
This isn't a consideration n00bs should have to makeAdorne
A
2

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.

Ashely answered 16/9, 2008 at 0:16 Comment(0)
C
1

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.

Calliope answered 12/9, 2008 at 18:52 Comment(0)
G
1

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).

Goering answered 16/9, 2008 at 0:4 Comment(0)
M
1

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.

Matter answered 16/9, 2008 at 0:18 Comment(0)
C
1

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.

Comic answered 21/9, 2008 at 23:22 Comment(0)
K
0

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.

Klinger answered 2/9, 2008 at 9:34 Comment(0)
L
0

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.)

Liturgy answered 12/9, 2008 at 18:43 Comment(0)
M
0

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.

Maymaya answered 15/9, 2008 at 18:22 Comment(0)
B
0

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.

Bloomington answered 17/9, 2008 at 18:1 Comment(0)
A
0

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.

Adorne answered 7/6, 2009 at 15:53 Comment(1)
Why not OGRE? You get platform independence, speed, eases of development, and don't have to worry about buggy Windows OpenGL drivers.Crocus
B
0

Clearly from the responses you've been getting, you can reasonably start with either D3D or OpenGL for your 3D graphics API. Triple-A gaming titles have been developed using both technologies, and they both have their strengths and weaknesses.

If you're already reasonably proficient in C++, either one will serve, however there's a number of other considerations to make in your selection:

  • Portability: OpenGL (and OpenGL ES) is available on Windows, Linux, OS X, iOS, Android, and other systems. D3D/DirectX locks you into MS platforms only.
  • Game Input: In DirectX, the DirectInput API gives you access to controllers. OpenGL doesn't have an equivalent here.
  • Sounds: DirectAudio supports sounds, OpenGL has no equivalent (however OpenAL is often used)
  • Physics: Depending on your game needs, you may need some advanced physics simulation

Typically the actual "gameplay" focus is on the AIs, combat, storyline, etc.

If you're still climbing the C++ learning curve (worthwhile, but takes some time), you might instead use C# and OpenTK. This would provide you with the benefits of a "gaming framework" like Ogre, reasonably direct access to OpenGL, and the significant benefits of using managed code (and IDE) for the game logic. OpenTK is cross-platform via Mono, so your code can run on OS X and Linux as well.

Have fun!

Boehmenism answered 25/6, 2011 at 1:52 Comment(0)
V
-1

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.

Vaginitis answered 29/11, 2008 at 18:27 Comment(1)
A book on DirectX 7? There is massive difference between DX7 and DX8!Litigable
S
-4

My opinion is that OpenGL is best.

OpenGL SuperBible: Comprehensive Tutorial and Reference is a good reference.

Samons answered 25/6, 2011 at 1:17 Comment(1)
You should add some arguments for your opinion that OpenGL is better.Glendoraglendower

© 2022 - 2024 — McMap. All rights reserved.