🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

DirectX vs OpenGL vs SDL vs Alegro

Started by
8 comments, last by Darrn 20 years, 6 months ago
as far as i get it, there are four standard APIs: direcx, opengl, sdl and alegro can someone please give me a short description of them, pros, cons, speed, 2D usage, 3D usage aso.
Advertisement
In reality there are only two "graphics" APIs - Direct3D and OpenGL (DirectX is the collaborative name for the all of the APIs), i would classify SDL and Allegro as more of "game libraries" as they provide a complete toolkit for writing applications whereas OGL/D3D only provide hardware accelerated graphics.

For 2D games/demos i would go with either SDL or Allegro as these are designed for 2D specifically, it''s possible to use D3D or OGL for 2D and many ppl do so but it would be easier to use a library that has been written for the sole purpose of 2D.

If your going the 3D route then learning either D3D or OGL is the way to go as these can take advantage of hardware capabilites for speeding things up
I would say go for SDL. It wraps up a lot of functionality, in a platform independant way, that 2D, 3D, network, I/O, sound etc. Its a lot easier using DirectX (for net/io/sound) and OpenGL (for 3D gfx). Ideal choice for a beginner I would say, and its comprehensive enough to write professional quality software in. Allegro is possibly a little bit easier, but overall I would still say go for SDL. Once you''ve messed with SDL a bit.. then its probably time to learn OpenGL, DirectX and Win32 (a little at least). You''ll benefit from having approached it at a higher level, and they all might not seem so mysterious. In reality you might never need to use OGL, DX and Win32 directly (with SDL around) but its nice to know whats going on behind the scenes to get the best out of it.
Second vote here for SDL

setting a window up in sdl is quite easy:

#include "SDL.h"int main(int argc, char *argc[]){    SDL_Init(SDL_INIT_VIDEO);    atexit(SDL_Quit);    SDL_Surface *scr=SDL_SetVideoMode(640,480,0,SDL_ANYFORMAT);    SDL_Delay(5000);    return 0;}//main


And you got a window Now imagine trying to do this in DirectX, or setting it up using WinAPI you wouldn''t even be half done




--{You fight like a dairy farmer!}

--{You fight like a dairy farmer!}

GLUT!!!! I vote for glut... its limited, but you learn a hell of alot with it.
quote: Original post by Spudder

For 2D games/demos i would go with either SDL or Allegro as these are designed for 2D specifically, it's possible to use D3D or OGL for 2D and many ppl do so but it would be easier to use a library that has been written for the sole purpose of 2D.

If your going the 3D route then learning either D3D or OGL is the way to go as these can take advantage of hardware capabilites for speeding things up


Beware! Don't get the wrong impression from this post! Its true Direct3d and opengl are the only two low level api's but SDL and Allegro can use Opengl for 3d too!

DirectX consists of sub apis like Directsound and DirectInput as well as Direct3d. Opengl consist of only 3d (and some 2d -- gl_ortho etc..) rendering. With both of these you have to take care of windowing and interfacing with the os for input etc..

Both SDL and Allegro use Directx on Windows for graphics etc, and on other platforms they use other apis (like SVGAlib on linux)

SDL and Allegro both have the capability of using hardware accelerated opengl; when using them they take care of the windowing and os interface for you.

SDL is a low level media lib, it provides basic 2d drawing, image loading, sound, timing, and input (keyboard and mouse) as well as the previously mention ability to use opengl calls.

Allegro is a gameprogramming lib, as such it gives you everything SDL plus a gui, pack files, font support, 3d math routines, a software 3d renderer (a bit buggy), primitive drawing, and rotation, scaling and blending of bitmaps/images. There are add on libs for sdl to give you this functionality, but Allegro is a complete package.


[edited by - nonnus29 on November 24, 2003 10:27:53 PM]
quote: Original post by Darrn
can someone please give me a short description of them, pros, cons, speed, 2D usage, 3D usage aso.


2D
I haven't had any experience with SDL (or OpenGL, or C++ DX), but I'm currently making an Allegro engine and have found it (Allegro) to be quite easy to use and develop with.

3D
There are millions of available engines/wrappers that make OpenGL and DirectX easy to use. I, personally, would recommend DirectX over OpenGL. Although they are both capable of the same things, I think that DirectX is becoming the standard for games which is accepted my most professional companies. But, of course, it really doesn't matter which one you choose as they are both widely known and used.

Please note too, I am not a professional game developer. I merely develop games as a hobby.

[EDIT]
Here's some Allegro code if you were curious. It just goes to full screen (800, 600) and prints Hello World on the screen.
#include <allegro.h>int main(){allegro_init();install_keyboard();set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0);textout(screen, font, "Hello World", 100, 100, makecol(255,0,0));readkey();return(0);// Exit with no errors}END_OF_MAIN();

I personally think that it is more self-explanitory then SDL

Rob Loach
Website: Over-Development
Current Project: rA1 - Allegro Engine

"The question is not how far, the question is do you possess the constitution, the depth of faith, to go as far as is needed. "
- The Boondock Saints


[edited by - Rob Loach on November 24, 2003 11:39:56 PM]
Rob Loach [Website] [Projects] [Contact]
I''d go with allegro if you are a beginner at least that''s the one I have experience with, I don''t know about SDL so I can''t really say anything about it. If you are serious then pick up either DirectX or OpenGL. I prefer OpenGL the biggest advantage it has is that it is cross platform, if you don''t care about that then DirectX, it is harder to learn but on the long run it''ll be easier to use since mostly everything you need is in one package including a way better documentation than OpenGL now that sucks
I''d argue that all you need to get going with OpenGL is a copy of ''OpenGL Game Programming'', The Red Book and a link to NEHE. The blue book is also handy and once you feel like going beyond 1.1 I''ve found the ''The OpenGL Extension Guide'' to be intresting and a hell of a lot easier to understand than the online specs
Both the Red Book and Blue Book are available as free e-books, in case your interested here''s the URLs:

Red Book: http://fly.cc.fer.hr/~unreal/theredbook/
Blue Book: http://www.parallab.uib.no/SGI_bookshelves/SGI_Developer/books/OpenGL_RM/sgi_html/bk02.html

Here''s another site i came across which provides tons of information about OpenGL, GLUT etc:

http://www.frii.com/~martz/oglfaq/

This topic is closed to new replies.

Advertisement