test/testwm2.c
author Ryan C. Gordon <icculus@icculus.org>
Sun, 11 Jan 2009 04:05:28 +0000
changeset 3017 3272431eeee2
parent 1985 8055185ae4ed
child 3338 9de326b3099c
permissions -rw-r--r--
Added testresample.c
slouken@1895
     1
slouken@1933
     2
#include <stdlib.h>
slouken@1933
     3
#include <stdio.h>
slouken@1895
     4
slouken@1933
     5
#include "common.h"
slouken@1895
     6
slouken@1933
     7
static CommonState *state;
slouken@1895
     8
slouken@1895
     9
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
slouken@1895
    10
static void
slouken@1895
    11
quit(int rc)
slouken@1895
    12
{
slouken@1933
    13
    CommonQuit(state);
slouken@1895
    14
    exit(rc);
slouken@1895
    15
}
slouken@1895
    16
slouken@1895
    17
int
slouken@1895
    18
main(int argc, char *argv[])
slouken@1895
    19
{
slouken@1895
    20
    int i, done;
slouken@1895
    21
    SDL_Event event;
slouken@1895
    22
slouken@1933
    23
    /* Initialize test framework */
slouken@1933
    24
    state = CommonCreateState(argv, SDL_INIT_VIDEO);
slouken@1933
    25
    if (!state) {
slouken@1933
    26
        return 1;
slouken@1933
    27
    }
slouken@1933
    28
    state->skip_renderer = SDL_TRUE;
slouken@1933
    29
    for (i = 1; i < argc;) {
slouken@1933
    30
        int consumed;
slouken@1933
    31
slouken@1933
    32
        consumed = CommonArg(state, i);
slouken@1933
    33
        if (consumed == 0) {
slouken@1933
    34
            consumed = -1;
slouken@1933
    35
        }
slouken@1933
    36
        if (consumed < 0) {
slouken@1985
    37
            fprintf(stderr, "Usage: %s %s\n", argv[0], CommonUsage(state));
slouken@1933
    38
            quit(1);
slouken@1933
    39
        }
slouken@1933
    40
        i += consumed;
slouken@1933
    41
    }
slouken@1933
    42
    if (!CommonInit(state)) {
slouken@1933
    43
        quit(2);
slouken@1895
    44
    }
slouken@1895
    45
slouken@1933
    46
    /* Main render loop */
slouken@1895
    47
    done = 0;
slouken@1895
    48
    while (!done) {
slouken@1895
    49
        /* Check for events */
slouken@1895
    50
        while (SDL_PollEvent(&event)) {
slouken@1933
    51
            CommonEvent(state, &event, &done);
slouken@1895
    52
        }
slouken@1895
    53
    }
slouken@1895
    54
    quit(0);
slouken@1895
    55
}
slouken@1895
    56
slouken@1895
    57
/* vi: set ts=4 sw=4 expandtab: */