-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.c
56 lines (45 loc) · 1.32 KB
/
init.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/************************************************************
* ***
* ~~=) All Rights Reversed - No Rights Reserved (=~~ ***
* ***
* Sweetmorn, the 40th day of Confusion in the YOLD 3184 ***
* ***
* Albert Veli ***
************************************************************/
/* Initialization and cleanup routines. */
#include <SDL2/SDL.h>
#include "init.h"
context ctx;
void init(int w, int h)
{
SDL_Window *window;
SDL_Renderer *renderer;
/* Init Video */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
SDL_Log("Unable to initialize SDL: %s", SDL_GetError());
SDL_Quit();
}
if (SDL_CreateWindowAndRenderer(w, h, 0, &window, &renderer)) {
SDL_Log("Unable to create SDL window/renderer: %s", SDL_GetError());
SDL_Quit();
}
ctx.window = window;
ctx.renderer = renderer;
ctx.quit = 0;
/* Init Audio */
ctx.audio_on = init_audio();
}
void cleanup(void)
{
cleanup_audio();
SDL_DestroyRenderer(ctx.renderer);
SDL_DestroyWindow(ctx.window);
SDL_Quit();
}
/**
* Local Variables:
* mode: c
* indent-tabs-mode: nil
* c-basic-offset: 3
* End:
*/