<p>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++.</p>

<p>Should I use OpenGL or Direct3D for my graphics backend? Why?</p>

<p>Or should I use a ready-made graphics engine such as <a href="http://www.ogre3d.org/" rel="nofollow noreferrer">OGRE 3D</a>? Which one?</p>

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

<p><strong>Edit</strong> - Yes I really meant Direct3D, not DirectX, thanks to <a href="https://stackoverflow.com/questions/39092/opengl-or-direct3d-for-a-new-windows-game-project#39202">graham.reeds</a> for clarification</p>

<p><strong>Edit</strong> - <a href="https://stackoverflow.com/questions/39092/opengl-or-direct3d-for-a-new-windows-game-project#39198">Mihai Lazar</a> pointed out that I could also use a graphics engine such OGRE 3D. Edited the question to reflect this alternative.</p>

[{'answer_id': 39096, 'author': 'Eugene Yokota', 'author_id': 3827, 'author_profile': 'https://Stackoverflow.com/users/3827', 'pm_score': 4, 'selected': False, 'text': '<p>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.</p>\n\n<p>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 <a href="http://www.opengl.org/resources/libraries/glut/" rel="noreferrer">glut</a>, you can get some 3D object to show up on your screen in a day. Start with <a href="http://nehe.gamedev.net/" rel="noreferrer">NeHe</a>\'s tutorials.</p>\n'}, {'answer_id': 39098, 'author': 'Antti Kissaniemi', 'author_id': 2948, 'author_profile': 'https://Stackoverflow.com/users/2948', 'pm_score': 0, 'selected': False, 'text': '<p>To start with, we\'ve got the <a href="http://en.wikipedia.org/wiki/Comparison_of_OpenGL_and_Direct3D" rel="nofollow noreferrer">Wikipedia comparison of OpenGL and Direct3D</a>.</p>\n\n<p>But I\'d really like to hear some practical viewpoints, especially in the light of recent developments of OpenGL&nbsp;3.0 and DirectX 10.</p>\n'}, {'answer_id': 39105, 'author': 'Mark Ingram', 'author_id': 986, 'author_profile': 'https://Stackoverflow.com/users/986', 'pm_score': 2, 'selected': False, 'text': "<p>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.</p>\n\n<p>Having said that, OpenGL will be easier to start programming with. As Direct3D is based heavily in COM, it has a steep learning curve.</p>\n\n<p>If it were me, I would be choosing DirectX over OpenGL. That's at the cost of non-platform independance.</p>\n"}, {'answer_id': 39155, 'author': 'Bernard', 'author_id': 61, 'author_profile': 'https://Stackoverflow.com/users/61', 'pm_score': 2, 'selected': False, 'text': '<p>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.</p>\n'}, {'answer_id': 39198, 'author': 'Mihai Lazar', 'author_id': 4204, 'author_profile': 'https://Stackoverflow.com/users/4204', 'pm_score': 3, 'selected': False, 'text': '<p>You could also base your work on <a href="http://www.ogre3d.org/" rel="noreferrer">ogre</a> 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. </p>\n\n<p>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.</p>\n'}, {'answer_id': 39202, 'author': 'graham.reeds', 'author_id': 342, 'author_profile': 'https://Stackoverflow.com/users/342', 'pm_score': 2, 'selected': False, 'text': '<p>You must remember that DirectX is a collection of technologies - Input, Audio and Graphics. However to most people DX is synonymous with the renderer.</p>\n\n<p>In my opinion D3D (or DirectGraphics) has not really been that hard since DX8. I have not tried DX9 or DX10.</p>\n\n<p>Bernard is right - try to abstract as much as possible. Try to keep DX or OGL calls outside your object classes.</p>\n'}, {'answer_id': 59731, 'author': 'Mark', 'author_id': 4405, 'author_profile': 'https://Stackoverflow.com/users/4405', 'pm_score': 0, 'selected': False, 'text': "<p>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.</p>\n\n<p>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.)</p>\n"}, {'answer_id': 59745, 'author': 'Astra', 'author_id': 5862, 'author_profile': 'https://Stackoverflow.com/users/5862', 'pm_score': 1, 'selected': False, 'text': '<p>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.</p>\n\n<p>There seems to be a lot of goodwill by the Linux community if the game is at least semi-released for Linux.</p>\n'}, {'answer_id': 65384, 'author': 'Adi', 'author_id': 9090, 'author_profile': 'https://Stackoverflow.com/users/9090', 'pm_score': 0, 'selected': False, 'text': "<p>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.</p>\n\n<p>I do however think that a good question to ask is what is your final goal.<br>\nIf 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.</p>\n\n<p>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.</p>\n\n<p>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.</p>\n\n<p>Hope it helped.</p>\n"}, {'answer_id': 68102, 'author': 'Perry', 'author_id': 10359, 'author_profile': 'https://Stackoverflow.com/users/10359', 'pm_score': 1, 'selected': False, 'text': '<p>To answer this question well requires more information about you:  </p>\n\n<ul>\n<li>what is your programming ability? </li>\n</ul>\n\n<p>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.</p>\n\n<p>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.</p>\n\n<p>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 <a href="http://nehe.gamedev.net" rel="nofollow noreferrer">http://nehe.gamedev.net</a> for example).</p>\n'}, {'answer_id': 68172, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>For the situation that you describe, I would recommend Direct3D.</p>\n\n<p>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.</p>\n\n<p>The low end game type cards tend to get poor and generally buggy drivers, causing problems on your end user\'s machines.</p>\n\n<p>If portability is important, then that would be a big reason to look at OpenGL or Ogre instead. </p>\n\n<p>But if you never plan to port, then focus on Direct3D since it is a more widely stable platform with better IHV driver support.</p>\n'}, {'answer_id': 68182, 'author': 'dreamlax', 'author_id': 10320, 'author_profile': 'https://Stackoverflow.com/users/10320', 'pm_score': 1, 'selected': False, 'text': '<p>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.</p>\n\n<p>This allows Direct3D developers to use the best allocation and management methods suitable to the application, but is also extra work.</p>\n\n<p>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.</p>\n'}, {'answer_id': 77422, 'author': 'José Carlos Gil', 'author_id': 8364, 'author_profile': 'https://Stackoverflow.com/users/8364', 'pm_score': 2, 'selected': False, 'text': '<p>I have no previous OpenGL, DirectX or videogame experience and i have made have an <a href="http://sourceforge.net/projects/crazycars" rel="nofollow noreferrer">open source race videogame</a> with <a href="http://www.ogre3d.org/" rel="nofollow noreferrer">Ogre3d</a>. Is a very good framework to start in videogames: well done code, plenty of <a href="http://www.ogre3d.org/wiki/index.php/Main_Page" rel="nofollow noreferrer">docs</a> and info in the net and <a href="http://www.ogre3d.org/wiki/index.php/Ogre_Tutorials" rel="nofollow noreferrer">very good starting tutorials</a>.</p>\n\n<p>The rendering engine is DirectX/OpenGl agnostic, you can later select to render your game with OpenGL or DirectX (withouth changes in your code)</p>\n'}, {'answer_id': 85771, 'author': 'lancekt', 'author_id': 16471, 'author_profile': 'https://Stackoverflow.com/users/16471', 'pm_score': 3, 'selected': False, 'text': "<p>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.</p>\n"}, {'answer_id': 85912, 'author': 'Gary Buckley', 'author_id': 16459, 'author_profile': 'https://Stackoverflow.com/users/16459', 'pm_score': 0, 'selected': False, 'text': '<p>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.   </p>\n\n<p>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.</p>\n\n<p>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.</p>\n\n<p>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.</p>\n'}, {'answer_id': 112513, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': "<p>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.</p>\n"}, {'answer_id': 327819, 'author': 'Ivan Vučica', 'author_id': 39974, 'author_profile': 'https://Stackoverflow.com/users/39974', 'pm_score': -1, 'selected': False, 'text': "<p>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.</p>\n\n<p>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.</p>\n\n<p>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. </p>\n"}, {'answer_id': 962151, 'author': 'bobobobo', 'author_id': 111307, 'author_profile': 'https://Stackoverflow.com/users/111307', 'pm_score': 0, 'selected': False, 'text': '<p>Don\'t start with Ogre.</p>\n\n<p>Start with OpenGL GLUT <a href="http://www.xmission.com/~nate/glut.html" rel="nofollow noreferrer">(Win32)</a>, and <a href="http://www.lighthouse3d.com/opengl/glut/" rel="nofollow noreferrer">a tutorial</a> or <a href="http://bobobobo.wordpress.com/2008/02/09/getting-started-with-glut/" rel="nofollow noreferrer">two</a>.</p>\n\n<p>As soon as you can <a href="http://bobobobo.wordpress.com/2008/02/11/opengl-in-a-proper-windows-app-no-glut/" rel="nofollow noreferrer">move to Win32</a> and take a look at <a href="http://gametutorials.com/" rel="nofollow noreferrer">this site</a>, which is pretty old now, but still, quite good.</p>\n'}, {'answer_id': 6475160, 'author': 'Dgenxron', 'author_id': 714412, 'author_profile': 'https://Stackoverflow.com/users/714412', 'pm_score': -1, 'selected': False, 'text': '<p>My opinion is that OpenGL is best.</p>\n\n<p><a href="https://rads.stackoverflow.com/amzn/click/com/0321712617" rel="nofollow noreferrer" rel="nofollow noreferrer">OpenGL SuperBible: Comprehensive Tutorial and Reference</a> is a good reference.</p>\n'}, {'answer_id': 6475289, 'author': 'holtavolt', 'author_id': 295726, 'author_profile': 'https://Stackoverflow.com/users/295726', 'pm_score': 0, 'selected': False, 'text': '<p>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.</p>\n\n<p>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:</p>\n\n<ul>\n<li>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.</li>\n<li>Game Input: In DirectX, the DirectInput API gives you access to controllers.  OpenGL doesn\'t have an equivalent here.</li>\n<li>Sounds: DirectAudio supports sounds, OpenGL has no equivalent (however OpenAL is often used)</li>\n<li>Physics: Depending on your game needs, you may need some advanced physics simulation</li>\n</ul>\n\n<p>Typically the actual "gameplay" focus is on the AIs, combat, storyline, etc.</p>\n\n<p>If you\'re still climbing the C++ learning curve (worthwhile, but takes some time), you might instead use C# and <a href="http://www.opentk.com" rel="nofollow">OpenTK</a>.  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.</p>\n\n<p>Have fun!</p>\n'}]
['https://Stackoverflow.com/questions/39092', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2948/']