src/test/SDL_test_common.c
author Andreas Schiffler <aschiffler@ferzkopp.net>
Sun, 09 Dec 2012 17:56:19 -0800
changeset 6727 1b5280cd5885
child 6783 001f59dc43be
permissions -rw-r--r--
Added existing common.c/.h functions to test lib; minor assert refactoring
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6727
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     1
/*
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     2
  Simple DirectMedia Layer
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     4
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     7
  arising from the use of this software.
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     8
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    11
  freely, subject to the following restrictions:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    12
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    16
     appreciated but is not required.
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    18
     misrepresented as being the original software.
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    20
*/
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    21
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    22
/* Ported from original test\common.c file. */
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    23
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    24
#include "SDL_config.h"
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    25
#include "SDL_test.h"
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    26
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    27
#include <stdio.h>
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    28
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    29
#define VIDEO_USAGE \
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    30
"[--video driver] [--renderer driver] [--info all|video|modes|render|event] [--log all|error|system|audio|video|render|input] [--display N] [--fullscreen | --windows N] [--title title] [--icon icon.bmp] [--center | --position X,Y] [--geometry WxH] [--depth N] [--refresh R] [--vsync] [--noframe] [--resize] [--minimize] [--maximize] [--grab]"
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    31
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    32
#define AUDIO_USAGE \
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    33
"[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]"
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    34
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    35
SDLTest_CommonState *
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    36
SDLTest_CommonCreateState(char **argv, Uint32 flags)
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    37
{
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    38
    SDLTest_CommonState *state = (SDLTest_CommonState *)SDL_calloc(1, sizeof(*state));
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    39
    if (!state) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    40
        SDL_OutOfMemory();
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    41
        return NULL;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    42
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    43
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    44
    /* Initialize some defaults */
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    45
    state->argv = argv;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    46
    state->flags = flags;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    47
#ifdef __NDS__
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    48
    state->window_title = "";
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    49
#else
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    50
    state->window_title = argv[0];
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    51
#endif
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    52
    state->window_flags = 0;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    53
    state->window_x = SDL_WINDOWPOS_UNDEFINED;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    54
    state->window_y = SDL_WINDOWPOS_UNDEFINED;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    55
    state->window_w = DEFAULT_WINDOW_WIDTH;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    56
    state->window_h = DEFAULT_WINDOW_HEIGHT;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    57
    state->num_windows = 1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    58
    state->audiospec.freq = 22050;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    59
    state->audiospec.format = AUDIO_S16;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    60
    state->audiospec.channels = 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    61
    state->audiospec.samples = 2048;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    62
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    63
    /* Set some very sane GL defaults */
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    64
    state->gl_red_size = 3;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    65
    state->gl_green_size = 3;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    66
    state->gl_blue_size = 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    67
    state->gl_alpha_size = 0;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    68
    state->gl_buffer_size = 0;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    69
    state->gl_depth_size = 16;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    70
    state->gl_stencil_size = 0;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    71
    state->gl_double_buffer = 1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    72
    state->gl_accum_red_size = 0;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    73
    state->gl_accum_green_size = 0;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    74
    state->gl_accum_blue_size = 0;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    75
    state->gl_accum_alpha_size = 0;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    76
    state->gl_stereo = 0;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    77
    state->gl_multisamplebuffers = 0;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    78
    state->gl_multisamplesamples = 0;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    79
    state->gl_retained_backing = 1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    80
    state->gl_accelerated = -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    81
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    82
    return state;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    83
}
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    84
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    85
int
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    86
SDLTest_CommonArg(SDLTest_CommonState * state, int index)
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    87
{
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    88
    char **argv = state->argv;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    89
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    90
#ifdef __NDS__
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    91
    return 0;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    92
#endif
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    93
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    94
    if (SDL_strcasecmp(argv[index], "--video") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    95
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    96
        if (!argv[index]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    97
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    98
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
    99
        state->videodriver = argv[index];
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   100
        return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   101
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   102
    if (SDL_strcasecmp(argv[index], "--renderer") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   103
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   104
        if (!argv[index]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   105
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   106
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   107
        state->renderdriver = argv[index];
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   108
        return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   109
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   110
    if (SDL_strcasecmp(argv[index], "--info") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   111
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   112
        if (!argv[index]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   113
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   114
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   115
        if (SDL_strcasecmp(argv[index], "all") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   116
            state->verbose |=
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   117
                (VERBOSE_VIDEO | VERBOSE_MODES | VERBOSE_RENDER |
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   118
                 VERBOSE_EVENT);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   119
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   120
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   121
        if (SDL_strcasecmp(argv[index], "video") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   122
            state->verbose |= VERBOSE_VIDEO;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   123
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   124
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   125
        if (SDL_strcasecmp(argv[index], "modes") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   126
            state->verbose |= VERBOSE_MODES;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   127
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   128
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   129
        if (SDL_strcasecmp(argv[index], "render") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   130
            state->verbose |= VERBOSE_RENDER;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   131
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   132
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   133
        if (SDL_strcasecmp(argv[index], "event") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   134
            state->verbose |= VERBOSE_EVENT;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   135
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   136
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   137
        return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   138
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   139
    if (SDL_strcasecmp(argv[index], "--log") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   140
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   141
        if (!argv[index]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   142
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   143
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   144
        if (SDL_strcasecmp(argv[index], "all") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   145
            SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   146
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   147
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   148
        if (SDL_strcasecmp(argv[index], "error") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   149
            SDL_LogSetPriority(SDL_LOG_CATEGORY_ERROR, SDL_LOG_PRIORITY_VERBOSE);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   150
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   151
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   152
        if (SDL_strcasecmp(argv[index], "system") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   153
            SDL_LogSetPriority(SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_PRIORITY_VERBOSE);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   154
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   155
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   156
        if (SDL_strcasecmp(argv[index], "audio") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   157
            SDL_LogSetPriority(SDL_LOG_CATEGORY_AUDIO, SDL_LOG_PRIORITY_VERBOSE);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   158
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   159
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   160
        if (SDL_strcasecmp(argv[index], "video") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   161
            SDL_LogSetPriority(SDL_LOG_CATEGORY_VIDEO, SDL_LOG_PRIORITY_VERBOSE);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   162
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   163
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   164
        if (SDL_strcasecmp(argv[index], "render") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   165
            SDL_LogSetPriority(SDL_LOG_CATEGORY_RENDER, SDL_LOG_PRIORITY_VERBOSE);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   166
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   167
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   168
        if (SDL_strcasecmp(argv[index], "input") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   169
            SDL_LogSetPriority(SDL_LOG_CATEGORY_INPUT, SDL_LOG_PRIORITY_VERBOSE);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   170
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   171
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   172
        return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   173
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   174
    if (SDL_strcasecmp(argv[index], "--display") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   175
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   176
        if (!argv[index]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   177
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   178
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   179
        state->display = SDL_atoi(argv[index]);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   180
        if (SDL_WINDOWPOS_ISUNDEFINED(state->window_x)) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   181
            state->window_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(state->display);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   182
            state->window_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(state->display);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   183
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   184
        if (SDL_WINDOWPOS_ISCENTERED(state->window_x)) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   185
            state->window_x = SDL_WINDOWPOS_CENTERED_DISPLAY(state->display);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   186
            state->window_y = SDL_WINDOWPOS_CENTERED_DISPLAY(state->display);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   187
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   188
        return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   189
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   190
    if (SDL_strcasecmp(argv[index], "--fullscreen") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   191
        state->window_flags |= SDL_WINDOW_FULLSCREEN;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   192
        state->num_windows = 1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   193
        return 1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   194
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   195
    if (SDL_strcasecmp(argv[index], "--windows") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   196
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   197
        if (!argv[index] || !SDL_isdigit(*argv[index])) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   198
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   199
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   200
        if (!(state->window_flags & SDL_WINDOW_FULLSCREEN)) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   201
            state->num_windows = SDL_atoi(argv[index]);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   202
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   203
        return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   204
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   205
    if (SDL_strcasecmp(argv[index], "--title") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   206
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   207
        if (!argv[index]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   208
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   209
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   210
        state->window_title = argv[index];
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   211
        return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   212
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   213
    if (SDL_strcasecmp(argv[index], "--icon") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   214
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   215
        if (!argv[index]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   216
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   217
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   218
        state->window_icon = argv[index];
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   219
        return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   220
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   221
    if (SDL_strcasecmp(argv[index], "--center") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   222
        state->window_x = SDL_WINDOWPOS_CENTERED;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   223
        state->window_y = SDL_WINDOWPOS_CENTERED;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   224
        return 1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   225
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   226
    if (SDL_strcasecmp(argv[index], "--position") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   227
        char *x, *y;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   228
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   229
        if (!argv[index]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   230
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   231
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   232
        x = argv[index];
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   233
        y = argv[index];
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   234
        while (*y && *y != ',') {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   235
            ++y;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   236
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   237
        if (!*y) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   238
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   239
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   240
        *y++ = '\0';
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   241
        state->window_x = SDL_atoi(x);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   242
        state->window_y = SDL_atoi(y);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   243
        return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   244
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   245
    if (SDL_strcasecmp(argv[index], "--geometry") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   246
        char *w, *h;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   247
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   248
        if (!argv[index]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   249
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   250
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   251
        w = argv[index];
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   252
        h = argv[index];
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   253
        while (*h && *h != 'x') {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   254
            ++h;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   255
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   256
        if (!*h) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   257
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   258
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   259
        *h++ = '\0';
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   260
        state->window_w = SDL_atoi(w);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   261
        state->window_h = SDL_atoi(h);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   262
        return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   263
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   264
    if (SDL_strcasecmp(argv[index], "--depth") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   265
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   266
        if (!argv[index]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   267
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   268
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   269
        state->depth = SDL_atoi(argv[index]);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   270
        return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   271
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   272
    if (SDL_strcasecmp(argv[index], "--refresh") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   273
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   274
        if (!argv[index]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   275
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   276
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   277
        state->refresh_rate = SDL_atoi(argv[index]);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   278
        return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   279
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   280
    if (SDL_strcasecmp(argv[index], "--vsync") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   281
        state->render_flags |= SDL_RENDERER_PRESENTVSYNC;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   282
        return 1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   283
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   284
    if (SDL_strcasecmp(argv[index], "--noframe") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   285
        state->window_flags |= SDL_WINDOW_BORDERLESS;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   286
        return 1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   287
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   288
    if (SDL_strcasecmp(argv[index], "--resize") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   289
        state->window_flags |= SDL_WINDOW_RESIZABLE;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   290
        return 1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   291
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   292
    if (SDL_strcasecmp(argv[index], "--minimize") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   293
        state->window_flags |= SDL_WINDOW_MINIMIZED;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   294
        return 1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   295
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   296
    if (SDL_strcasecmp(argv[index], "--maximize") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   297
        state->window_flags |= SDL_WINDOW_MAXIMIZED;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   298
        return 1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   299
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   300
    if (SDL_strcasecmp(argv[index], "--grab") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   301
        state->window_flags |= SDL_WINDOW_INPUT_GRABBED;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   302
        return 1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   303
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   304
    if (SDL_strcasecmp(argv[index], "--rate") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   305
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   306
        if (!argv[index]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   307
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   308
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   309
        state->audiospec.freq = SDL_atoi(argv[index]);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   310
        return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   311
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   312
    if (SDL_strcasecmp(argv[index], "--format") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   313
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   314
        if (!argv[index]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   315
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   316
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   317
        if (SDL_strcasecmp(argv[index], "U8") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   318
            state->audiospec.format = AUDIO_U8;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   319
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   320
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   321
        if (SDL_strcasecmp(argv[index], "S8") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   322
            state->audiospec.format = AUDIO_S8;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   323
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   324
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   325
        if (SDL_strcasecmp(argv[index], "U16") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   326
            state->audiospec.format = AUDIO_U16;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   327
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   328
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   329
        if (SDL_strcasecmp(argv[index], "U16LE") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   330
            state->audiospec.format = AUDIO_U16LSB;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   331
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   332
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   333
        if (SDL_strcasecmp(argv[index], "U16BE") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   334
            state->audiospec.format = AUDIO_U16MSB;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   335
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   336
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   337
        if (SDL_strcasecmp(argv[index], "S16") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   338
            state->audiospec.format = AUDIO_S16;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   339
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   340
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   341
        if (SDL_strcasecmp(argv[index], "S16LE") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   342
            state->audiospec.format = AUDIO_S16LSB;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   343
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   344
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   345
        if (SDL_strcasecmp(argv[index], "S16BE") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   346
            state->audiospec.format = AUDIO_S16MSB;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   347
            return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   348
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   349
        return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   350
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   351
    if (SDL_strcasecmp(argv[index], "--channels") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   352
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   353
        if (!argv[index]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   354
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   355
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   356
        state->audiospec.channels = (Uint8) SDL_atoi(argv[index]);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   357
        return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   358
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   359
    if (SDL_strcasecmp(argv[index], "--samples") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   360
        ++index;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   361
        if (!argv[index]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   362
            return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   363
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   364
        state->audiospec.samples = (Uint16) SDL_atoi(argv[index]);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   365
        return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   366
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   367
    if ((SDL_strcasecmp(argv[index], "-h") == 0)
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   368
        || (SDL_strcasecmp(argv[index], "--help") == 0)) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   369
        /* Print the usage message */
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   370
        return -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   371
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   372
    if (SDL_strcmp(argv[index], "-NSDocumentRevisionsDebugMode") == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   373
	/* Debug flag sent by Xcode */
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   374
        return 2;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   375
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   376
    return 0;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   377
}
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   378
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   379
const char *
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   380
SDLTest_CommonUsage(SDLTest_CommonState * state)
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   381
{
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   382
    switch (state->flags & (SDL_INIT_VIDEO | SDL_INIT_AUDIO)) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   383
    case SDL_INIT_VIDEO:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   384
        return VIDEO_USAGE;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   385
    case SDL_INIT_AUDIO:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   386
        return AUDIO_USAGE;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   387
    case (SDL_INIT_VIDEO | SDL_INIT_AUDIO):
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   388
        return VIDEO_USAGE " " AUDIO_USAGE;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   389
    default:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   390
        return "";
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   391
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   392
}
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   393
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   394
static void
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   395
SDLTest_PrintRendererFlag(Uint32 flag)
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   396
{
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   397
    switch (flag) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   398
    case SDL_RENDERER_PRESENTVSYNC:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   399
        fprintf(stderr, "PresentVSync");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   400
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   401
    case SDL_RENDERER_ACCELERATED:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   402
        fprintf(stderr, "Accelerated");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   403
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   404
    default:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   405
        fprintf(stderr, "0x%8.8x", flag);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   406
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   407
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   408
}
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   409
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   410
static void
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   411
SDLTest_PrintPixelFormat(Uint32 format)
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   412
{
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   413
    switch (format) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   414
    case SDL_PIXELFORMAT_UNKNOWN:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   415
        fprintf(stderr, "Unknwon");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   416
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   417
    case SDL_PIXELFORMAT_INDEX1LSB:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   418
        fprintf(stderr, "Index1LSB");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   419
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   420
    case SDL_PIXELFORMAT_INDEX1MSB:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   421
        fprintf(stderr, "Index1MSB");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   422
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   423
    case SDL_PIXELFORMAT_INDEX4LSB:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   424
        fprintf(stderr, "Index4LSB");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   425
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   426
    case SDL_PIXELFORMAT_INDEX4MSB:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   427
        fprintf(stderr, "Index4MSB");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   428
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   429
    case SDL_PIXELFORMAT_INDEX8:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   430
        fprintf(stderr, "Index8");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   431
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   432
    case SDL_PIXELFORMAT_RGB332:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   433
        fprintf(stderr, "RGB332");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   434
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   435
    case SDL_PIXELFORMAT_RGB444:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   436
        fprintf(stderr, "RGB444");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   437
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   438
    case SDL_PIXELFORMAT_RGB555:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   439
        fprintf(stderr, "RGB555");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   440
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   441
    case SDL_PIXELFORMAT_BGR555:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   442
        fprintf(stderr, "BGR555");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   443
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   444
    case SDL_PIXELFORMAT_ARGB4444:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   445
        fprintf(stderr, "ARGB4444");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   446
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   447
    case SDL_PIXELFORMAT_ABGR4444:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   448
        fprintf(stderr, "ABGR4444");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   449
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   450
    case SDL_PIXELFORMAT_ARGB1555:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   451
        fprintf(stderr, "ARGB1555");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   452
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   453
    case SDL_PIXELFORMAT_ABGR1555:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   454
        fprintf(stderr, "ABGR1555");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   455
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   456
    case SDL_PIXELFORMAT_RGB565:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   457
        fprintf(stderr, "RGB565");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   458
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   459
    case SDL_PIXELFORMAT_BGR565:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   460
        fprintf(stderr, "BGR565");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   461
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   462
    case SDL_PIXELFORMAT_RGB24:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   463
        fprintf(stderr, "RGB24");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   464
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   465
    case SDL_PIXELFORMAT_BGR24:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   466
        fprintf(stderr, "BGR24");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   467
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   468
    case SDL_PIXELFORMAT_RGB888:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   469
        fprintf(stderr, "RGB888");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   470
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   471
    case SDL_PIXELFORMAT_BGR888:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   472
        fprintf(stderr, "BGR888");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   473
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   474
    case SDL_PIXELFORMAT_ARGB8888:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   475
        fprintf(stderr, "ARGB8888");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   476
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   477
    case SDL_PIXELFORMAT_RGBA8888:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   478
        fprintf(stderr, "RGBA8888");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   479
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   480
    case SDL_PIXELFORMAT_ABGR8888:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   481
        fprintf(stderr, "ABGR8888");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   482
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   483
    case SDL_PIXELFORMAT_BGRA8888:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   484
        fprintf(stderr, "BGRA8888");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   485
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   486
    case SDL_PIXELFORMAT_ARGB2101010:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   487
        fprintf(stderr, "ARGB2101010");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   488
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   489
    case SDL_PIXELFORMAT_YV12:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   490
        fprintf(stderr, "YV12");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   491
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   492
    case SDL_PIXELFORMAT_IYUV:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   493
        fprintf(stderr, "IYUV");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   494
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   495
    case SDL_PIXELFORMAT_YUY2:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   496
        fprintf(stderr, "YUY2");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   497
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   498
    case SDL_PIXELFORMAT_UYVY:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   499
        fprintf(stderr, "UYVY");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   500
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   501
    case SDL_PIXELFORMAT_YVYU:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   502
        fprintf(stderr, "YVYU");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   503
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   504
    default:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   505
        fprintf(stderr, "0x%8.8x", format);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   506
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   507
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   508
}
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   509
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   510
static void
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   511
SDLTest_PrintRenderer(SDL_RendererInfo * info)
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   512
{
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   513
    int i, count;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   514
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   515
    fprintf(stderr, "  Renderer %s:\n", info->name);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   516
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   517
    fprintf(stderr, "    Flags: 0x%8.8X", info->flags);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   518
    fprintf(stderr, " (");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   519
    count = 0;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   520
    for (i = 0; i < sizeof(info->flags) * 8; ++i) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   521
        Uint32 flag = (1 << i);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   522
        if (info->flags & flag) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   523
            if (count > 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   524
                fprintf(stderr, " | ");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   525
            }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   526
            SDLTest_PrintRendererFlag(flag);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   527
            ++count;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   528
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   529
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   530
    fprintf(stderr, ")\n");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   531
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   532
    fprintf(stderr, "    Texture formats (%d): ", info->num_texture_formats);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   533
    for (i = 0; i < (int) info->num_texture_formats; ++i) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   534
        if (i > 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   535
            fprintf(stderr, ", ");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   536
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   537
        SDLTest_PrintPixelFormat(info->texture_formats[i]);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   538
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   539
    fprintf(stderr, "\n");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   540
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   541
    if (info->max_texture_width || info->max_texture_height) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   542
        fprintf(stderr, "    Max Texture Size: %dx%d\n",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   543
                info->max_texture_width, info->max_texture_height);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   544
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   545
}
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   546
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   547
static SDL_Surface *
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   548
SDLTest_LoadIcon(const char *file)
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   549
{
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   550
    SDL_Surface *icon;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   551
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   552
    /* Load the icon surface */
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   553
    icon = SDL_LoadBMP(file);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   554
    if (icon == NULL) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   555
        fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   556
        return (NULL);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   557
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   558
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   559
    if (icon->format->palette) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   560
        /* Set the colorkey */
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   561
        SDL_SetColorKey(icon, 1, *((Uint8 *) icon->pixels));
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   562
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   563
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   564
    return (icon);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   565
}
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   566
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   567
SDL_bool
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   568
SDLTest_CommonInit(SDLTest_CommonState * state)
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   569
{
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   570
    int i, j, m, n, w, h;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   571
    SDL_DisplayMode fullscreen_mode;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   572
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   573
    if (state->flags & SDL_INIT_VIDEO) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   574
        if (state->verbose & VERBOSE_VIDEO) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   575
            n = SDL_GetNumVideoDrivers();
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   576
            if (n == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   577
                fprintf(stderr, "No built-in video drivers\n");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   578
            } else {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   579
                fprintf(stderr, "Built-in video drivers:");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   580
                for (i = 0; i < n; ++i) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   581
                    if (i > 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   582
                        fprintf(stderr, ",");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   583
                    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   584
                    fprintf(stderr, " %s", SDL_GetVideoDriver(i));
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   585
                }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   586
                fprintf(stderr, "\n");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   587
            }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   588
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   589
        if (SDL_VideoInit(state->videodriver) < 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   590
            fprintf(stderr, "Couldn't initialize video driver: %s\n",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   591
                    SDL_GetError());
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   592
            return SDL_FALSE;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   593
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   594
        if (state->verbose & VERBOSE_VIDEO) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   595
            fprintf(stderr, "Video driver: %s\n",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   596
                    SDL_GetCurrentVideoDriver());
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   597
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   598
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   599
        /* Upload GL settings */
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   600
        SDL_GL_SetAttribute(SDL_GL_RED_SIZE, state->gl_red_size);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   601
        SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, state->gl_green_size);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   602
        SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, state->gl_blue_size);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   603
        SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, state->gl_alpha_size);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   604
        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, state->gl_double_buffer);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   605
        SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, state->gl_buffer_size);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   606
        SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, state->gl_depth_size);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   607
        SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, state->gl_stencil_size);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   608
        SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, state->gl_accum_red_size);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   609
        SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, state->gl_accum_green_size);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   610
        SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, state->gl_accum_blue_size);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   611
        SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, state->gl_accum_alpha_size);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   612
        SDL_GL_SetAttribute(SDL_GL_STEREO, state->gl_stereo);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   613
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, state->gl_multisamplebuffers);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   614
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, state->gl_multisamplesamples);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   615
        if (state->gl_accelerated >= 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   616
            SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   617
                                state->gl_accelerated);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   618
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   619
        SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, state->gl_retained_backing);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   620
        if (state->gl_major_version) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   621
            SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, state->gl_major_version);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   622
            SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, state->gl_minor_version);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   623
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   624
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   625
        if (state->verbose & VERBOSE_MODES) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   626
            SDL_Rect bounds;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   627
            SDL_DisplayMode mode;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   628
            int bpp;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   629
            Uint32 Rmask, Gmask, Bmask, Amask;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   630
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   631
            n = SDL_GetNumVideoDisplays();
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   632
            fprintf(stderr, "Number of displays: %d\n", n);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   633
            for (i = 0; i < n; ++i) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   634
                fprintf(stderr, "Display %d:\n", i);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   635
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   636
                SDL_zero(bounds);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   637
                SDL_GetDisplayBounds(i, &bounds);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   638
                fprintf(stderr, "Bounds: %dx%d at %d,%d\n", bounds.w, bounds.h, bounds.x, bounds.y);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   639
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   640
                SDL_GetDesktopDisplayMode(i, &mode);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   641
                SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   642
                                           &Bmask, &Amask);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   643
                fprintf(stderr,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   644
                        "  Current mode: %dx%d@%dHz, %d bits-per-pixel (%s)\n",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   645
                        mode.w, mode.h, mode.refresh_rate, bpp,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   646
                        SDL_GetPixelFormatName(mode.format));
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   647
                if (Rmask || Gmask || Bmask) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   648
                    fprintf(stderr, "      Red Mask   = 0x%.8x\n", Rmask);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   649
                    fprintf(stderr, "      Green Mask = 0x%.8x\n", Gmask);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   650
                    fprintf(stderr, "      Blue Mask  = 0x%.8x\n", Bmask);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   651
                    if (Amask)
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   652
                        fprintf(stderr, "      Alpha Mask = 0x%.8x\n", Amask);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   653
                }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   654
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   655
                /* Print available fullscreen video modes */
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   656
                m = SDL_GetNumDisplayModes(i);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   657
                if (m == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   658
                    fprintf(stderr, "No available fullscreen video modes\n");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   659
                } else {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   660
                    fprintf(stderr, "  Fullscreen video modes:\n");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   661
                    for (j = 0; j < m; ++j) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   662
                        SDL_GetDisplayMode(i, j, &mode);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   663
                        SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   664
                                                   &Gmask, &Bmask, &Amask);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   665
                        fprintf(stderr,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   666
                                "    Mode %d: %dx%d@%dHz, %d bits-per-pixel (%s)\n",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   667
                                j, mode.w, mode.h, mode.refresh_rate, bpp,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   668
                                SDL_GetPixelFormatName(mode.format));
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   669
                        if (Rmask || Gmask || Bmask) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   670
                            fprintf(stderr, "        Red Mask   = 0x%.8x\n",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   671
                                    Rmask);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   672
                            fprintf(stderr, "        Green Mask = 0x%.8x\n",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   673
                                    Gmask);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   674
                            fprintf(stderr, "        Blue Mask  = 0x%.8x\n",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   675
                                    Bmask);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   676
                            if (Amask)
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   677
                                fprintf(stderr,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   678
                                        "        Alpha Mask = 0x%.8x\n",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   679
                                        Amask);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   680
                        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   681
                    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   682
                }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   683
            }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   684
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   685
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   686
        if (state->verbose & VERBOSE_RENDER) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   687
            SDL_RendererInfo info;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   688
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   689
            n = SDL_GetNumRenderDrivers();
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   690
            if (n == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   691
                fprintf(stderr, "No built-in render drivers\n");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   692
            } else {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   693
                fprintf(stderr, "Built-in render drivers:\n");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   694
                for (i = 0; i < n; ++i) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   695
                    SDL_GetRenderDriverInfo(i, &info);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   696
                    SDLTest_PrintRenderer(&info);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   697
                }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   698
            }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   699
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   700
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   701
        SDL_zero(fullscreen_mode);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   702
        switch (state->depth) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   703
        case 8:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   704
            fullscreen_mode.format = SDL_PIXELFORMAT_INDEX8;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   705
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   706
        case 15:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   707
            fullscreen_mode.format = SDL_PIXELFORMAT_RGB555;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   708
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   709
        case 16:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   710
            fullscreen_mode.format = SDL_PIXELFORMAT_RGB565;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   711
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   712
        case 24:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   713
            fullscreen_mode.format = SDL_PIXELFORMAT_RGB24;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   714
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   715
        default:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   716
            fullscreen_mode.format = SDL_PIXELFORMAT_RGB888;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   717
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   718
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   719
        fullscreen_mode.refresh_rate = state->refresh_rate;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   720
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   721
        state->windows =
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   722
            (SDL_Window **) SDL_malloc(state->num_windows *
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   723
                                        sizeof(*state->windows));
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   724
        state->renderers =
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   725
            (SDL_Renderer **) SDL_malloc(state->num_windows *
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   726
                                        sizeof(*state->renderers));
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   727
        if (!state->windows || !state->renderers) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   728
            fprintf(stderr, "Out of memory!\n");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   729
            return SDL_FALSE;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   730
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   731
        for (i = 0; i < state->num_windows; ++i) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   732
            char title[1024];
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   733
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   734
            if (state->num_windows > 1) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   735
                SDL_snprintf(title, SDL_arraysize(title), "%s %d",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   736
                             state->window_title, i + 1);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   737
            } else {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   738
                SDL_strlcpy(title, state->window_title, SDL_arraysize(title));
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   739
            }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   740
            state->windows[i] =
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   741
                SDL_CreateWindow(title, state->window_x, state->window_y,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   742
                                 state->window_w, state->window_h,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   743
                                 state->window_flags);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   744
            if (!state->windows[i]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   745
                fprintf(stderr, "Couldn't create window: %s\n",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   746
                        SDL_GetError());
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   747
                return SDL_FALSE;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   748
            }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   749
            SDL_GetWindowSize(state->windows[i], &w, &h);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   750
            if (!(state->window_flags & SDL_WINDOW_RESIZABLE) &&
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   751
                (w != state->window_w || h != state->window_h)) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   752
                printf("Window requested size %dx%d, got %dx%d\n", state->window_w, state->window_h, w, h);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   753
                state->window_w = w;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   754
                state->window_h = h;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   755
            }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   756
            if (SDL_SetWindowDisplayMode(state->windows[i], &fullscreen_mode) < 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   757
                fprintf(stderr, "Can't set up fullscreen display mode: %s\n",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   758
                        SDL_GetError());
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   759
                return SDL_FALSE;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   760
            }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   761
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   762
            if (state->window_icon) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   763
                SDL_Surface *icon = SDLTest_LoadIcon(state->window_icon);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   764
                if (icon) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   765
                    SDL_SetWindowIcon(state->windows[i], icon);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   766
                    SDL_FreeSurface(icon);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   767
                }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   768
            }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   769
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   770
            SDL_ShowWindow(state->windows[i]);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   771
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   772
            state->renderers[i] = NULL;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   773
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   774
            if (!state->skip_renderer
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   775
                && (state->renderdriver
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   776
                    || !(state->window_flags & SDL_WINDOW_OPENGL))) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   777
                m = -1;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   778
                if (state->renderdriver) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   779
                    SDL_RendererInfo info;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   780
                    n = SDL_GetNumRenderDrivers();
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   781
                    for (j = 0; j < n; ++j) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   782
                        SDL_GetRenderDriverInfo(j, &info);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   783
                        if (SDL_strcasecmp(info.name, state->renderdriver) ==
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   784
                            0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   785
                            m = j;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   786
                            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   787
                        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   788
                    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   789
                    if (m == n) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   790
                        fprintf(stderr,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   791
                                "Couldn't find render driver named %s",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   792
                                state->renderdriver);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   793
                        return SDL_FALSE;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   794
                    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   795
                }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   796
                state->renderers[i] = SDL_CreateRenderer(state->windows[i],
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   797
                                            m, state->render_flags);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   798
                if (!state->renderers[i]) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   799
                    fprintf(stderr, "Couldn't create renderer: %s\n",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   800
                            SDL_GetError());
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   801
                    return SDL_FALSE;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   802
                }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   803
                if (state->verbose & VERBOSE_RENDER) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   804
                    SDL_RendererInfo info;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   805
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   806
                    fprintf(stderr, "Current renderer:\n");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   807
                    SDL_GetRendererInfo(state->renderers[i], &info);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   808
                    SDLTest_PrintRenderer(&info);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   809
                }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   810
            }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   811
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   812
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   813
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   814
    if (state->flags & SDL_INIT_AUDIO) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   815
        if (state->verbose & VERBOSE_AUDIO) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   816
            n = SDL_GetNumAudioDrivers();
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   817
            if (n == 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   818
                fprintf(stderr, "No built-in audio drivers\n");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   819
            } else {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   820
                fprintf(stderr, "Built-in audio drivers:");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   821
                for (i = 0; i < n; ++i) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   822
                    if (i > 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   823
                        fprintf(stderr, ",");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   824
                    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   825
                    fprintf(stderr, " %s", SDL_GetAudioDriver(i));
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   826
                }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   827
                fprintf(stderr, "\n");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   828
            }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   829
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   830
        if (SDL_AudioInit(state->audiodriver) < 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   831
            fprintf(stderr, "Couldn't initialize audio driver: %s\n",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   832
                    SDL_GetError());
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   833
            return SDL_FALSE;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   834
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   835
        if (state->verbose & VERBOSE_VIDEO) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   836
            fprintf(stderr, "Audio driver: %s\n",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   837
                    SDL_GetCurrentAudioDriver());
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   838
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   839
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   840
        if (SDL_OpenAudio(&state->audiospec, NULL) < 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   841
            fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   842
            return SDL_FALSE;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   843
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   844
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   845
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   846
    return SDL_TRUE;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   847
}
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   848
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   849
static void
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   850
SDLTest_PrintEvent(SDL_Event * event)
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   851
{
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   852
    if (event->type == SDL_MOUSEMOTION) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   853
        /* Mouse motion is really spammy */
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   854
        //return;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   855
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   856
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   857
    fprintf(stderr, "SDL EVENT: ");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   858
    switch (event->type) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   859
    case SDL_WINDOWEVENT:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   860
        switch (event->window.event) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   861
        case SDL_WINDOWEVENT_SHOWN:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   862
            fprintf(stderr, "Window %d shown", event->window.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   863
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   864
        case SDL_WINDOWEVENT_HIDDEN:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   865
            fprintf(stderr, "Window %d hidden", event->window.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   866
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   867
        case SDL_WINDOWEVENT_EXPOSED:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   868
            fprintf(stderr, "Window %d exposed", event->window.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   869
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   870
        case SDL_WINDOWEVENT_MOVED:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   871
            fprintf(stderr, "Window %d moved to %d,%d",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   872
                    event->window.windowID, event->window.data1,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   873
                    event->window.data2);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   874
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   875
        case SDL_WINDOWEVENT_RESIZED:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   876
            fprintf(stderr, "Window %d resized to %dx%d",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   877
                    event->window.windowID, event->window.data1,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   878
                    event->window.data2);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   879
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   880
        case SDL_WINDOWEVENT_SIZE_CHANGED:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   881
            fprintf(stderr, "Window %d changed size to %dx%d",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   882
                    event->window.windowID, event->window.data1,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   883
                    event->window.data2);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   884
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   885
        case SDL_WINDOWEVENT_MINIMIZED:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   886
            fprintf(stderr, "Window %d minimized", event->window.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   887
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   888
        case SDL_WINDOWEVENT_MAXIMIZED:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   889
            fprintf(stderr, "Window %d maximized", event->window.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   890
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   891
        case SDL_WINDOWEVENT_RESTORED:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   892
            fprintf(stderr, "Window %d restored", event->window.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   893
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   894
        case SDL_WINDOWEVENT_ENTER:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   895
            fprintf(stderr, "Mouse entered window %d",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   896
                    event->window.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   897
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   898
        case SDL_WINDOWEVENT_LEAVE:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   899
            fprintf(stderr, "Mouse left window %d", event->window.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   900
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   901
        case SDL_WINDOWEVENT_FOCUS_GAINED:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   902
            fprintf(stderr, "Window %d gained keyboard focus",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   903
                    event->window.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   904
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   905
        case SDL_WINDOWEVENT_FOCUS_LOST:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   906
            fprintf(stderr, "Window %d lost keyboard focus",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   907
                    event->window.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   908
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   909
        case SDL_WINDOWEVENT_CLOSE:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   910
            fprintf(stderr, "Window %d closed", event->window.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   911
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   912
        default:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   913
            fprintf(stderr, "Window %d got unknown event %d",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   914
                    event->window.windowID, event->window.event);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   915
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   916
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   917
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   918
    case SDL_KEYDOWN:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   919
        fprintf(stderr,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   920
                "Keyboard: key pressed  in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   921
                event->key.windowID,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   922
                event->key.keysym.scancode,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   923
                SDL_GetScancodeName(event->key.keysym.scancode),
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   924
                event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym));
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   925
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   926
    case SDL_KEYUP:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   927
        fprintf(stderr,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   928
                "Keyboard: key released in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   929
                event->key.windowID,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   930
                event->key.keysym.scancode,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   931
                SDL_GetScancodeName(event->key.keysym.scancode),
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   932
                event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym));
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   933
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   934
    case SDL_TEXTINPUT:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   935
        fprintf(stderr, "Keyboard: text input \"%s\" in window %d",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   936
                event->text.text, event->text.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   937
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   938
    case SDL_MOUSEMOTION:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   939
        fprintf(stderr, "Mouse: moved to %d,%d (%d,%d) in window %d",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   940
                event->motion.x, event->motion.y,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   941
                event->motion.xrel, event->motion.yrel,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   942
                event->motion.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   943
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   944
    case SDL_MOUSEBUTTONDOWN:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   945
        fprintf(stderr, "Mouse: button %d pressed at %d,%d in window %d",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   946
                event->button.button, event->button.x, event->button.y,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   947
                event->button.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   948
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   949
    case SDL_MOUSEBUTTONUP:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   950
        fprintf(stderr, "Mouse: button %d released at %d,%d in window %d",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   951
                event->button.button, event->button.x, event->button.y,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   952
                event->button.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   953
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   954
    case SDL_MOUSEWHEEL:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   955
        fprintf(stderr,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   956
                "Mouse: wheel scrolled %d in x and %d in y in window %d",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   957
                event->wheel.x, event->wheel.y, event->wheel.windowID);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   958
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   959
    case SDL_JOYBALLMOTION:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   960
        fprintf(stderr, "Joystick %d: ball %d moved by %d,%d",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   961
                event->jball.which, event->jball.ball, event->jball.xrel,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   962
                event->jball.yrel);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   963
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   964
    case SDL_JOYHATMOTION:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   965
        fprintf(stderr, "Joystick %d: hat %d moved to ", event->jhat.which,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   966
                event->jhat.hat);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   967
        switch (event->jhat.value) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   968
        case SDL_HAT_CENTERED:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   969
            fprintf(stderr, "CENTER");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   970
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   971
        case SDL_HAT_UP:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   972
            fprintf(stderr, "UP");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   973
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   974
        case SDL_HAT_RIGHTUP:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   975
            fprintf(stderr, "RIGHTUP");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   976
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   977
        case SDL_HAT_RIGHT:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   978
            fprintf(stderr, "RIGHT");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   979
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   980
        case SDL_HAT_RIGHTDOWN:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   981
            fprintf(stderr, "RIGHTDOWN");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   982
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   983
        case SDL_HAT_DOWN:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   984
            fprintf(stderr, "DOWN");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   985
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   986
        case SDL_HAT_LEFTDOWN:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   987
            fprintf(stderr, "LEFTDOWN");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   988
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   989
        case SDL_HAT_LEFT:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   990
            fprintf(stderr, "LEFT");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   991
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   992
        case SDL_HAT_LEFTUP:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   993
            fprintf(stderr, "LEFTUP");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   994
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   995
        default:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   996
            fprintf(stderr, "UNKNOWN");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   997
            break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   998
        }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
   999
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1000
    case SDL_JOYBUTTONDOWN:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1001
        fprintf(stderr, "Joystick %d: button %d pressed",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1002
                event->jbutton.which, event->jbutton.button);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1003
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1004
    case SDL_JOYBUTTONUP:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1005
        fprintf(stderr, "Joystick %d: button %d released",
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1006
                event->jbutton.which, event->jbutton.button);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1007
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1008
    case SDL_CLIPBOARDUPDATE:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1009
        fprintf(stderr, "Clipboard updated");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1010
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1011
    case SDL_QUIT:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1012
        fprintf(stderr, "Quit requested");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1013
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1014
    case SDL_USEREVENT:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1015
        fprintf(stderr, "User event %d", event->user.code);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1016
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1017
    default:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1018
        fprintf(stderr, "Unknown event %d", event->type);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1019
        break;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1020
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1021
    fprintf(stderr, "\n");
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1022
}
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1023
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1024
static void
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1025
SDLTest_ScreenShot(SDL_Renderer *renderer)
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1026
{
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1027
    SDL_Rect viewport;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1028
    SDL_Surface *surface;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1029
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1030
    if (!renderer) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1031
        return;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1032
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1033
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1034
    SDL_RenderGetViewport(renderer, &viewport);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1035
    surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1036
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1037
                    0x00FF0000, 0x0000FF00, 0x000000FF,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1038
#else
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1039
                    0x000000FF, 0x0000FF00, 0x00FF0000,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1040
#endif
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1041
                    0x00000000);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1042
    if (!surface) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1043
        fprintf(stderr, "Couldn't create surface: %s\n", SDL_GetError());
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1044
        return;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1045
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1046
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1047
    if (SDL_RenderReadPixels(renderer, NULL, surface->format->format,
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1048
                             surface->pixels, surface->pitch) < 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1049
        fprintf(stderr, "Couldn't read screen: %s\n", SDL_GetError());
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1050
        return;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1051
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1052
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1053
    if (SDL_SaveBMP(surface, "screenshot.bmp") < 0) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1054
        fprintf(stderr, "Couldn't save screenshot.bmp: %s\n", SDL_GetError());
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1055
        return;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1056
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1057
}
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1058
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1059
void
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1060
SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done)
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1061
{
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1062
    int i;
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1063
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1064
    if (state->verbose & VERBOSE_EVENT) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1065
        SDLTest_PrintEvent(event);
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1066
    }
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1067
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1068
    switch (event->type) {
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1069
    case SDL_WINDOWEVENT:
1b5280cd5885 Added existing common.c/.h functions to test lib; minor assert refactoring
Andreas Schiffler <aschiffler@ferzkopp.net>
parents:
diff changeset
  1070
        switch (event->window.event) {