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