Sign in to follow this  
Dalphin

Should I use OpenGL or Directx

Recommended Posts

Hello,

 

For some time, I've been learning to program in C++. I learned the basics yet (roughly until template programming)

and now I want to start to slowly make some more serious things.

 

I want to start experimenting in making 3D games (first making small games, then moving up).

 

I don't know really if I should learn Directx or OpenGL. If I look to the performace, it doens't make

much difference for me, so I would only like to know which one is easier to learn, as I normally have only 

a spare amount of time to learn.

 

And my second question: what is a good source (preferably a book) to learn it?

 

Thanks

Share this post


Link to post
Share on other sites
This question has been asked multiple times and is actually not allowed.

From the For Beginners FAQ:
 

"This" versus "that" threads are considered flame bait and will usually be closed on sight. Such questions have usually been asked before, several times, so there should be no need to ask them again.

Edited by MarkS

Share this post


Link to post
Share on other sites

It was surely good to not allow the question before but nowadays it's not the same because Vulkan will be there soon (December maybe).

Using Vulkan you have support for windows xp, windows vista, windows 8, windows 10, linux, mac, android and maybe ios if they allow it.

Using DirectX 12 you only have support for Windows 10 and Xbox One.

My only recommendation for you is to wait Vulkan.

Edited by Alundra

Share this post


Link to post
Share on other sites

A third alternative would be to go 2D first.  Depending on your comfort with linear algrebra and the mathematical underpinnings of 3D graphics, it can be a little overwhelming to jump into working with vectors, matrices, object, world, view and projection matrices.  Not to mention the infrastructure involved in dealing with standing up DirectX/OpenGL contexts, managing device flags, writing, loading, compiling and binding shaders, creating vertex and index buffers, and more.

 

Using something like SDL or a comparable 2D graphics library will allow you to get your feet wet with window management, input-handling, basic UI/menus, transitions between game states, sprites, sound effects, music, etc.  This stuff will all remain broadly applicable to 3D games, as well.  And building up in smaller steps can be more encouraging.  I think the canonical skill progression is generally considered to be something like: Snake->Pong->Breakout->Asteroids->PacMan->Mario/2D platformer clone->simple 3D FPS.

 

It sort of depends on what you want to be doing.  If you are more focused on learning graphics, rather than writing an entire game, then you could disregard the last paragraph and find a DirectX (prefer DX11, or wait for DX12 books to come out) or OpenGL book (something relatively recent, not using deprecated GL 1.x techniques).  Either way, once you learn one, the core concepts and the math are the same.

 

As Alundra touched on, DX12 and Vulkan are going to introduce some big changes.  Although, if history is any judge, the old ways are not going to disappear overnight.  There are still new games coming out targeted at DX9.

 

I'd agree with eric and would encourage you to try some 2D games first. This will help you better understand the "game loop" and how to manage assets effectively. I haven't messed with anything 3D yet and have been working on a few 2D games for 5-6 months. I'm sure this is going to make 3D a quicker and more efficient learning experience.

I use openGl because its used on many platforms, but id assume this decision depends on which platforms you're targeting.

Share this post


Link to post
Share on other sites

OpenGL is not as platform portable as you may think as a beginner.

 

Firstly you need to associate opengl contexts with a window or device, and this is platform specific.

 

Secondly nearly all features of opengl are vendor extensions, which may or may not be available on your device of choice even varying between versions of that platform and device.

 

Let's not even touch on the differences between opengl and opengl ES as found on mobile platforms. 

 

DirectX generally doesn't have these problems but sacrifices platform portability as the price for this.

 

Historically opengl has been slow to change and release due to internal politics and bickering between vendors, so a promise to release vulcan to the masses by December means December 2018 even though vulcan is very much simpler an api than vanilla opengl...

 

It's also definitely worth mentioning as others have the both dx12 and vulcan are nothing like dx11 and vanilla opengl and aren't newbie friendly. 

Share this post


Link to post
Share on other sites

I think everyone is missing the point of the OP.

 

This guy doen't know enough stuff to be able to jump into DX12 or Vulcan or even DX9 for that matter.

 

I'd suggest you go to nehe.gamedev.net and learn good ole OpenGL version 1.5'ish. This will teach you the 3d side of things.

Once you can create a window, render a gui, and load a model from file and move it around then you can move on.

 

To learn OpenGL 1.5ish basics (and the basics of 3D!! )

nehe.gamedev.net (tutorials listed on the right side of the screen)

 

To load an animated 3D model easily

http://milkshape3d.com/ (download the "MilkShape 3D Binary Model Viewer (/w src)" and at first copy paste but then learn it)

(also, 3drt.com has freebies in Ms3d format and also sells the premium models as Ms3d)

 

TBH there is enough source code at those 2 places to copy and paste together a working yet very lame working game.

 

I'm suggesting GL < 2.0 because its really hard for a beginner to learn how to write shaders. Obviosly once the OP knows the 3D basics then he can start with OpenGL 3.0+ or D3D10 and learn how to write shaders.

 

I'm a big fanboy of OpenGL myself simply because I like being able to write my OpenGL renderer and by using a few #ifdef #define's to wrap the OS specific lines of code (not very many) I can simply compile my C++ OpenGL renderer on Windows, Mac, and Linux with little problems.

Of course I'm only using X11 on Mac which works fine because learning Objective C++ is just too weird for me at this moment.

I do plan on adding DX8, 9, 10, 11, and maybe even 12 renderers to my current project along with Vulkan and Metal (once the Obj C weirdness goes away).

I've already made renderers for GL 3.0 and DX9 and 10 before.

Edited by Gl2eenDl2agon

Share this post


Link to post
Share on other sites

I disagree that the op start out on ancient opengl 1.5.

 

It could teach bad habits and is like telling someone that to learn to drive they should start by driving a model T ford. You'll have to throw away half what you learned.

 

The correct route IMHO is to start out with purely 2D and stay clear of opengl and dirextx, use SFML or similar and take your time. Once you are ready advice straight into directx 11 or opengl >2.0...

 

I disagree.

Learning to write shaders (the right way) for me was harder than everything else about 3D combined.

Upconverting from GL 1.x to 2.0+ isn't very hard either.

I typically protoype in GL1.x to get more work done since I don't have to concern myself with the actual work of rendering. Then I tend to adapt some older GL3.0 code and throw it in there later on.

 

 

 


Firstly you need to associate opengl contexts with a window or device, and this is platform specific.



Secondly nearly all features of opengl are vendor extensions, which may or may not be available on your device of choice even varying between versions of that platform and device.

 

First part isn't that hard and for most people they just keep copy-pasting the same code they wrote 5 years ago... or just use SDL.

 

Typically only the features added after a major version are extensions. If you want to use pretty much every feature of a DX10 graphics card you would use GL3.0 for example. You really don't need the extensions if you aim for the major GL version that has those features baked in. If your name is Carmack, then you use extensions because he is like the Chuck Norris of the 3D world.

Edited by Gl2eenDl2agon

Share this post


Link to post
Share on other sites

Thanks for the answers, I decided to start with SFML to get used to the usage of 2D graphics without

extraordinary hard 3D math stuff.

 

I looked a bit around and I found this book: http://www.amazon.com/SFML-Game-Development-Jan-Haller/dp/1849696845 (SFML Game Development).

 

Is this a good source to learn how to make 2D games (as I use books rather than sites, as books are most of the time good structured) or do you know

a better one?

 

Thanks

Edited by Dalphin

Share this post


Link to post
Share on other sites

I'm a little leery of Packt-published books, since they can be wildly inconsistent in the quality of their content and editing.  I happened to pick this one up at some point on their daily free ebook promotion, and it does seem pretty reasonable, from quick skimming.  If you're going to order a paper copy, it's much cheaper from the publisher than Amazon (https://www.packtpub.com/game-development/sfml-game-development)

Share this post


Link to post
Share on other sites

Thanks for the answers, I decided to start with SFML to get used to the usage of 2D graphics without

extraordinary hard 3D math stuff.

 

I looked a bit around and I found this book: http://www.amazon.com/SFML-Game-Development-Jan-Haller/dp/1849696845 (SFML Game Development).

 

Is this a good source to learn how to make 2D games (as I use books rather than sites, as books are most of the time good structured) or do you know

a better one?

 

Thanks

 

I own this book, and while I think it is good, I also think it is *not* for absolute beginners. It uses some ingenious C++11, and you should read about the State, Command and Game Loop design patterns beforehand.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this