test/testoverlay2.c
author Ryan C. Gordon <icculus@icculus.org>
Wed, 25 Jun 2014 17:24:06 -0400
changeset 8956 a99e30f2bf0a
parent 8149 681eb46b8ac4
child 9046 c3ec7c3e6c24
permissions -rw-r--r--
Patched to compile on Windows.
slouken@5535
     1
/*
slouken@8149
     2
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
slouken@5535
     3
slouken@5535
     4
  This software is provided 'as-is', without any express or implied
slouken@5535
     5
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     6
  arising from the use of this software.
slouken@5535
     7
slouken@5535
     8
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
     9
  including commercial applications, and to alter it and redistribute it
slouken@5535
    10
  freely.
slouken@5535
    11
*/
slouken@672
    12
/********************************************************************************
slouken@672
    13
 *                                                                              *
slouken@672
    14
 * Test of the overlay used for moved pictures, test more closed to real life.  *
slouken@672
    15
 * Running trojan moose :) Coded by Mike Gorchak.                               *
slouken@672
    16
 *                                                                              *
slouken@672
    17
 ********************************************************************************/
slouken@672
    18
slouken@1030
    19
#include <stdlib.h>
slouken@1030
    20
#include <stdio.h>
slouken@1030
    21
#include <string.h>
slouken@1030
    22
slouken@672
    23
#include "SDL.h"
slouken@672
    24
slouken@672
    25
#define MOOSEPIC_W 64
slouken@672
    26
#define MOOSEPIC_H 88
slouken@672
    27
slouken@672
    28
#define MOOSEFRAME_SIZE (MOOSEPIC_W * MOOSEPIC_H)
slouken@672
    29
#define MOOSEFRAMES_COUNT 10
slouken@672
    30
slouken@1895
    31
SDL_Color MooseColors[84] = {
slouken@1895
    32
    {49, 49, 49}
slouken@1895
    33
    , {66, 24, 0}
slouken@1895
    34
    , {66, 33, 0}
slouken@1895
    35
    , {66, 66, 66}
slouken@1895
    36
    ,
slouken@1895
    37
    {66, 115, 49}
slouken@1895
    38
    , {74, 33, 0}
slouken@1895
    39
    , {74, 41, 16}
slouken@1895
    40
    , {82, 33, 8}
slouken@1895
    41
    ,
slouken@1895
    42
    {82, 41, 8}
slouken@1895
    43
    , {82, 49, 16}
slouken@1895
    44
    , {82, 82, 82}
slouken@1895
    45
    , {90, 41, 8}
slouken@1895
    46
    ,
slouken@1895
    47
    {90, 41, 16}
slouken@1895
    48
    , {90, 57, 24}
slouken@1895
    49
    , {99, 49, 16}
slouken@1895
    50
    , {99, 66, 24}
slouken@1895
    51
    ,
slouken@1895
    52
    {99, 66, 33}
slouken@1895
    53
    , {99, 74, 33}
slouken@1895
    54
    , {107, 57, 24}
slouken@1895
    55
    , {107, 82, 41}
slouken@1895
    56
    ,
slouken@1895
    57
    {115, 57, 33}
slouken@1895
    58
    , {115, 66, 33}
slouken@1895
    59
    , {115, 66, 41}
slouken@1895
    60
    , {115, 74, 0}
slouken@1895
    61
    ,
slouken@1895
    62
    {115, 90, 49}
slouken@1895
    63
    , {115, 115, 115}
slouken@1895
    64
    , {123, 82, 0}
slouken@1895
    65
    , {123, 99, 57}
slouken@1895
    66
    ,
slouken@1895
    67
    {132, 66, 41}
slouken@1895
    68
    , {132, 74, 41}
slouken@1895
    69
    , {132, 90, 8}
slouken@1895
    70
    , {132, 99, 33}
slouken@1895
    71
    ,
slouken@1895
    72
    {132, 99, 66}
slouken@1895
    73
    , {132, 107, 66}
slouken@1895
    74
    , {140, 74, 49}
slouken@1895
    75
    , {140, 99, 16}
slouken@1895
    76
    ,
slouken@1895
    77
    {140, 107, 74}
slouken@1895
    78
    , {140, 115, 74}
slouken@1895
    79
    , {148, 107, 24}
slouken@1895
    80
    , {148, 115, 82}
slouken@1895
    81
    ,
slouken@1895
    82
    {148, 123, 74}
slouken@1895
    83
    , {148, 123, 90}
slouken@1895
    84
    , {156, 115, 33}
slouken@1895
    85
    , {156, 115, 90}
slouken@1895
    86
    ,
slouken@1895
    87
    {156, 123, 82}
slouken@1895
    88
    , {156, 132, 82}
slouken@1895
    89
    , {156, 132, 99}
slouken@1895
    90
    , {156, 156, 156}
slouken@1895
    91
    ,
slouken@1895
    92
    {165, 123, 49}
slouken@1895
    93
    , {165, 123, 90}
slouken@1895
    94
    , {165, 132, 82}
slouken@1895
    95
    , {165, 132, 90}
slouken@1895
    96
    ,
slouken@1895
    97
    {165, 132, 99}
slouken@1895
    98
    , {165, 140, 90}
slouken@1895
    99
    , {173, 132, 57}
slouken@1895
   100
    , {173, 132, 99}
slouken@1895
   101
    ,
slouken@1895
   102
    {173, 140, 107}
slouken@1895
   103
    , {173, 140, 115}
slouken@1895
   104
    , {173, 148, 99}
slouken@1895
   105
    , {173, 173, 173}
slouken@1895
   106
    ,
slouken@1895
   107
    {181, 140, 74}
slouken@1895
   108
    , {181, 148, 115}
slouken@1895
   109
    , {181, 148, 123}
slouken@1895
   110
    , {181, 156, 107}
slouken@1895
   111
    ,
slouken@1895
   112
    {189, 148, 123}
slouken@1895
   113
    , {189, 156, 82}
slouken@1895
   114
    , {189, 156, 123}
slouken@1895
   115
    , {189, 156, 132}
slouken@1895
   116
    ,
slouken@1895
   117
    {189, 189, 189}
slouken@1895
   118
    , {198, 156, 123}
slouken@1895
   119
    , {198, 165, 132}
slouken@1895
   120
    , {206, 165, 99}
slouken@1895
   121
    ,
slouken@1895
   122
    {206, 165, 132}
slouken@1895
   123
    , {206, 173, 140}
slouken@1895
   124
    , {206, 206, 206}
slouken@1895
   125
    , {214, 173, 115}
slouken@1895
   126
    ,
slouken@1895
   127
    {214, 173, 140}
slouken@1895
   128
    , {222, 181, 148}
slouken@1895
   129
    , {222, 189, 132}
slouken@1895
   130
    , {222, 189, 156}
slouken@1895
   131
    ,
slouken@1895
   132
    {222, 222, 222}
slouken@1895
   133
    , {231, 198, 165}
slouken@1895
   134
    , {231, 231, 231}
slouken@1895
   135
    , {239, 206, 173}
slouken@672
   136
};
slouken@672
   137
icculus@1151
   138
icculus@1151
   139
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
slouken@1895
   140
static void
slouken@1895
   141
quit(int rc)
icculus@1151
   142
{
slouken@1895
   143
    SDL_Quit();
slouken@1895
   144
    exit(rc);
icculus@1151
   145
}
icculus@1151
   146
slouken@672
   147
/* All RGB2YUV conversion code and some other parts of code has been taken from testoverlay.c */
slouken@672
   148
slouken@672
   149
/* NOTE: These RGB conversion functions are not intended for speed,
slouken@672
   150
         only as examples.
slouken@672
   151
*/
slouken@672
   152
slouken@1895
   153
void
slouken@1895
   154
RGBtoYUV(Uint8 * rgb, int *yuv, int monochrome, int luminance)
slouken@672
   155
{
slouken@1895
   156
    if (monochrome) {
slouken@1895
   157
#if 1                           /* these are the two formulas that I found on the FourCC site... */
aschiffler@4884
   158
        yuv[0] = (int)(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]);
slouken@672
   159
        yuv[1] = 128;
slouken@672
   160
        yuv[2] = 128;
slouken@672
   161
#else
aschiffler@4884
   162
        yuv[0] = (int)(0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
slouken@672
   163
        yuv[1] = 128;
slouken@672
   164
        yuv[2] = 128;
slouken@672
   165
#endif
slouken@1895
   166
    } else {
slouken@1895
   167
#if 1                           /* these are the two formulas that I found on the FourCC site... */
aschiffler@4884
   168
        yuv[0] = (int)(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]);
aschiffler@4884
   169
        yuv[1] = (int)((rgb[2] - yuv[0]) * 0.565 + 128);
aschiffler@4884
   170
        yuv[2] = (int)((rgb[0] - yuv[0]) * 0.713 + 128);
slouken@672
   171
#else
slouken@672
   172
        yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
slouken@672
   173
        yuv[1] = 128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]);
slouken@672
   174
        yuv[2] = 128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]);
slouken@672
   175
#endif
slouken@672
   176
    }
slouken@672
   177
slouken@1895
   178
    if (luminance != 100) {
slouken@1895
   179
        yuv[0] = yuv[0] * luminance / 100;
slouken@1895
   180
        if (yuv[0] > 255)
slouken@1895
   181
            yuv[0] = 255;
slouken@672
   182
    }
slouken@672
   183
}
slouken@672
   184
slouken@1895
   185
void
slouken@5216
   186
ConvertRGBtoYV12(Uint8 *rgb, Uint8 *out, int w, int h,
slouken@5216
   187
                 int monochrome, int luminance)
slouken@672
   188
{
slouken@1895
   189
    int x, y;
slouken@1895
   190
    int yuv[3];
slouken@5216
   191
    Uint8 *op[3];
slouken@672
   192
slouken@5216
   193
    op[0] = out;
slouken@5216
   194
    op[1] = op[0] + w*h;
slouken@5216
   195
    op[2] = op[1] + w*h/4;
slouken@5216
   196
    for (y = 0; y < h; ++y) {
slouken@5216
   197
        for (x = 0; x < w; ++x) {
slouken@5216
   198
            RGBtoYUV(rgb, yuv, monochrome, luminance);
slouken@1895
   199
            *(op[0]++) = yuv[0];
slouken@1895
   200
            if (x % 2 == 0 && y % 2 == 0) {
slouken@1895
   201
                *(op[1]++) = yuv[2];
slouken@1895
   202
                *(op[2]++) = yuv[1];
slouken@1895
   203
            }
slouken@5216
   204
            rgb += 3;
slouken@1895
   205
        }
slouken@1895
   206
    }
slouken@672
   207
}
slouken@672
   208
slouken@1895
   209
static void
slouken@1895
   210
PrintUsage(char *argv0)
slouken@672
   211
{
aschiffler@7639
   212
    SDL_Log("Usage: %s [arg] [arg] [arg] ...\n", argv0);
aschiffler@7639
   213
    SDL_Log("\n");
aschiffler@7639
   214
    SDL_Log("Where 'arg' is any of the following options:\n");
aschiffler@7639
   215
    SDL_Log("\n");
aschiffler@7639
   216
    SDL_Log("    -fps <frames per second>\n");
aschiffler@7639
   217
    SDL_Log("    -nodelay\n");
aschiffler@7639
   218
    SDL_Log("    -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
aschiffler@7639
   219
    SDL_Log("    -scale <scale factor> (initial scale of the overlay)\n");
aschiffler@7639
   220
    SDL_Log("    -help (shows this help)\n");
aschiffler@7639
   221
    SDL_Log("\n");
aschiffler@7639
   222
    SDL_Log("Press ESC to exit, or SPACE to freeze the movie while application running.\n");
aschiffler@7639
   223
    SDL_Log("\n");
slouken@672
   224
}
slouken@672
   225
slouken@1895
   226
int
slouken@1895
   227
main(int argc, char **argv)
slouken@672
   228
{
slouken@1895
   229
    Uint8 *RawMooseData;
slouken@1895
   230
    SDL_RWops *handle;
slouken@5216
   231
    int window_w;
slouken@5216
   232
    int window_h;
slouken@5216
   233
    SDL_Window *window;
slouken@5216
   234
    SDL_Renderer *renderer;
slouken@5216
   235
    Uint8 MooseFrame[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE*2];
slouken@5216
   236
    SDL_Texture *MooseTexture;
slouken@5216
   237
    SDL_Rect displayrect;
slouken@672
   238
    SDL_Event event;
slouken@1895
   239
    int paused = 0;
slouken@5216
   240
    int i, j;
slouken@1895
   241
    int fps = 12;
slouken@672
   242
    int fpsdelay;
slouken@5216
   243
    int nodelay = 0;
slouken@5264
   244
    Uint32 pixel_format = SDL_PIXELFORMAT_YV12;
slouken@1895
   245
    int scale = 5;
slouken@5216
   246
    SDL_bool done = SDL_FALSE;
slouken@672
   247
aschiffler@7639
   248
    /* Enable standard application logging */
aschiffler@7639
   249
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
aschiffler@7639
   250
slouken@7504
   251
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
aschiffler@7639
   252
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
icculus@1151
   253
        return 3;
icculus@1151
   254
    }
icculus@1151
   255
slouken@1895
   256
    while (argc > 1) {
slouken@1895
   257
        if (strcmp(argv[1], "-fps") == 0) {
slouken@1895
   258
            if (argv[2]) {
slouken@672
   259
                fps = atoi(argv[2]);
slouken@1895
   260
                if (fps == 0) {
aschiffler@7639
   261
                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
slouken@1895
   262
                            "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
icculus@1151
   263
                    quit(10);
slouken@672
   264
                }
slouken@1895
   265
                if ((fps < 0) || (fps > 1000)) {
aschiffler@7639
   266
                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
slouken@1895
   267
                            "The -fps option must be in range from 1 to 1000, default is 12.\n");
icculus@1151
   268
                    quit(10);
slouken@672
   269
                }
slouken@672
   270
                argv += 2;
slouken@672
   271
                argc -= 2;
slouken@1895
   272
            } else {
aschiffler@7639
   273
                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
slouken@1895
   274
                        "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
icculus@1151
   275
                quit(10);
slouken@672
   276
            }
slouken@5216
   277
        } else if (strcmp(argv[1], "-nodelay") == 0) {
slouken@5216
   278
            nodelay = 1;
slouken@5216
   279
            argv += 1;
slouken@5216
   280
            argc -= 1;
slouken@1895
   281
        } else if (strcmp(argv[1], "-scale") == 0) {
slouken@1895
   282
            if (argv[2]) {
slouken@672
   283
                scale = atoi(argv[2]);
slouken@1895
   284
                if (scale == 0) {
aschiffler@7639
   285
                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
slouken@1895
   286
                            "The -scale option requires an argument [from 1 to 50], default is 5.\n");
icculus@1151
   287
                    quit(10);
slouken@672
   288
                }
slouken@1895
   289
                if ((scale < 0) || (scale > 50)) {
aschiffler@7639
   290
                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
slouken@1895
   291
                            "The -scale option must be in range from 1 to 50, default is 5.\n");
icculus@1151
   292
                    quit(10);
slouken@672
   293
                }
slouken@672
   294
                argv += 2;
slouken@672
   295
                argc -= 2;
slouken@1895
   296
            } else {
aschiffler@7639
   297
                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
slouken@1895
   298
                        "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
icculus@1151
   299
                quit(10);
slouken@672
   300
            }
slouken@1895
   301
        } else if ((strcmp(argv[1], "-help") == 0)
slouken@1895
   302
                   || (strcmp(argv[1], "-h") == 0)) {
slouken@672
   303
            PrintUsage(argv[0]);
icculus@1151
   304
            quit(0);
slouken@1895
   305
        } else {
aschiffler@7639
   306
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unrecognized option: %s.\n", argv[1]);
icculus@1151
   307
            quit(10);
slouken@672
   308
        }
slouken@672
   309
        break;
slouken@672
   310
    }
slouken@1895
   311
slouken@1895
   312
    RawMooseData = (Uint8 *) malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
slouken@1895
   313
    if (RawMooseData == NULL) {
aschiffler@7639
   314
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n");
slouken@672
   315
        free(RawMooseData);
icculus@1151
   316
        quit(1);
slouken@672
   317
    }
slouken@672
   318
slouken@672
   319
    /* load the trojan moose images */
slouken@1895
   320
    handle = SDL_RWFromFile("moose.dat", "rb");
slouken@1895
   321
    if (handle == NULL) {
aschiffler@7639
   322
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
slouken@672
   323
        free(RawMooseData);
icculus@1151
   324
        quit(2);
slouken@672
   325
    }
slouken@1895
   326
slouken@672
   327
    SDL_RWread(handle, RawMooseData, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT);
slouken@672
   328
slouken@672
   329
    SDL_RWclose(handle);
slouken@672
   330
slouken@5216
   331
    /* Create the window and renderer */
slouken@5216
   332
    window_w = MOOSEPIC_W * scale;
slouken@5216
   333
    window_h = MOOSEPIC_H * scale;
slouken@5216
   334
    window = SDL_CreateWindow("Happy Moose",
slouken@5216
   335
                              SDL_WINDOWPOS_UNDEFINED,
slouken@5216
   336
                              SDL_WINDOWPOS_UNDEFINED,
slouken@5216
   337
                              window_w, window_h,
philipp@7478
   338
                              SDL_WINDOW_RESIZABLE);
slouken@5216
   339
    if (!window) {
aschiffler@7639
   340
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
slouken@672
   341
        free(RawMooseData);
icculus@1151
   342
        quit(4);
slouken@672
   343
    }
slouken@672
   344
slouken@5216
   345
    renderer = SDL_CreateRenderer(window, -1, 0);
slouken@5216
   346
    if (!renderer) {
aschiffler@7639
   347
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
slouken@5216
   348
        free(RawMooseData);
slouken@5216
   349
        quit(4);
slouken@5216
   350
    }
slouken@5216
   351
slouken@5264
   352
    MooseTexture = SDL_CreateTexture(renderer, pixel_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
slouken@5252
   353
    if (!MooseTexture) {
aschiffler@7639
   354
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
slouken@5216
   355
        free(RawMooseData);
slouken@5216
   356
        quit(5);
slouken@5216
   357
    }
slouken@7504
   358
    /* Uncomment this to check vertex color with a YUV texture */
gabomdq@7678
   359
    /* SDL_SetTextureColorMod(MooseTexture, 0xff, 0x80, 0x80); */
slouken@672
   360
slouken@1895
   361
    for (i = 0; i < MOOSEFRAMES_COUNT; i++) {
slouken@5216
   362
        Uint8 MooseFrameRGB[MOOSEFRAME_SIZE*3];
slouken@5216
   363
        Uint8 *rgb;
slouken@5216
   364
        Uint8 *frame;
slouken@5216
   365
slouken@5216
   366
        rgb = MooseFrameRGB;
slouken@5216
   367
        frame = RawMooseData + i * MOOSEFRAME_SIZE;
slouken@5216
   368
        for (j = 0; j < MOOSEFRAME_SIZE; ++j) {
slouken@5216
   369
            rgb[0] = MooseColors[frame[j]].r;
slouken@5216
   370
            rgb[1] = MooseColors[frame[j]].g;
slouken@5216
   371
            rgb[2] = MooseColors[frame[j]].b;
slouken@5216
   372
            rgb += 3;
slouken@672
   373
        }
slouken@5216
   374
        ConvertRGBtoYV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100);
slouken@672
   375
    }
slouken@672
   376
slouken@672
   377
    free(RawMooseData);
slouken@672
   378
slouken@5216
   379
    /* set the start frame */
slouken@5216
   380
    i = 0;
slouken@5216
   381
    if (nodelay) {
slouken@5216
   382
        fpsdelay = 0;
slouken@5216
   383
    } else {
slouken@5216
   384
        fpsdelay = 1000 / fps;
slouken@886
   385
    }
slouken@672
   386
slouken@5216
   387
    displayrect.x = 0;
slouken@5216
   388
    displayrect.y = 0;
slouken@5216
   389
    displayrect.w = window_w;
slouken@5216
   390
    displayrect.h = window_h;
slouken@672
   391
slouken@672
   392
    /* Ignore key up events, they don't even get filtered */
slouken@672
   393
    SDL_EventState(SDL_KEYUP, SDL_IGNORE);
slouken@672
   394
slouken@672
   395
    /* Loop, waiting for QUIT or RESIZE */
slouken@5216
   396
    while (!done) {
slouken@5216
   397
        while (SDL_PollEvent(&event)) {
slouken@1895
   398
            switch (event.type) {
slouken@5216
   399
            case SDL_WINDOWEVENT:
slouken@5216
   400
                if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
slouken@5357
   401
                    SDL_RenderSetViewport(renderer, NULL);
slouken@5216
   402
                    displayrect.w = window_w = event.window.data1;
slouken@5274
   403
                    displayrect.h = window_h = event.window.data2;
slouken@1895
   404
                }
slouken@1895
   405
                break;
slouken@1895
   406
            case SDL_MOUSEBUTTONDOWN:
slouken@5216
   407
                displayrect.x = event.button.x - window_w / 2;
slouken@5216
   408
                displayrect.y = event.button.y - window_h / 2;
slouken@5216
   409
                break;
slouken@5216
   410
            case SDL_MOUSEMOTION:
slouken@5216
   411
                if (event.motion.state) {
slouken@5216
   412
                    displayrect.x = event.motion.x - window_w / 2;
slouken@5216
   413
                    displayrect.y = event.motion.y - window_h / 2;
slouken@5216
   414
                }
slouken@1895
   415
                break;
slouken@1895
   416
            case SDL_KEYDOWN:
slouken@1895
   417
                if (event.key.keysym.sym == SDLK_SPACE) {
slouken@1895
   418
                    paused = !paused;
slouken@1895
   419
                    break;
slouken@1895
   420
                }
slouken@1895
   421
                if (event.key.keysym.sym != SDLK_ESCAPE) {
slouken@1895
   422
                    break;
slouken@1895
   423
                }
slouken@1895
   424
            case SDL_QUIT:
slouken@5216
   425
                done = SDL_TRUE;
slouken@5216
   426
                break;
slouken@672
   427
            }
slouken@672
   428
        }
slouken@5216
   429
        SDL_Delay(fpsdelay);
slouken@672
   430
slouken@5216
   431
        if (!paused) {
slouken@5216
   432
            i = (i + 1) % MOOSEFRAMES_COUNT;
slouken@672
   433
slouken@5264
   434
            SDL_UpdateTexture(MooseTexture, NULL, MooseFrame[i], MOOSEPIC_W*SDL_BYTESPERPIXEL(pixel_format));
slouken@672
   435
        }
slouken@5216
   436
        SDL_RenderClear(renderer);
slouken@5216
   437
        SDL_RenderCopy(renderer, MooseTexture, NULL, &displayrect);
slouken@5216
   438
        SDL_RenderPresent(renderer);
slouken@672
   439
    }
slouken@5216
   440
    SDL_DestroyRenderer(renderer);
slouken@5216
   441
    quit(0);
slouken@672
   442
    return 0;
slouken@672
   443
}
slouken@5216
   444
slouken@5216
   445
/* vi: set ts=4 sw=4 expandtab: */