
Former-commit-id: 496ef51b135330911afed2719564b90e6e039c89 Former-commit-id: 85a5e21f8bf4a7bdc0ade370a0872bc2fbc9b59b
55 lines
807 B
C
55 lines
807 B
C
#include "init.h"
|
|
|
|
extern void closeFont(TTF_Font *);
|
|
|
|
|
|
void init(char *title)
|
|
{
|
|
/* Initialise SDL */
|
|
|
|
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
|
{
|
|
printf("Could not initialize SDL: %s\n", SDL_GetError());
|
|
|
|
exit(1);
|
|
}
|
|
|
|
/* Initialise SDL_TTF */
|
|
|
|
if (TTF_Init() < 0)
|
|
{
|
|
printf("Couldn't initialize SDL TTF: %s\n", SDL_GetError());
|
|
|
|
exit(1);
|
|
}
|
|
|
|
|
|
game.screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, SDL_HWPALETTE|SDL_DOUBLEBUF);
|
|
|
|
if (game.screen == NULL)
|
|
{
|
|
printf("Couldn't set screen mode to %d x %d: %s\n", SCREEN_WIDTH, SCREEN_HEIGHT, SDL_GetError());
|
|
|
|
exit(1);
|
|
}
|
|
|
|
/* Set the screen title */
|
|
|
|
SDL_WM_SetCaption(title, NULL);
|
|
}
|
|
|
|
void cleanup()
|
|
{
|
|
/* Close the font */
|
|
|
|
closeFont(game.font);
|
|
|
|
/* Close SDL_TTF */
|
|
|
|
TTF_Quit();
|
|
|
|
/* Shut down SDL */
|
|
|
|
SDL_Quit();
|
|
}
|