What is the difference and advantages of OpenGL, and DirectX in relation to each other and when to use?


I have entered some websites and some speak well of OpenGL for being multiplatform, others defending the use of directx due to being from microsoft and said to be easier to use, others speak to instead of directly using OpenGL to use SDL . I'm starting to see this part of programming now using graphical libraries, I wanted to know the main difference between performance and ease of use and when it's best to use each one.

asked by anonymous 03.07.2014 / 18:19

1 answer


The big difference is 2D vs. 3D!

The graphics part of SDL gives you an API for making 2D graphics, while OpenGL gives you both 2D and 3D.

Important to emphasize SDL also provides several APIs besides graphics: audio, mouse, keyboard, joystick, etc. I can not say the same for OpenGL (because I've never used it), but it's very common to see it being used with other frameworks for things that are not just graphics (very common to use OpenAL for audio for example) .

Another thing, while the SDL API does not give you functions to render 3D graphics, you can use OpenGL for that part together with SDL.

But which way to go?


If you are just starting to develop games (it's for games?) and (still) do not have a career in that area or use a famous engine, the best is SDL.

SDL is an excellent choice to go for essential game development concepts. The API is very simple to understand and very "raw", that is, most of the logic is going to be on your own and from there comes a great learning (like frame rate control, for example).

Another good thing about SDL is that it also supports OpenGL; that is, when you're ready to go to 3D , you're going to stay focused on that (since the rest you've already learned with SDL).

Bonus: SDL 2 supports android!

OpenGL (and DirectX)

Since OpenGL is much more dense than SDL, it's a lot of concepts and it's a bit trickier to get into a working result. The great advantage is that it will give you the opportunity to work with the most famous engines.

But here's the warning: if it's just a hobby, it can be a bit disheartening to start with something so great.

OpenGL is portable for Windows, Linux, Mac OS and PlayStation platforms.

DirectX, being Microsoft is specifically targeted to Windows and parallel systems such as Windows Phone or Xbox.

Follow this trail if you want to make games that require high performance (mainly 3D). Both APIs provide a layer of hardware access and make it possible to specifically program a video card (in the case of HLSL and GLSL Shaders).


Also add Unity !

I know little about Unity, but it's remarkable how he's seen growing up lately.

Recent examples are the latest Blizzard game, Hearthstone , which uses Unity as well as bought by Microsoft from UnityVS , which integrates Unity with Visual Studio (before this plugin was paid but now it's going to be for free!). >     

03.07.2014 / 18:56