Ubuntu Pastebin

Paste from mcphail at Mon, 23 Nov 2015 16:40:53 +0000

Download as text
 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
57
58
59
60
61
62
63
64
65
static SDL_Window *main_window;
static SDL_Renderer *main_renderer;

int main(int argc, char *argv[])
{
        /* Sensible default options */
        struct game_options options = {
                .x_res = 800,
                .y_res = 600,
                .windowed = SDL_FALSE,
                .ghosting = SDL_TRUE,
                .level = 1,
                .p1_human = SDL_TRUE,
                .p2_human = SDL_FALSE
        };

        /* rc options take precedence over defaults */
        get_rc_options(&options);

        /* command line options take ultimate precedence */
        parse_commandline_options(&options, argc, argv);
        if (options.error) {
                fprintf(stderr, "Error parsing options: %s\n", options.error);
                exit(EXIT_FAILURE);
        }
        /* Halt if user passed --help, --version etc */
        if (options.stop_before_sdl) {
                exit(EXIT_SUCCESS);
        }

        /* Get SDL up and running */
        if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER)) {
                fprintf(stderr, "SDL initialization failed: %s\n",
                        SDL_GetError());
                exit(EXIT_FAILURE);
        }
        atexit(cleanup);

        int rv;
        if (options.windowed) {
                rv = SDL_CreateWindowAndRenderer(options.x_res, options.y_res,
                                                 SDL_WINDOW_INPUT_FOCUS,
                                                 &main_window, &main_renderer);
        } else {
                rv = SDL_CreateWindowAndRenderer(0, 0,
                                                 SDL_WINDOW_FULLSCREEN_DESKTOP,
                                                 &main_window, &main_renderer);
        }
        if (rv || !main_window || !main_renderer) {
                fprintf(stderr, "Couldn't create SDL window or renderer: %s\n",
                        SDL_GetError());
                exit(EXIT_FAILURE);
        }

        if (options.windowed) {
                SDL_ShowCursor(SDL_DISABLE);
        } else {
                SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
                SDL_RenderSetLogicalSize(main_renderer, options.x_res,
                                         options.y_res);
        }

        SDL_SetRenderDrawColor(main_renderer, P_BLACK);
        SDL_RenderClear(main_renderer);
        SDL_RenderPresent(main_renderer);
Download as text