Sign in to follow this  

allegro or SDL

This topic is 4816 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

im having a dellema should i go for allegro or sdl? i know alot of people who like sdl but there is less documentation this would be my first time using a non councle based API (ie. windows,DOS) thanks [smile] ive read the forums and seen both librarys dised and praised i dont know Open GL and ive not really looked too far into eaither one

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
try both, i heard both are good
sdl has a license (LGPL i think) and Allegro is a giftware (you can do anything you want with this, no license).
i dont know sdl, but you can use allegro without opengl (for using allegro with opengl you can use allegroGL, which is also without a license. i think.)
some people will tell you to toss a coin, so first look at the sdl license and see if you agree with it. licenses are important, i think
another topic with same title as yours can be found here (i found it in the search engine)

Share this post


Link to post
Share on other sites
Quote:

Original post by raptorstrike
i know alot of people who like sdl but there is less documentation this would be my first time using a non councle based API

download the docs - they cover everything, and are easy to navigate. for tutorials, cone3d is an excellent reference.
sdl itself is 2d, so unless you tell sdl to, opengl won't be initialized by default, just sdl. opengl is just there for those who want to use it through sdl. remember, opengl is separate from both sdl and allegro, so you don't have to use it with either of them if you don't want to.
Quote:

Original post by Mindwarp
I would highly recommend it[sdl].

indeed, although allegro does have more goodies (from what i've heard). its up to you.

Share this post


Link to post
Share on other sites
For ease of use, I'd recommend Allegro first. Easier to get into for a beginner; SDL is somewhat lower-level. But as far as SDL vs. Allegro, both are very capable, so you can't pick wrong. Read over the general API's; see which one you like. Whichever one you pick, you can always try the other later. [smile]

Share this post


Link to post
Share on other sites
were can i find the genral API i have yet to find an api that lists defines and describes the functions in either i found a very short one in sdl and a bit of a longer one in allegro but i dont think either one is the"full library"

Share this post


Link to post
Share on other sites
Quote:
Original post by 23yrold3yrold
For ease of use, I'd recommend Allegro first. Easier to get into for a beginner; SDL is somewhat lower-level. But as far as SDL vs. Allegro, both are very capable, so you can't pick wrong. Read over the general API's; see which one you like. Whichever one you pick, you can always try the other later. [smile]

Yeah I'd have to agree that it harder to get any easier than writing games using allegro. I mean with the help of "game programming all in one" 2nd edition I was writing simple 2D games that ran on my apple powerbook,windows and linux box without any modification!
On the otherhand a lot more books seem to use SDL like data structures for game programmers,etc. But xcode on macs makes it just as easy to use either sdl or allegro since it has project templates for either one!
sdl template in xcode:

/* Simple program: Create a blank window, wait for keypress, quit.

Please see the SDL documentation for details on using the SDL API:
/Developer/Documentation/SDL/docs.html
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include "SDL.h"


//screen dimensions
const int SCREEN_WIDTH=640;
const int SCREEN_HEIGHT=480;

//display surface
SDL_Surface* g_pDisplaySurface = NULL;

//bitmap surface
SDL_Surface* g_pBitmapSurface = NULL;

//event structure
SDL_Event g_Event;

//source and destination rectangles
SDL_Rect g_SrcRect,g_DstRect;

//clipping rectangle
SDL_Rect g_ClipRect;

//main function
int main(int argc, char* argv[])
{
//initialize SDL
if (SDL_Init(SDL_INIT_VIDEO)==-1)
{
//error initializing SDL

//report the error
fprintf(stderr,"Could not initialize SDL!\n");

//end the program
exit(1);
}
else
{
//SDL initialized

//report success
fprintf(stdout,"SDL initialized properly!\n");

//set up to uninitialize SDL at exit
atexit(SDL_Quit);
}

//create windowed environment
g_pDisplaySurface = SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,0,SDL_ANYFORMAT);

//error check
if (g_pDisplaySurface == NULL)
{
//report error
fprintf(stderr,"Could not set up display surface!\n");

//exit the program
exit(1);
}

//set up the clipping rectangle
g_ClipRect.x=32;
g_ClipRect.y=32;
g_ClipRect.w=SCREEN_WIDTH-64;
g_ClipRect.h=SCREEN_HEIGHT-64;

//set the clip rect
SDL_SetClipRect(g_pDisplaySurface,&g_ClipRect);

//load in the bitmap
g_pBitmapSurface=SDL_LoadBMP("ball.bmp");

//set the color key for the bitmap surface
SDL_SetColorKey(g_pBitmapSurface,SDL_SRCCOLORKEY,0);

//error check
if(g_pBitmapSurface==NULL)
{
//report error
fprintf(stderr,"Could not load bitmap surface!\n");

//exit the program
exit(1);
}

//set the widths of the source and destination rectangles
g_SrcRect.w=g_DstRect.w=g_pBitmapSurface->w;
g_SrcRect.h=g_DstRect.h=g_pBitmapSurface->h;

//set source rect x and y to 0
g_SrcRect.x=g_SrcRect.y=0;

//repeat forever
for(;;)
{
//wait for an event
if(SDL_PollEvent(&g_Event)==0)
{
//no event, so blit image onto display

//pick a random destination location
g_DstRect.x=rand()%(SCREEN_WIDTH-g_DstRect.w);
g_DstRect.y=rand()%(SCREEN_HEIGHT-g_DstRect.h);

//blit
SDL_BlitSurface(g_pBitmapSurface,&g_SrcRect,g_pDisplaySurface,&g_DstRect);

//update the screen
SDL_UpdateRect(g_pDisplaySurface,0,0,0,0);
}
else
{
//event occurred, check for quit
if(g_Event.type==SDL_QUIT) break;
}
}

SDL_FreeSurface(g_pBitmapSurface);

//normal termination
fprintf(stdout,"Terminating normally.\n");

//return 0
return(0);
}
allegro template for mac:
/*
* InitGraphics
*
* Created by daveangel on Tue Aug 10 2004.
* Copyright (c) 2004 __MyCompanyName__. All rights reserved.
*/

#include <Allegro/allegro.h>


int main(int argc, const char *argv[])
{
// Initalize Allegro
allegro_init();
// Initalize the keyboard
install_keyboard();

// initalize video mode to 640x480
int ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
if(ret != 0) {
// allegro_message displays error message in pop-up dialog box or to console
allegro_message(allegro_error);
return;
}

// display screen resolution
textprintf(screen, font, 0, 0, makecol(255,255,255),
"%dx%d", SCREEN_W, SCREEN_H);

// wait for keypress
while(!key[KEY_ESC]);

// end program
allegro_exit();

return 0;


}
END_OF_MAIN();

Share this post


Link to post
Share on other sites
Quote:
Original post by raptorstrike
the reason i said is wasnt well documented is that every one points me to cone3d and i dont find that tutorial help ful at all


Ah! then you should have said, there is a lack of tutorials, rather than not well documented. [smile]

Cheers!

Share this post


Link to post
Share on other sites
I'd have to vote Allegro. I've looked at SDL, but I haven't used it. However, I've used Allegro extensively, and it's great. Very easy to use, and powerful enough for anything I want to do.

Share this post


Link to post
Share on other sites
I don't like SDL very much, mostly because to do anything interesting, you need half a dozen libraries, or write your own functions. You can't even easily plot a single pixel. Yeah, I know, they didn't want to clutter up the main library. Allegro might be a mammoth compared to SDL, but everything you need is already right there. What to draw some text, lines, or rotate an image? You can do that 'out of the box' with Allegro. With SDL you'll need some auxiliary libraries.

Share this post


Link to post
Share on other sites
Quote:
Original post by Alpha_ProgDes
what does Allegro use under the hood for 2D graphics?

Depends. It's a partial DirectX wrapper under Windows IINM ...
Quote:
Original post by Alpha_ProgDes
also if you want a 2D game with the 3D capabilities but without explicitly setting all the 3D stuff, what do you use?

Well, Allegro has fairly good 3D functionality. It's nowhere near as good as OpenGL, but it's good for simple effects. Anything more, and OpenGL can be used with Allegro anyway. Not sure what exactly you mean by "a 2D game with the 3D capabilities" though ...

Share this post


Link to post
Share on other sites

This topic is 4816 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.

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