test/common.c
author Sam Lantinga <slouken@libsdl.org>
Wed, 19 Jul 2006 05:03:21 +0000
changeset 1916 c773b0c0ac89
parent 1914 051df511279c
child 1921 f3399f779a1d
permissions -rw-r--r--
Implemented blend modes in the D3D renderer
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
/* A simple test program framework */
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     3
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
#include <stdio.h>
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
#include "common.h"
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
#define VIDEO_USAGE \
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
"[--video driver] [--renderer driver] [--info all|video|modes|render|event] [--display %d] [--fullscreen | --windows N] [--title title] [--center | --position X,Y] [--geometry WxH] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab]"
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
#define AUDIO_USAGE \
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
"[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]"
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
CommonState *
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
CommonCreateState(char **argv, Uint32 flags)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
{
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    CommonState *state = SDL_calloc(1, sizeof(*state));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
    if (!state) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
        SDL_OutOfMemory();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
        return NULL;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
    /* Initialize some defaults */
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
    state->argv = argv;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
    state->flags = flags;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
    state->window_title = argv[0];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
    state->window_flags = SDL_WINDOW_SHOWN;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
    state->window_x = SDL_WINDOWPOS_UNDEFINED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
    state->window_y = SDL_WINDOWPOS_UNDEFINED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
    state->window_w = 640;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
    state->window_h = 480;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
    state->num_windows = 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
    state->audiospec.freq = 22050;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
    state->audiospec.format = AUDIO_S16;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
    state->audiospec.channels = 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
    state->audiospec.samples = 2048;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
    return state;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
}
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
int
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
CommonArg(CommonState * state, int index)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
{
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
    char **argv = state->argv;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
    if (SDL_strcasecmp(argv[index], "--video") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
        ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
        if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
            return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
        state->videodriver = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
        return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
    if (SDL_strcasecmp(argv[index], "--renderer") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
        ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
        if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
            return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
        if (SDL_strcasecmp(argv[index], "opengl") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
            state->window_flags |= SDL_WINDOW_OPENGL;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
        state->renderdriver = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
        return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
    if (SDL_strcasecmp(argv[index], "--info") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
        ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
        if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
            return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
        if (SDL_strcasecmp(argv[index], "all") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
            state->verbose |=
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
                (VERBOSE_VIDEO | VERBOSE_MODES | VERBOSE_RENDER |
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
                 VERBOSE_EVENT);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
            return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
        if (SDL_strcasecmp(argv[index], "video") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
            state->verbose |= VERBOSE_VIDEO;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
            return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
        if (SDL_strcasecmp(argv[index], "modes") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
            state->verbose |= VERBOSE_MODES;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
            return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
        if (SDL_strcasecmp(argv[index], "render") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
            state->verbose |= VERBOSE_RENDER;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
            return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
        if (SDL_strcasecmp(argv[index], "event") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
            state->verbose |= VERBOSE_EVENT;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
            return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
        return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
    if (SDL_strcasecmp(argv[index], "--display") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
        ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
        if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
            return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
        state->display = SDL_atoi(argv[index]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
        return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
    if (SDL_strcasecmp(argv[index], "--fullscreen") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
        state->window_flags |= SDL_WINDOW_FULLSCREEN;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
        state->num_windows = 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
        return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
    if (SDL_strcasecmp(argv[index], "--windows") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
        ++index;
1916
c773b0c0ac89 Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1914
diff changeset
   108
        if (!argv[index] || !SDL_isdigit(*argv[index])) {
1914
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
            return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
        if (!(state->window_flags & SDL_WINDOW_FULLSCREEN)) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
            state->num_windows = SDL_atoi(argv[index]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
        return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
    if (SDL_strcasecmp(argv[index], "--title") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
        ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
        if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
            return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
        state->window_title = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
        return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
    if (SDL_strcasecmp(argv[index], "--center") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
        state->window_x = SDL_WINDOWPOS_CENTERED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
        state->window_y = SDL_WINDOWPOS_CENTERED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
        return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
    if (SDL_strcasecmp(argv[index], "--position") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
        char *x, *y;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
        ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
        if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
            return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
        x = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
        y = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
        while (*y && *y != ',') {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
            ++y;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
        if (!*y) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
            return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
        *y++ = '\0';
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
        state->window_x = SDL_atoi(x);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
        state->window_y = SDL_atoi(y);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
        return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
    if (SDL_strcasecmp(argv[index], "--geometry") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
        char *w, *h;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
        ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
        if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
            return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
        w = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
        h = argv[index];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
        while (*h && *h != 'x') {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
            ++h;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
        if (!*h) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
            return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
        *h++ = '\0';
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
        state->window_w = SDL_atoi(w);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
        state->window_h = SDL_atoi(h);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
        return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   166
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
    if (SDL_strcasecmp(argv[index], "--refresh") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
        ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
        if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
            return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
        state->refresh_rate = SDL_atoi(argv[index]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
        return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
    if (SDL_strcasecmp(argv[index], "--vsync") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
        state->render_flags |= SDL_Renderer_PresentVSync;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   177
        return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   179
    if (SDL_strcasecmp(argv[index], "--noframe") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   180
        state->window_flags |= SDL_WINDOW_BORDERLESS;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   181
        return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   183
    if (SDL_strcasecmp(argv[index], "--resize") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   184
        state->window_flags |= SDL_WINDOW_RESIZABLE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   185
        return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   186
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
    if (SDL_strcasecmp(argv[index], "--minimize") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   188
        state->window_flags |= SDL_WINDOW_MINIMIZED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
        return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
    if (SDL_strcasecmp(argv[index], "--maximize") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   192
        state->window_flags |= SDL_WINDOW_MAXIMIZED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   193
        return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   194
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   195
    if (SDL_strcasecmp(argv[index], "--grab") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   196
        state->window_flags |= SDL_WINDOW_INPUT_GRABBED;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   197
        return 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   199
    if (SDL_strcasecmp(argv[index], "--rate") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   200
        ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   201
        if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   202
            return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   203
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   204
        state->audiospec.freq = SDL_atoi(argv[index]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   205
        return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   206
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   207
    if (SDL_strcasecmp(argv[index], "--format") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   208
        ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   209
        if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   210
            return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   211
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   212
        if (SDL_strcasecmp(argv[index], "U8") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   213
            state->audiospec.format = AUDIO_U8;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   214
            return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   215
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   216
        if (SDL_strcasecmp(argv[index], "S8") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   217
            state->audiospec.format = AUDIO_S8;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   218
            return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   219
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   220
        if (SDL_strcasecmp(argv[index], "U16") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   221
            state->audiospec.format = AUDIO_U16;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   222
            return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   223
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   224
        if (SDL_strcasecmp(argv[index], "U16LE") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   225
            state->audiospec.format = AUDIO_U16LSB;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   226
            return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   227
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   228
        if (SDL_strcasecmp(argv[index], "U16BE") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   229
            state->audiospec.format = AUDIO_U16MSB;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   230
            return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   231
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   232
        if (SDL_strcasecmp(argv[index], "S16") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   233
            state->audiospec.format = AUDIO_S16;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   234
            return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   235
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   236
        if (SDL_strcasecmp(argv[index], "S16LE") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   237
            state->audiospec.format = AUDIO_S16LSB;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   238
            return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   239
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   240
        if (SDL_strcasecmp(argv[index], "S16BE") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
            state->audiospec.format = AUDIO_S16MSB;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   242
            return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
        return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   245
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   246
    if (SDL_strcasecmp(argv[index], "--channels") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   247
        ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
        if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   249
            return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   251
        state->audiospec.channels = SDL_atoi(argv[index]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   252
        return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   253
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   254
    if (SDL_strcasecmp(argv[index], "--samples") == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   255
        ++index;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
        if (!argv[index]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   257
            return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   258
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   259
        state->audiospec.samples = SDL_atoi(argv[index]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   260
        return 2;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   261
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   262
    if ((SDL_strcasecmp(argv[index], "-h") == 0)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   263
        || (SDL_strcasecmp(argv[index], "--help") == 0)) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   264
        /* Print the usage message */
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   265
        return -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   266
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   267
    return 0;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   268
}
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   269
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   270
const char *
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   271
CommonUsage(CommonState * state)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   272
{
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   273
    switch (state->flags & (SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   274
    case SDL_INIT_VIDEO:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   275
        return VIDEO_USAGE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   276
    case SDL_INIT_AUDIO:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   277
        return AUDIO_USAGE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   278
    case (SDL_INIT_VIDEO | SDL_INIT_AUDIO):
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   279
        return VIDEO_USAGE " " AUDIO_USAGE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   280
    default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   281
        return "";
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   282
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   283
}
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   284
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   285
static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   286
PrintRendererFlag(Uint32 flag)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   287
{
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   288
    switch (flag) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   289
    case SDL_Renderer_SingleBuffer:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   290
        fprintf(stderr, "SingleBuffer");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   291
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   292
    case SDL_Renderer_PresentCopy:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   293
        fprintf(stderr, "PresentCopy");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   294
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   295
    case SDL_Renderer_PresentFlip2:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   296
        fprintf(stderr, "PresentFlip2");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   297
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   298
    case SDL_Renderer_PresentFlip3:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   299
        fprintf(stderr, "PresentFlip3");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   300
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   301
    case SDL_Renderer_PresentDiscard:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   302
        fprintf(stderr, "PresentDiscard");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   303
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   304
    case SDL_Renderer_PresentVSync:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   305
        fprintf(stderr, "PresentVSync");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   306
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   307
    default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   308
        fprintf(stderr, "0x%8.8x", flag);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   309
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   310
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   311
}
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   312
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   313
static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   314
PrintBlendMode(Uint32 flag)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   315
{
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   316
    switch (flag) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   317
    case SDL_TextureBlendMode_None:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   318
        fprintf(stderr, "None");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   319
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   320
    case SDL_TextureBlendMode_Mask:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   321
        fprintf(stderr, "Mask");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   322
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   323
    case SDL_TextureBlendMode_Blend:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   324
        fprintf(stderr, "Blend");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   325
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   326
    case SDL_TextureBlendMode_Add:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   327
        fprintf(stderr, "Add");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   328
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   329
    case SDL_TextureBlendMode_Mod:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   330
        fprintf(stderr, "Mod");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   331
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   332
    default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   333
        fprintf(stderr, "0x%8.8x", flag);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   334
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   335
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   336
}
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   337
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   338
static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   339
PrintScaleMode(Uint32 flag)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   340
{
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   341
    switch (flag) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   342
    case SDL_TextureScaleMode_None:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   343
        fprintf(stderr, "None");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   344
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   345
    case SDL_TextureScaleMode_Fast:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   346
        fprintf(stderr, "Fast");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   347
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   348
    case SDL_TextureScaleMode_Slow:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   349
        fprintf(stderr, "Slow");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   350
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   351
    case SDL_TextureScaleMode_Best:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   352
        fprintf(stderr, "Best");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   353
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   354
    default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   355
        fprintf(stderr, "0x%8.8x", flag);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   356
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   357
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   358
}
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   359
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   360
static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   361
PrintPixelFormat(Uint32 format)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   362
{
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   363
    switch (format) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   364
    case SDL_PixelFormat_Unknown:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   365
        fprintf(stderr, "Unknwon");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   366
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   367
    case SDL_PixelFormat_Index1LSB:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   368
        fprintf(stderr, "Index1LSB");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   369
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   370
    case SDL_PixelFormat_Index1MSB:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   371
        fprintf(stderr, "Index1MSB");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   372
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   373
    case SDL_PixelFormat_Index4LSB:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   374
        fprintf(stderr, "Index4LSB");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   375
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   376
    case SDL_PixelFormat_Index4MSB:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   377
        fprintf(stderr, "Index4MSB");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   378
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   379
    case SDL_PixelFormat_Index8:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   380
        fprintf(stderr, "Index8");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   381
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   382
    case SDL_PixelFormat_RGB332:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   383
        fprintf(stderr, "RGB332");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   384
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   385
    case SDL_PixelFormat_RGB444:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   386
        fprintf(stderr, "RGB444");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   387
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   388
    case SDL_PixelFormat_RGB555:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   389
        fprintf(stderr, "RGB555");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   390
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   391
    case SDL_PixelFormat_ARGB4444:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   392
        fprintf(stderr, "ARGB4444");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   393
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   394
    case SDL_PixelFormat_ARGB1555:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   395
        fprintf(stderr, "ARGB1555");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   396
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   397
    case SDL_PixelFormat_RGB565:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   398
        fprintf(stderr, "RGB565");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   399
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   400
    case SDL_PixelFormat_RGB24:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   401
        fprintf(stderr, "RGB24");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   402
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   403
    case SDL_PixelFormat_BGR24:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   404
        fprintf(stderr, "BGR24");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   405
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   406
    case SDL_PixelFormat_RGB888:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   407
        fprintf(stderr, "RGB888");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   408
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   409
    case SDL_PixelFormat_BGR888:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   410
        fprintf(stderr, "BGR888");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   411
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   412
    case SDL_PixelFormat_ARGB8888:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   413
        fprintf(stderr, "ARGB8888");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   414
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   415
    case SDL_PixelFormat_RGBA8888:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   416
        fprintf(stderr, "RGBA8888");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   417
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   418
    case SDL_PixelFormat_ABGR8888:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   419
        fprintf(stderr, "ABGR8888");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   420
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   421
    case SDL_PixelFormat_BGRA8888:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   422
        fprintf(stderr, "BGRA8888");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   423
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   424
    case SDL_PixelFormat_ARGB2101010:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   425
        fprintf(stderr, "ARGB2101010");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   426
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   427
    case SDL_PixelFormat_YV12:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   428
        fprintf(stderr, "YV12");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   429
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   430
    case SDL_PixelFormat_IYUV:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   431
        fprintf(stderr, "IYUV");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   432
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   433
    case SDL_PixelFormat_YUY2:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   434
        fprintf(stderr, "YUY2");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   435
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   436
    case SDL_PixelFormat_UYVY:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   437
        fprintf(stderr, "UYVY");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   438
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   439
    case SDL_PixelFormat_YVYU:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   440
        fprintf(stderr, "YVYU");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   441
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   442
    default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   443
        fprintf(stderr, "0x%8.8x", format);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   444
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   445
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   446
}
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   447
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   448
static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   449
PrintRenderer(SDL_RendererInfo * info)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   450
{
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   451
    int i, count;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   452
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   453
    fprintf(stderr, "  Renderer %s:\n", info->name);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   454
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   455
    fprintf(stderr, "    Flags: 0x%8.8X", info->flags);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   456
    fprintf(stderr, " (");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   457
    count = 0;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   458
    for (i = 0; i < sizeof(info->flags) * 8; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   459
        Uint32 flag = (1 << i);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   460
        if (info->flags & flag) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   461
            if (count > 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   462
                fprintf(stderr, " | ");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   463
            }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   464
            PrintRendererFlag(flag);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   465
            ++count;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   466
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   467
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   468
    fprintf(stderr, ")\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   469
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   470
    fprintf(stderr, "    Blend: 0x%8.8X", info->blend_modes);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   471
    fprintf(stderr, " (");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   472
    count = 0;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   473
    for (i = 0; i < sizeof(info->blend_modes) * 8; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   474
        Uint32 flag = (1 << i);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   475
        if (info->blend_modes & flag) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   476
            if (count > 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   477
                fprintf(stderr, " | ");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   478
            }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   479
            PrintBlendMode(flag);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   480
            ++count;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   481
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   482
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   483
    fprintf(stderr, ")\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   484
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   485
    fprintf(stderr, "    Scale: 0x%8.8X", info->scale_modes);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   486
    fprintf(stderr, " (");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   487
    count = 0;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   488
    for (i = 0; i < sizeof(info->scale_modes) * 8; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   489
        Uint32 flag = (1 << i);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   490
        if (info->scale_modes & flag) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   491
            if (count > 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   492
                fprintf(stderr, " | ");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   493
            }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   494
            PrintScaleMode(flag);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   495
            ++count;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   496
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   497
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   498
    fprintf(stderr, ")\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   499
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   500
    fprintf(stderr, "    Texture formats (%d): ", info->num_texture_formats);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   501
    for (i = 0; i < info->num_texture_formats; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   502
        if (i > 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   503
            fprintf(stderr, ", ");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   504
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   505
        PrintPixelFormat(info->texture_formats[i]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   506
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   507
    fprintf(stderr, "\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   508
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   509
    if (info->max_texture_width || info->max_texture_height) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   510
        fprintf(stderr, "    Max Texture Size: %dx%d\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   511
                info->max_texture_width, info->max_texture_height);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   512
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   513
}
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   514
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   515
SDL_bool
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   516
CommonInit(CommonState * state)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   517
{
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   518
    int i, j, m, n;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   519
    SDL_DisplayMode fullscreen_mode;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   520
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   521
    if (state->flags & SDL_INIT_VIDEO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   522
        if (state->verbose & VERBOSE_VIDEO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   523
            n = SDL_GetNumVideoDrivers();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   524
            if (n == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   525
                fprintf(stderr, "No built-in video drivers\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   526
            } else {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   527
                fprintf(stderr, "Built-in video drivers:");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   528
                for (i = 0; i < n; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   529
                    if (i > 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   530
                        fprintf(stderr, ",");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   531
                    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   532
                    fprintf(stderr, " %s", SDL_GetVideoDriver(i));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   533
                }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   534
                fprintf(stderr, "\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   535
            }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   536
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   537
        if (SDL_VideoInit(state->videodriver, 0) < 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   538
            fprintf(stderr, "Couldn't initialize video driver: %s\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   539
                    SDL_GetError());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   540
            return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   541
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   542
        if (state->verbose & VERBOSE_VIDEO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   543
            fprintf(stderr, "Video driver: %s\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   544
                    SDL_GetCurrentVideoDriver());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   545
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   546
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   547
        if (state->verbose & VERBOSE_MODES) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   548
            const SDL_DisplayMode *mode;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   549
            int bpp;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   550
            Uint32 Rmask, Gmask, Bmask, Amask;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   551
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   552
            n = SDL_GetNumVideoDisplays();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   553
            fprintf(stderr, "Number of displays: %d\n", n);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   554
            for (i = 0; i < n; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   555
                fprintf(stderr, "Display %d:\n", i);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   556
                SDL_SelectVideoDisplay(i);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   557
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   558
                mode = SDL_GetDesktopDisplayMode();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   559
                SDL_PixelFormatEnumToMasks(mode->format, &bpp, &Rmask, &Gmask,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   560
                                           &Bmask, &Amask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   561
                fprintf(stderr,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   562
                        "  Current mode: %dx%d@%dHz, %d bits-per-pixel\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   563
                        mode->w, mode->h, mode->refresh_rate, bpp);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   564
                if (Rmask || Gmask || Bmask) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   565
                    fprintf(stderr, "      Red Mask = 0x%.8x\n", Rmask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   566
                    fprintf(stderr, "      Green Mask = 0x%.8x\n", Gmask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   567
                    fprintf(stderr, "      Blue Mask = 0x%.8x\n", Bmask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   568
                    if (Amask)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   569
                        fprintf(stderr, "      Alpha Mask = 0x%.8x\n", Amask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   570
                }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   571
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   572
                /* Print available fullscreen video modes */
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   573
                m = SDL_GetNumDisplayModes();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   574
                if (m == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   575
                    fprintf(stderr, "No available fullscreen video modes\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   576
                } else {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   577
                    fprintf(stderr, "  Fullscreen video modes:\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   578
                    for (j = 0; j < m; ++j) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   579
                        mode = SDL_GetDisplayMode(j);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   580
                        SDL_PixelFormatEnumToMasks(mode->format, &bpp, &Rmask,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   581
                                                   &Gmask, &Bmask, &Amask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   582
                        fprintf(stderr,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   583
                                "    Mode %d: %dx%d@%dHz, %d bits-per-pixel\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   584
                                j, mode->w, mode->h, mode->refresh_rate, bpp);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   585
                        if (Rmask || Gmask || Bmask) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   586
                            fprintf(stderr, "        Red Mask = 0x%.8x\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   587
                                    Rmask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   588
                            fprintf(stderr, "        Green Mask = 0x%.8x\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   589
                                    Gmask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   590
                            fprintf(stderr, "        Blue Mask = 0x%.8x\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   591
                                    Bmask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   592
                            if (Amask)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   593
                                fprintf(stderr,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   594
                                        "        Alpha Mask = 0x%.8x\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   595
                                        Amask);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   596
                        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   597
                    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   598
                }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   599
            }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   600
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   601
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   602
        SDL_SelectVideoDisplay(state->display);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   603
        if (state->verbose & VERBOSE_RENDER) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   604
            SDL_RendererInfo info;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   605
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   606
            n = SDL_GetNumRenderers();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   607
            if (n == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   608
                fprintf(stderr, "No built-in render drivers\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   609
            } else {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   610
                fprintf(stderr, "Built-in render video drivers:\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   611
                for (i = 0; i < n; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   612
                    SDL_GetRendererInfo(i, &info);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   613
                    PrintRenderer(&info);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   614
                }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   615
            }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   616
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   617
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   618
        switch (state->depth) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   619
        case 8:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   620
            fullscreen_mode.format = SDL_PixelFormat_Index8;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   621
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   622
        case 15:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   623
            fullscreen_mode.format = SDL_PixelFormat_RGB555;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   624
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   625
        case 16:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   626
            fullscreen_mode.format = SDL_PixelFormat_RGB565;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   627
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   628
        default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   629
            fullscreen_mode.format = SDL_PixelFormat_RGB888;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   630
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   631
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   632
        fullscreen_mode.w = state->window_w;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   633
        fullscreen_mode.h = state->window_h;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   634
        fullscreen_mode.refresh_rate = state->refresh_rate;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   635
        SDL_SetFullscreenDisplayMode(&fullscreen_mode);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   636
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   637
        state->windows =
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   638
            (SDL_WindowID *) SDL_malloc(state->num_windows *
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   639
                                        sizeof(*state->windows));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   640
        if (!state->windows) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   641
            fprintf(stderr, "Out of memory!\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   642
            return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   643
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   644
        for (i = 0; i < state->num_windows; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   645
            char title[1024];
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   646
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   647
            if (state->num_windows > 1) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   648
                SDL_snprintf(title, SDL_arraysize(title), "%s %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   649
                             state->window_title, i + 1);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   650
            } else {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   651
                SDL_strlcpy(title, state->window_title, SDL_arraysize(title));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   652
            }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   653
            state->windows[i] =
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   654
                SDL_CreateWindow(title, state->window_x, state->window_y,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   655
                                 state->window_w, state->window_h,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   656
                                 state->window_flags);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   657
            if (!state->windows[i]) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   658
                fprintf(stderr, "Couldn't create window: %s\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   659
                        SDL_GetError());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   660
                return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   661
            }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   662
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   663
            if (state->renderdriver
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   664
                || !(state->window_flags & SDL_WINDOW_OPENGL)) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   665
                m = -1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   666
                if (state->renderdriver) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   667
                    SDL_RendererInfo info;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   668
                    n = SDL_GetNumRenderers();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   669
                    for (j = 0; j < n; ++j) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   670
                        SDL_GetRendererInfo(j, &info);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   671
                        if (SDL_strcasecmp(info.name, state->renderdriver) ==
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   672
                            0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   673
                            m = j;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   674
                            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   675
                        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   676
                    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   677
                    if (m == n) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   678
                        fprintf(stderr,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   679
                                "Couldn't find render driver named %s",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   680
                                state->renderdriver);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   681
                        return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   682
                    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   683
                }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   684
                if (SDL_CreateRenderer
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   685
                    (state->windows[i], m, state->render_flags) < 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   686
                    fprintf(stderr, "Couldn't create renderer: %s\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   687
                            SDL_GetError());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   688
                    return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   689
                }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   690
            }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   691
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   692
        SDL_SelectRenderer(state->windows[0]);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   693
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   694
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   695
    if (state->flags & SDL_INIT_AUDIO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   696
        if (state->verbose & VERBOSE_AUDIO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   697
            n = SDL_GetNumAudioDrivers();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   698
            if (n == 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   699
                fprintf(stderr, "No built-in audio drivers\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   700
            } else {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   701
                fprintf(stderr, "Built-in audio drivers:");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   702
                for (i = 0; i < n; ++i) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   703
                    if (i > 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   704
                        fprintf(stderr, ",");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   705
                    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   706
                    fprintf(stderr, " %s", SDL_GetAudioDriver(i));
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   707
                }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   708
                fprintf(stderr, "\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   709
            }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   710
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   711
        if (SDL_AudioInit(state->audiodriver) < 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   712
            fprintf(stderr, "Couldn't initialize audio driver: %s\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   713
                    SDL_GetError());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   714
            return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   715
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   716
        if (state->verbose & VERBOSE_VIDEO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   717
            fprintf(stderr, "Audio driver: %s\n",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   718
                    SDL_GetCurrentAudioDriver());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   719
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   720
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   721
        if (SDL_OpenAudio(&state->audiospec, NULL) < 0) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   722
            fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   723
            return SDL_FALSE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   724
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   725
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   726
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   727
    return SDL_TRUE;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   728
}
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   729
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   730
static void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   731
PrintEvent(SDL_Event * event)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   732
{
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   733
    fprintf(stderr, "SDL EVENT: ");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   734
    switch (event->type) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   735
    case SDL_WINDOWEVENT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   736
        switch (event->window.event) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   737
        case SDL_WINDOWEVENT_SHOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   738
            fprintf(stderr, "Window %d shown", event->window.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   739
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   740
        case SDL_WINDOWEVENT_HIDDEN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   741
            fprintf(stderr, "Window %d hidden", event->window.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   742
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   743
        case SDL_WINDOWEVENT_EXPOSED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   744
            fprintf(stderr, "Window %d exposed: %d", event->window.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   745
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   746
        case SDL_WINDOWEVENT_MOVED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   747
            fprintf(stderr, "Window %d moved to %d,%d: %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   748
                    event->window.windowID, event->window.data1,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   749
                    event->window.data2);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   750
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   751
        case SDL_WINDOWEVENT_RESIZED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   752
            fprintf(stderr, "Window %d resized to %dx%d: %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   753
                    event->window.windowID, event->window.data1,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   754
                    event->window.data2);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   755
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   756
        case SDL_WINDOWEVENT_MINIMIZED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   757
            fprintf(stderr, "Window %d minimized", event->window.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   758
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   759
        case SDL_WINDOWEVENT_MAXIMIZED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   760
            fprintf(stderr, "Window %d maximized", event->window.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   761
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   762
        case SDL_WINDOWEVENT_RESTORED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   763
            fprintf(stderr, "Window %d restored", event->window.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   764
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   765
        case SDL_WINDOWEVENT_ENTER:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   766
            fprintf(stderr, "Mouse entered window %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   767
                    event->window.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   768
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   769
        case SDL_WINDOWEVENT_LEAVE:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   770
            fprintf(stderr, "Mouse left window %d", event->window.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   771
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   772
        case SDL_WINDOWEVENT_FOCUS_GAINED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   773
            fprintf(stderr, "Window %d gained keyboard focus",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   774
                    event->window.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   775
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   776
        case SDL_WINDOWEVENT_FOCUS_LOST:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   777
            fprintf(stderr, "Window %d lost keyboard focus",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   778
                    event->window.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   779
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   780
        default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   781
            fprintf(stderr, "Window %d got unknown event %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   782
                    event->window.windowID, event->window.event);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   783
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   784
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   785
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   786
    case SDL_KEYDOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   787
        fprintf(stderr, "Keyboard %d: key %s pressed in window %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   788
                event->key.which, SDL_GetKeyName(event->key.keysym.sym),
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   789
                event->key.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   790
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   791
    case SDL_KEYUP:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   792
        fprintf(stderr, "Keyboard %d: key %s released in window %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   793
                event->key.which, SDL_GetKeyName(event->key.keysym.sym),
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   794
                event->key.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   795
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   796
    case SDL_TEXTINPUT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   797
        fprintf(stderr, "Keyboard %d: text input \"%s\" in window %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   798
                event->text.which, event->text.text, event->text.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   799
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   800
    case SDL_MOUSEMOTION:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   801
        fprintf(stderr, "Mouse %d: moved to %d,%d (%d,%d) in window %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   802
                event->motion.which, event->motion.x, event->motion.y,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   803
                event->motion.xrel, event->motion.yrel,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   804
                event->motion.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   805
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   806
    case SDL_MOUSEBUTTONDOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   807
        fprintf(stderr, "Mouse %d: button %d pressed at %d,%d in window %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   808
                event->button.which, event->button.button, event->button.x,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   809
                event->button.y, event->button.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   810
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   811
    case SDL_MOUSEBUTTONUP:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   812
        fprintf(stderr, "Mouse %d: button %d released at %d,%d in window %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   813
                event->button.which, event->button.button, event->button.x,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   814
                event->button.y, event->button.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   815
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   816
    case SDL_MOUSEWHEEL:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   817
        fprintf(stderr, "Mouse %d: wheel scrolled %d in window %d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   818
                event->wheel.which, event->wheel.motion,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   819
                event->button.windowID);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   820
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   821
    case SDL_JOYBALLMOTION:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   822
        fprintf(stderr, "Joystick %d: ball %d moved by %d,%d",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   823
                event->jball.which, event->jball.ball, event->jball.xrel,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   824
                event->jball.yrel);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   825
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   826
    case SDL_JOYHATMOTION:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   827
        fprintf(stderr, "Joystick %d: hat %d moved to ", event->jhat.which,
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   828
                event->jhat.hat);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   829
        switch (event->jhat.value) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   830
        case SDL_HAT_CENTERED:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   831
            fprintf(stderr, "CENTER");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   832
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   833
        case SDL_HAT_UP:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   834
            fprintf(stderr, "UP");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   835
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   836
        case SDL_HAT_RIGHTUP:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   837
            fprintf(stderr, "RIGHTUP");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   838
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   839
        case SDL_HAT_RIGHT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   840
            fprintf(stderr, "RIGHT");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   841
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   842
        case SDL_HAT_RIGHTDOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   843
            fprintf(stderr, "RIGHTDOWN");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   844
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   845
        case SDL_HAT_DOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   846
            fprintf(stderr, "DOWN");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   847
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   848
        case SDL_HAT_LEFTDOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   849
            fprintf(stderr, "LEFTDOWN");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   850
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   851
        case SDL_HAT_LEFT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   852
            fprintf(stderr, "LEFT");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   853
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   854
        case SDL_HAT_LEFTUP:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   855
            fprintf(stderr, "LEFTUP");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   856
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   857
        default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   858
            fprintf(stderr, "UNKNOWN");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   859
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   860
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   861
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   862
    case SDL_JOYBUTTONDOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   863
        fprintf(stderr, "Joystick %d: button %d pressed",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   864
                event->jbutton.which, event->jbutton.button);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   865
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   866
    case SDL_JOYBUTTONUP:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   867
        fprintf(stderr, "Joystick %d: button %d released",
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   868
                event->jbutton.which, event->jbutton.button);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   869
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   870
    case SDL_QUIT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   871
        fprintf(stderr, "Quit requested");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   872
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   873
    case SDL_USEREVENT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   874
        fprintf(stderr, "User event %d", event->user.code);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   875
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   876
    default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   877
        fprintf(stderr, "Unknown event %d", event->type);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   878
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   879
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   880
    fprintf(stderr, "\n");
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   881
}
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   882
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   883
void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   884
CommonEvent(CommonState * state, SDL_Event * event, int *done)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   885
{
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   886
    if (state->verbose & VERBOSE_EVENT) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   887
        PrintEvent(event);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   888
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   889
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   890
    switch (event->type) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   891
    case SDL_WINDOWEVENT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   892
        switch (event->window.event) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   893
        case SDL_WINDOWEVENT_CLOSE:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   894
            *done = 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   895
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   896
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   897
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   898
    case SDL_KEYDOWN:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   899
        switch (event->key.keysym.sym) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   900
            /* Add hotkeys here */
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   901
        case SDLK_ESCAPE:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   902
            *done = 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   903
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   904
        default:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   905
            break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   906
        }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   907
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   908
    case SDL_QUIT:
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   909
        *done = 1;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   910
        break;
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   911
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   912
}
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   913
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   914
void
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   915
CommonQuit(CommonState * state)
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   916
{
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   917
    if (state->flags & SDL_INIT_VIDEO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   918
        SDL_VideoQuit();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   919
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   920
    if (state->flags & SDL_INIT_AUDIO) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   921
        SDL_AudioQuit();
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   922
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   923
    if (state->windows) {
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   924
        SDL_free(state->windows);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   925
    }
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   926
    SDL_free(state);
051df511279c Added a test program framework for easy initialization.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   927
}