Jump to content
  • Advertisement
Sign in to follow this  
Chrono1081

Why does everyone recommend SDL?

This topic is 3700 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was learning SDL for a little bit but found there to be a severe lack of books/tutorials for it. Even so the two books and three websites I could find on it don't even come close to matching each other as far as syntax is concerned, so I think I will be switching to Allegro because I see many many books on Amazon for it, and many tutorials online and the books have full projects in them (or so it looks like). Am I missing something with SDL? Is there a reason people prefer it over allegro? All I am looking to do is create little 2D games for now, nothing special. I just am having a hard time finding any information on SDL. -For the record I have Focus on SDL, which sorry, I really don't find to be a helpful resource for beginners, I have Data Structures for Game Programmers (which is a different type of book but still has some SDL) and LazyFoo's tutorials (while nice, I really want more in-depth explanation and I would like to see just the basics, his tutorials have all kinds of optimizations, which while great to learn, makes it harder for a beginner in graphics who just wants to see the base concept at work and build from it.) I just want to make sure I am making the right decision before I sink some money into books.

Share this post


Link to post
Share on other sites
Advertisement
This one is a good alternative to SDL, but object oriented: sfml. It has quite some documentation, maybe you look some seconds into the tutorials!


greets

seb

Share this post


Link to post
Share on other sites
Many people just use the API documentation along with the various types of demos/examples out there to move ahead with certain libraries once they have their feet wet. Others prefer to have their hand held all the way along (like myself, sometimes [grin]). If you feel like Allegro suits you better, then just use Allegro [wink].

Share this post


Link to post
Share on other sites
I personally chose to use SDL over Allegro because I didn't like the weird macro syntax Allegro had in the setup code. It seemed wrong for some reason.

On the flip side of that, I found that SDL was relatively lacking in features (a GUI is not included in bas SDL for instance) on it's own (add-on libraries exist to do the things I wanted) compared to Allegro.

Since then I have found that SDL, SDL_Net, SDL_Image along with Opengl, guichan and SQLite provide me pretty much everything I need. Opengl and guichan really have made sticking with SDL a no brainer for me.

Share this post


Link to post
Share on other sites
SDL by itself may not seem like much but SDL with OpenGL is much more impressive. There is a Documentation Wiki on the SDL web page so you don't need a reference manual assuming your broadband Internet is always on.

Lazyfoo's tutorials are a good way to get started but not good enough to make a professional game with. If you want to learn how to make the most of SDL, look into OpenGL books. You can set up an OpenGL context with SDL and really go at it!

Also, SDL 1.3 should be coming out in the next year or so. See what that has to offer when it comes. It will be more OpenGL-based than the 1.2.x variety of SDL.

The reason Allegro isn't used by professionals as much as SDL is on the few professional Linux games there are, is because Allegro is better-suited to one-man teams and IIRC uses its own scene-render engine for its OpenGL implementation rather than the hardware-accelerated variety used by Windows, MacOSX, and Linux.

Also, regarding SFML, it may someday be better than SDL if they ever get all of the bugs worked out and get it working on 64-bit systems.

Share this post


Link to post
Share on other sites
Chrono1081,

I had the exact same problem with SDL. Being a beginner to game programming, I had never heard of Allegro until I bought Jonathan S. Harbour's "Game Programming All In One, Third Edition". This was just the book I needed. I was only 1/3 of the way through it when I put it down and started writing a pong game (don't worry, the book wasn't going over how to make pong.) A few days later I had a completed game with splash screen, scrolling background, animated sprites, sounds and music. I still haven't finished reading the book (just skimmed a page here and there), yet I continue to use Allegro without difficulty for my ongoing projects. At some point I intend to make the switch to SDL since it has been used on a lot more professional projects than Allegro has. I think because of what I have done with Allegro, I will more easily understand how to implement SDL. My thanks go to Jonathan S. Harbour for introducing me to Allegro in a way that made sense to my beginner's brain.

Share this post


Link to post
Share on other sites
Thank you guys for all of the replies :)

I was looking at getting Jonathan Harbours book but I can't tell if its written for C or C++ (most reviews say both) and I'm not really sure if it even matters. (Anyone know the answer to this?)

As far as SDL last night I realized that since the tutorials I want don't exist I had to write them myself. I started ripping apart the books and tutorials I had so that I can get down to the core concepts without all of the optimization and personal touches I keep finding on websites and in books. Not saying those are bad but for a beginner in graphics...those are bad. Its hard to weed through what is necessary and what is not. I was amazed when I was able to display a blank screen with about 8 lines (including headers and such) verses the 20 and 30+ I was using that I found on tutorials and in books. (Granted mine does bad things like not freeing surfaces but still, its nice to see just the basics)

Share this post


Link to post
Share on other sites
Hey Chrono1081,

I skimmed through the book for you. All the code examples in the book are written in C with one exception: One of the advanced chapters dealing with sprites uses a base C++ class. No inheritance or advanced OOP stuff, just a C structure with functions. I hope this helps...

Share this post


Link to post
Share on other sites
Not to keep plugging allegro, but here is a plain window (using C):

#include <allegro.h>

int main(void)
{
allegro_init();
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);

install_keyboard();
while(!key[KEY_ESC]);

allegro_exit();

return 0;
}
END_OF_MAIN()

Share this post


Link to post
Share on other sites
You know, I have wondered the same thing myself. Occasional language-hacks aside, Allegro is a very very nice library, same C style as SDL, with some major pros. A) Giftware/PD instead of LGPL. B) All inclusive in default builds. C) More "Pro-Active" Contributing community.

Now if you want to check into an awsome OOP api, please look into clanlib. But plan on learning through hacking / mailing lists mostly.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!