Should I use OpenGL or Directx

Started by
11 comments, last by georger.araujo 8 years, 6 months ago

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

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

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.

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.

Eric Richards

SlimDX tutorials - http://www.richardssoftware.net/

Twitter - @EricRichards22

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


The OP is obviously an absolute beginner. Neither Vulkan nor D3D12 are an appropriate API to recommend to a beginner. They are geared explicitly for hardcore graphics devs and not hobbyists or casual-professional needs.

OP's realistic choices are indeed between OpenGL and pre-12 Direct3D.

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


Don't expect that Mac will get Vulkan anytime soon. It's in the same boat as iOS; Apple and only Apple can develop Vulkan support for their platforms and they've given zero indication so far that they intend to do so.

My only recommendation for you is to wait Vulkan.


I would not wait. Even once it's out, it's going to be some time before there's any community support, public documentation, tutorials, books, etc.


Not that widest platform support is the best thing for an absolute beginner to care about. Beginners are not going to worry about compiling their experiments and 30 operating systems; they're just going to care about getting anything at all working on their primary development environment.

The hard part for a beginner is learning how 3D graphics even works and and should choose based on what is going to help their early education the most; the best choice is to choose an API with clean and consistent interfaces, high quality official documentation, broad community support in tutorials and examples, and a strong debugging toolset ecosystem).

I personally believe very strongly that D3D best fits all those criteria based on some years of working with students and absolute beginners, but now we're into the predicated flameware territory. smile.png

Sean Middleditch – Game Systems Engineer – Join my team!

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.

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.

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.

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

This topic is closed to new replies.

Advertisement