50 lines
887 B
C
50 lines
887 B
C
/*
|
|
** sdl.c - <+DESC+>
|
|
**
|
|
** 2014 - Frank Villaro-Dixon <Frank@Villaro-Dixon.eu>
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "SDL/SDL.h"
|
|
#include "SDL/SDL_ttf.h"
|
|
#include "game.h"
|
|
|
|
void
|
|
init_SDL(struct s_game *g)
|
|
{
|
|
/* initialize SDL */
|
|
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
|
|
perror("Could not init SDL !");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
/* set the title bar */
|
|
SDL_WM_SetCaption("SDL Move", "SDL Move");
|
|
|
|
/* create window */
|
|
g->screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
|
|
if(!g->screen) {
|
|
perror("Could not grab screen !");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
if(TTF_Init() < 0) {
|
|
perror("Could not load SDL TTF");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
TTF_Font *font;
|
|
//TODO FIXME
|
|
font = TTF_OpenFont("/usr/share/fonts/TTF/DejaVuSerif.ttf", 26);
|
|
|
|
if(!font) {
|
|
perror("Could not load font");
|
|
}
|
|
|
|
g->font = font;
|
|
|
|
|
|
atexit(TTF_Quit);
|
|
atexit(SDL_Quit);
|
|
}
|