Allegro error checking system
I am making an Allegro game, and I think it would be good to have a nice error checking system laid out before I start coding, this is how I usualy do it, I don't think it is good enough, what kind of systems do you use with your Allegro programs?
Code:
/*******************/
/* V-Ball */
/* Undefined Games */
/*******************/
#include <allegro.h>
FILE *fp = NULL;
BITMAP *buffer = NULL;
int setup();
void shutdown();
int main()
{
fp = fopen("log.txt", "w");
if(fp == NULL)
{
printf("Could not open log file, exiting...");
return 0;
}
fprintf(fp, "Starting program execution\n");
if(setup() != 0)
{
fprintf(fp, "Setup failed\n");
}
else
{
while(!key[KEY_ESC])
;
}
shutdown();
return 0;
}
END_OF_MAIN();
/*******************/
int setup()
{
allegro_init();
if(install_keyboard() != 0)
{
fprintf(fp, "Could not install keyboard\n");
return 1;
}
buffer = create_bitmap(640, 480);
if(buffer == NULL)
{
fprintf(fp, "Could not create buffer\n");
return 1;
}
set_color_depth(32);
if(set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640, 480, 0, 0) != 0)
{
fprintf(fp, "Could not set graphics mode\n");
return 1;
}
return 0;
}
/*******************/
void shutdown()
{
destroy_bitmap(buffer);
fprintf(fp, "Ending program execution\n");
fclose(fp);
}
/*******************/