test/testoverlay2.c
author Sam Lantinga <slouken@libsdl.org>
Thu, 23 May 2019 14:19:00 -0700
changeset 12756 4116bf232fe7
parent 12503 806492103856
child 12828 27d544cc7236
permissions -rw-r--r--
Added a function to get the current Android SDK version at runtime
slouken@5535
     1
/*
slouken@12503
     2
  Copyright (C) 1997-2019 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
icculus@9278
    19
#ifdef __EMSCRIPTEN__
icculus@9278
    20
#include <emscripten/emscripten.h>
icculus@9278
    21
#endif
icculus@9278
    22
slouken@672
    23
#include "SDL.h"
slouken@672
    24
slouken@11702
    25
#include "testyuv_cvt.h"
slouken@11702
    26
slouken@672
    27
#define MOOSEPIC_W 64
slouken@672
    28
#define MOOSEPIC_H 88
slouken@672
    29
slouken@672
    30
#define MOOSEFRAME_SIZE (MOOSEPIC_W * MOOSEPIC_H)
slouken@672
    31
#define MOOSEFRAMES_COUNT 10
slouken@672
    32
slouken@1895
    33
SDL_Color MooseColors[84] = {
philipp@10810
    34
    {49, 49, 49, SDL_ALPHA_OPAQUE}
philipp@10810
    35
    , {66, 24, 0, SDL_ALPHA_OPAQUE}
philipp@10810
    36
    , {66, 33, 0, SDL_ALPHA_OPAQUE}
philipp@10810
    37
    , {66, 66, 66, SDL_ALPHA_OPAQUE}
slouken@1895
    38
    ,
philipp@10810
    39
    {66, 115, 49, SDL_ALPHA_OPAQUE}
philipp@10810
    40
    , {74, 33, 0, SDL_ALPHA_OPAQUE}
philipp@10810
    41
    , {74, 41, 16, SDL_ALPHA_OPAQUE}
philipp@10810
    42
    , {82, 33, 8, SDL_ALPHA_OPAQUE}
slouken@1895
    43
    ,
philipp@10810
    44
    {82, 41, 8, SDL_ALPHA_OPAQUE}
philipp@10810
    45
    , {82, 49, 16, SDL_ALPHA_OPAQUE}
philipp@10810
    46
    , {82, 82, 82, SDL_ALPHA_OPAQUE}
philipp@10810
    47
    , {90, 41, 8, SDL_ALPHA_OPAQUE}
slouken@1895
    48
    ,
philipp@10810
    49
    {90, 41, 16, SDL_ALPHA_OPAQUE}
philipp@10810
    50
    , {90, 57, 24, SDL_ALPHA_OPAQUE}
philipp@10810
    51
    , {99, 49, 16, SDL_ALPHA_OPAQUE}
philipp@10810
    52
    , {99, 66, 24, SDL_ALPHA_OPAQUE}
slouken@1895
    53
    ,
philipp@10810
    54
    {99, 66, 33, SDL_ALPHA_OPAQUE}
philipp@10810
    55
    , {99, 74, 33, SDL_ALPHA_OPAQUE}
philipp@10810
    56
    , {107, 57, 24, SDL_ALPHA_OPAQUE}
philipp@10810
    57
    , {107, 82, 41, SDL_ALPHA_OPAQUE}
slouken@1895
    58
    ,
philipp@10810
    59
    {115, 57, 33, SDL_ALPHA_OPAQUE}
philipp@10810
    60
    , {115, 66, 33, SDL_ALPHA_OPAQUE}
philipp@10810
    61
    , {115, 66, 41, SDL_ALPHA_OPAQUE}
philipp@10810
    62
    , {115, 74, 0, SDL_ALPHA_OPAQUE}
slouken@1895
    63
    ,
philipp@10810
    64
    {115, 90, 49, SDL_ALPHA_OPAQUE}
philipp@10810
    65
    , {115, 115, 115, SDL_ALPHA_OPAQUE}
philipp@10810
    66
    , {123, 82, 0, SDL_ALPHA_OPAQUE}
philipp@10810
    67
    , {123, 99, 57, SDL_ALPHA_OPAQUE}
slouken@1895
    68
    ,
philipp@10810
    69
    {132, 66, 41, SDL_ALPHA_OPAQUE}
philipp@10810
    70
    , {132, 74, 41, SDL_ALPHA_OPAQUE}
philipp@10810
    71
    , {132, 90, 8, SDL_ALPHA_OPAQUE}
philipp@10810
    72
    , {132, 99, 33, SDL_ALPHA_OPAQUE}
slouken@1895
    73
    ,
philipp@10810
    74
    {132, 99, 66, SDL_ALPHA_OPAQUE}
philipp@10810
    75
    , {132, 107, 66, SDL_ALPHA_OPAQUE}
philipp@10810
    76
    , {140, 74, 49, SDL_ALPHA_OPAQUE}
philipp@10810
    77
    , {140, 99, 16, SDL_ALPHA_OPAQUE}
slouken@1895
    78
    ,
philipp@10810
    79
    {140, 107, 74, SDL_ALPHA_OPAQUE}
philipp@10810
    80
    , {140, 115, 74, SDL_ALPHA_OPAQUE}
philipp@10810
    81
    , {148, 107, 24, SDL_ALPHA_OPAQUE}
philipp@10810
    82
    , {148, 115, 82, SDL_ALPHA_OPAQUE}
slouken@1895
    83
    ,
philipp@10810
    84
    {148, 123, 74, SDL_ALPHA_OPAQUE}
philipp@10810
    85
    , {148, 123, 90, SDL_ALPHA_OPAQUE}
philipp@10810
    86
    , {156, 115, 33, SDL_ALPHA_OPAQUE}
philipp@10810
    87
    , {156, 115, 90, SDL_ALPHA_OPAQUE}
slouken@1895
    88
    ,
philipp@10810
    89
    {156, 123, 82, SDL_ALPHA_OPAQUE}
philipp@10810
    90
    , {156, 132, 82, SDL_ALPHA_OPAQUE}
philipp@10810
    91
    , {156, 132, 99, SDL_ALPHA_OPAQUE}
philipp@10810
    92
    , {156, 156, 156, SDL_ALPHA_OPAQUE}
slouken@1895
    93
    ,
philipp@10810
    94
    {165, 123, 49, SDL_ALPHA_OPAQUE}
philipp@10810
    95
    , {165, 123, 90, SDL_ALPHA_OPAQUE}
philipp@10810
    96
    , {165, 132, 82, SDL_ALPHA_OPAQUE}
philipp@10810
    97
    , {165, 132, 90, SDL_ALPHA_OPAQUE}
slouken@1895
    98
    ,
philipp@10810
    99
    {165, 132, 99, SDL_ALPHA_OPAQUE}
philipp@10810
   100
    , {165, 140, 90, SDL_ALPHA_OPAQUE}
philipp@10810
   101
    , {173, 132, 57, SDL_ALPHA_OPAQUE}
philipp@10810
   102
    , {173, 132, 99, SDL_ALPHA_OPAQUE}
slouken@1895
   103
    ,
philipp@10810
   104
    {173, 140, 107, SDL_ALPHA_OPAQUE}
philipp@10810
   105
    , {173, 140, 115, SDL_ALPHA_OPAQUE}
philipp@10810
   106
    , {173, 148, 99, SDL_ALPHA_OPAQUE}
philipp@10810
   107
    , {173, 173, 173, SDL_ALPHA_OPAQUE}
slouken@1895
   108
    ,
philipp@10810
   109
    {181, 140, 74, SDL_ALPHA_OPAQUE}
philipp@10810
   110
    , {181, 148, 115, SDL_ALPHA_OPAQUE}
philipp@10810
   111
    , {181, 148, 123, SDL_ALPHA_OPAQUE}
philipp@10810
   112
    , {181, 156, 107, SDL_ALPHA_OPAQUE}
slouken@1895
   113
    ,
philipp@10810
   114
    {189, 148, 123, SDL_ALPHA_OPAQUE}
philipp@10810
   115
    , {189, 156, 82, SDL_ALPHA_OPAQUE}
philipp@10810
   116
    , {189, 156, 123, SDL_ALPHA_OPAQUE}
philipp@10810
   117
    , {189, 156, 132, SDL_ALPHA_OPAQUE}
slouken@1895
   118
    ,
philipp@10810
   119
    {189, 189, 189, SDL_ALPHA_OPAQUE}
philipp@10810
   120
    , {198, 156, 123, SDL_ALPHA_OPAQUE}
philipp@10810
   121
    , {198, 165, 132, SDL_ALPHA_OPAQUE}
philipp@10810
   122
    , {206, 165, 99, SDL_ALPHA_OPAQUE}
slouken@1895
   123
    ,
philipp@10810
   124
    {206, 165, 132, SDL_ALPHA_OPAQUE}
philipp@10810
   125
    , {206, 173, 140, SDL_ALPHA_OPAQUE}
philipp@10810
   126
    , {206, 206, 206, SDL_ALPHA_OPAQUE}
philipp@10810
   127
    , {214, 173, 115, SDL_ALPHA_OPAQUE}
slouken@1895
   128
    ,
philipp@10810
   129
    {214, 173, 140, SDL_ALPHA_OPAQUE}
philipp@10810
   130
    , {222, 181, 148, SDL_ALPHA_OPAQUE}
philipp@10810
   131
    , {222, 189, 132, SDL_ALPHA_OPAQUE}
philipp@10810
   132
    , {222, 189, 156, SDL_ALPHA_OPAQUE}
slouken@1895
   133
    ,
philipp@10810
   134
    {222, 222, 222, SDL_ALPHA_OPAQUE}
philipp@10810
   135
    , {231, 198, 165, SDL_ALPHA_OPAQUE}
philipp@10810
   136
    , {231, 231, 231, SDL_ALPHA_OPAQUE}
philipp@10810
   137
    , {239, 206, 173, SDL_ALPHA_OPAQUE}
slouken@672
   138
};
slouken@672
   139
icculus@9278
   140
Uint8 MooseFrame[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE*2];
icculus@9278
   141
SDL_Texture *MooseTexture;
icculus@9278
   142
SDL_Rect displayrect;
icculus@9278
   143
int window_w;
icculus@9278
   144
int window_h;
icculus@9278
   145
SDL_Window *window;
icculus@9278
   146
SDL_Renderer *renderer;
icculus@9278
   147
int paused = 0;
icculus@9278
   148
int i;
icculus@9278
   149
SDL_bool done = SDL_FALSE;
philipp@10731
   150
static int fpsdelay;
icculus@1151
   151
icculus@1151
   152
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
slouken@1895
   153
static void
slouken@1895
   154
quit(int rc)
icculus@1151
   155
{
slouken@1895
   156
    SDL_Quit();
slouken@1895
   157
    exit(rc);
icculus@1151
   158
}
icculus@1151
   159
slouken@1895
   160
static void
slouken@1895
   161
PrintUsage(char *argv0)
slouken@672
   162
{
aschiffler@7639
   163
    SDL_Log("Usage: %s [arg] [arg] [arg] ...\n", argv0);
aschiffler@7639
   164
    SDL_Log("\n");
aschiffler@7639
   165
    SDL_Log("Where 'arg' is any of the following options:\n");
aschiffler@7639
   166
    SDL_Log("\n");
aschiffler@7639
   167
    SDL_Log("    -fps <frames per second>\n");
aschiffler@7639
   168
    SDL_Log("    -nodelay\n");
aschiffler@7639
   169
    SDL_Log("    -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
aschiffler@7639
   170
    SDL_Log("    -scale <scale factor> (initial scale of the overlay)\n");
aschiffler@7639
   171
    SDL_Log("    -help (shows this help)\n");
aschiffler@7639
   172
    SDL_Log("\n");
aschiffler@7639
   173
    SDL_Log("Press ESC to exit, or SPACE to freeze the movie while application running.\n");
aschiffler@7639
   174
    SDL_Log("\n");
slouken@672
   175
}
slouken@672
   176
icculus@9278
   177
void
icculus@9278
   178
loop()
icculus@9278
   179
{
icculus@9278
   180
    SDL_Event event;
icculus@9278
   181
icculus@9278
   182
    while (SDL_PollEvent(&event)) {
icculus@9278
   183
        switch (event.type) {
icculus@9278
   184
        case SDL_WINDOWEVENT:
icculus@9278
   185
            if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
icculus@9278
   186
                SDL_RenderSetViewport(renderer, NULL);
icculus@9278
   187
                displayrect.w = window_w = event.window.data1;
icculus@9278
   188
                displayrect.h = window_h = event.window.data2;
icculus@9278
   189
            }
icculus@9278
   190
            break;
icculus@9278
   191
        case SDL_MOUSEBUTTONDOWN:
icculus@9278
   192
            displayrect.x = event.button.x - window_w / 2;
icculus@9278
   193
            displayrect.y = event.button.y - window_h / 2;
icculus@9278
   194
            break;
icculus@9278
   195
        case SDL_MOUSEMOTION:
icculus@9278
   196
            if (event.motion.state) {
icculus@9278
   197
                displayrect.x = event.motion.x - window_w / 2;
icculus@9278
   198
                displayrect.y = event.motion.y - window_h / 2;
icculus@9278
   199
            }
icculus@9278
   200
            break;
icculus@9278
   201
        case SDL_KEYDOWN:
icculus@9278
   202
            if (event.key.keysym.sym == SDLK_SPACE) {
icculus@9278
   203
                paused = !paused;
icculus@9278
   204
                break;
icculus@9278
   205
            }
icculus@9278
   206
            if (event.key.keysym.sym != SDLK_ESCAPE) {
icculus@9278
   207
                break;
icculus@9278
   208
            }
icculus@9278
   209
        case SDL_QUIT:
icculus@9278
   210
            done = SDL_TRUE;
icculus@9278
   211
            break;
icculus@9278
   212
        }
icculus@9278
   213
    }
icculus@9278
   214
icculus@9278
   215
#ifndef __EMSCRIPTEN__
icculus@9278
   216
    SDL_Delay(fpsdelay);
icculus@9278
   217
#endif
icculus@9278
   218
icculus@9278
   219
    if (!paused) {
icculus@9278
   220
        i = (i + 1) % MOOSEFRAMES_COUNT;
icculus@9278
   221
slouken@11702
   222
        SDL_UpdateTexture(MooseTexture, NULL, MooseFrame[i], MOOSEPIC_W);
icculus@9278
   223
    }
icculus@9278
   224
    SDL_RenderClear(renderer);
icculus@9278
   225
    SDL_RenderCopy(renderer, MooseTexture, NULL, &displayrect);
icculus@9278
   226
    SDL_RenderPresent(renderer);
philipp@9607
   227
philipp@9607
   228
#ifdef __EMSCRIPTEN__
philipp@9607
   229
    if (done) {
philipp@9607
   230
        emscripten_cancel_main_loop();
philipp@9607
   231
    }
philipp@9607
   232
#endif
icculus@9278
   233
}
icculus@9278
   234
slouken@1895
   235
int
slouken@1895
   236
main(int argc, char **argv)
slouken@672
   237
{
slouken@1895
   238
    Uint8 *RawMooseData;
slouken@1895
   239
    SDL_RWops *handle;
slouken@5216
   240
    SDL_Window *window;
icculus@9278
   241
    int j;
slouken@1895
   242
    int fps = 12;
slouken@5216
   243
    int nodelay = 0;
slouken@1895
   244
    int scale = 5;
slouken@672
   245
aschiffler@7639
   246
    /* Enable standard application logging */
aschiffler@7639
   247
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
aschiffler@7639
   248
slouken@7504
   249
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
aschiffler@7639
   250
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
icculus@1151
   251
        return 3;
icculus@1151
   252
    }
icculus@1151
   253
slouken@1895
   254
    while (argc > 1) {
slouken@1895
   255
        if (strcmp(argv[1], "-fps") == 0) {
slouken@1895
   256
            if (argv[2]) {
icculus@11834
   257
                fps = SDL_atoi(argv[2]);
slouken@1895
   258
                if (fps == 0) {
aschiffler@7639
   259
                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
slouken@1895
   260
                            "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
icculus@1151
   261
                    quit(10);
slouken@672
   262
                }
slouken@1895
   263
                if ((fps < 0) || (fps > 1000)) {
aschiffler@7639
   264
                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
slouken@1895
   265
                            "The -fps option must be in range from 1 to 1000, default is 12.\n");
icculus@1151
   266
                    quit(10);
slouken@672
   267
                }
slouken@672
   268
                argv += 2;
slouken@672
   269
                argc -= 2;
slouken@1895
   270
            } else {
aschiffler@7639
   271
                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
slouken@1895
   272
                        "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
icculus@1151
   273
                quit(10);
slouken@672
   274
            }
slouken@5216
   275
        } else if (strcmp(argv[1], "-nodelay") == 0) {
slouken@5216
   276
            nodelay = 1;
slouken@5216
   277
            argv += 1;
slouken@5216
   278
            argc -= 1;
slouken@1895
   279
        } else if (strcmp(argv[1], "-scale") == 0) {
slouken@1895
   280
            if (argv[2]) {
icculus@11834
   281
                scale = SDL_atoi(argv[2]);
slouken@1895
   282
                if (scale == 0) {
aschiffler@7639
   283
                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
slouken@1895
   284
                            "The -scale option requires an argument [from 1 to 50], default is 5.\n");
icculus@1151
   285
                    quit(10);
slouken@672
   286
                }
slouken@1895
   287
                if ((scale < 0) || (scale > 50)) {
aschiffler@7639
   288
                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
slouken@1895
   289
                            "The -scale option must be in range from 1 to 50, default is 5.\n");
icculus@1151
   290
                    quit(10);
slouken@672
   291
                }
slouken@672
   292
                argv += 2;
slouken@672
   293
                argc -= 2;
slouken@1895
   294
            } else {
aschiffler@7639
   295
                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
slouken@1895
   296
                        "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
icculus@1151
   297
                quit(10);
slouken@672
   298
            }
slouken@1895
   299
        } else if ((strcmp(argv[1], "-help") == 0)
slouken@1895
   300
                   || (strcmp(argv[1], "-h") == 0)) {
slouken@672
   301
            PrintUsage(argv[0]);
icculus@1151
   302
            quit(0);
slouken@1895
   303
        } else {
aschiffler@7639
   304
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unrecognized option: %s.\n", argv[1]);
icculus@1151
   305
            quit(10);
slouken@672
   306
        }
slouken@672
   307
        break;
slouken@672
   308
    }
slouken@1895
   309
slouken@1895
   310
    RawMooseData = (Uint8 *) malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
slouken@1895
   311
    if (RawMooseData == NULL) {
aschiffler@7639
   312
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n");
icculus@1151
   313
        quit(1);
slouken@672
   314
    }
slouken@672
   315
slouken@672
   316
    /* load the trojan moose images */
slouken@1895
   317
    handle = SDL_RWFromFile("moose.dat", "rb");
slouken@1895
   318
    if (handle == NULL) {
aschiffler@7639
   319
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
slouken@672
   320
        free(RawMooseData);
icculus@1151
   321
        quit(2);
slouken@672
   322
    }
slouken@1895
   323
slouken@672
   324
    SDL_RWread(handle, RawMooseData, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT);
slouken@672
   325
slouken@672
   326
    SDL_RWclose(handle);
slouken@672
   327
slouken@5216
   328
    /* Create the window and renderer */
slouken@5216
   329
    window_w = MOOSEPIC_W * scale;
slouken@5216
   330
    window_h = MOOSEPIC_H * scale;
slouken@5216
   331
    window = SDL_CreateWindow("Happy Moose",
slouken@5216
   332
                              SDL_WINDOWPOS_UNDEFINED,
slouken@5216
   333
                              SDL_WINDOWPOS_UNDEFINED,
slouken@5216
   334
                              window_w, window_h,
philipp@7478
   335
                              SDL_WINDOW_RESIZABLE);
slouken@5216
   336
    if (!window) {
aschiffler@7639
   337
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
slouken@672
   338
        free(RawMooseData);
icculus@1151
   339
        quit(4);
slouken@672
   340
    }
slouken@672
   341
slouken@5216
   342
    renderer = SDL_CreateRenderer(window, -1, 0);
slouken@5216
   343
    if (!renderer) {
aschiffler@7639
   344
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
slouken@5216
   345
        free(RawMooseData);
slouken@5216
   346
        quit(4);
slouken@5216
   347
    }
slouken@5216
   348
slouken@11702
   349
    MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
slouken@5252
   350
    if (!MooseTexture) {
aschiffler@7639
   351
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
slouken@5216
   352
        free(RawMooseData);
slouken@5216
   353
        quit(5);
slouken@5216
   354
    }
slouken@7504
   355
    /* Uncomment this to check vertex color with a YUV texture */
gabomdq@7678
   356
    /* SDL_SetTextureColorMod(MooseTexture, 0xff, 0x80, 0x80); */
slouken@672
   357
slouken@1895
   358
    for (i = 0; i < MOOSEFRAMES_COUNT; i++) {
slouken@5216
   359
        Uint8 MooseFrameRGB[MOOSEFRAME_SIZE*3];
slouken@5216
   360
        Uint8 *rgb;
slouken@5216
   361
        Uint8 *frame;
slouken@5216
   362
slouken@5216
   363
        rgb = MooseFrameRGB;
slouken@5216
   364
        frame = RawMooseData + i * MOOSEFRAME_SIZE;
slouken@5216
   365
        for (j = 0; j < MOOSEFRAME_SIZE; ++j) {
slouken@5216
   366
            rgb[0] = MooseColors[frame[j]].r;
slouken@5216
   367
            rgb[1] = MooseColors[frame[j]].g;
slouken@5216
   368
            rgb[2] = MooseColors[frame[j]].b;
slouken@5216
   369
            rgb += 3;
slouken@672
   370
        }
slouken@11702
   371
        ConvertRGBtoYUV(SDL_PIXELFORMAT_YV12, MooseFrameRGB, MOOSEPIC_W*3, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H,
slouken@11702
   372
            SDL_GetYUVConversionModeForResolution(MOOSEPIC_W, MOOSEPIC_H),
slouken@11702
   373
            0, 100);
slouken@672
   374
    }
slouken@672
   375
slouken@672
   376
    free(RawMooseData);
slouken@672
   377
slouken@5216
   378
    /* set the start frame */
slouken@5216
   379
    i = 0;
slouken@5216
   380
    if (nodelay) {
slouken@5216
   381
        fpsdelay = 0;
slouken@5216
   382
    } else {
slouken@5216
   383
        fpsdelay = 1000 / fps;
slouken@886
   384
    }
slouken@672
   385
slouken@5216
   386
    displayrect.x = 0;
slouken@5216
   387
    displayrect.y = 0;
slouken@5216
   388
    displayrect.w = window_w;
slouken@5216
   389
    displayrect.h = window_h;
slouken@672
   390
slouken@672
   391
    /* Ignore key up events, they don't even get filtered */
slouken@672
   392
    SDL_EventState(SDL_KEYUP, SDL_IGNORE);
slouken@672
   393
slouken@672
   394
    /* Loop, waiting for QUIT or RESIZE */
icculus@9278
   395
#ifdef __EMSCRIPTEN__
icculus@9278
   396
    emscripten_set_main_loop(loop, nodelay ? 0 : fps, 1);
icculus@9278
   397
#else
slouken@5216
   398
    while (!done) {
icculus@9278
   399
        loop();
slouken@672
   400
            }
icculus@9278
   401
#endif
slouken@672
   402
slouken@5216
   403
    SDL_DestroyRenderer(renderer);
slouken@5216
   404
    quit(0);
slouken@672
   405
    return 0;
slouken@672
   406
}
slouken@5216
   407
slouken@5216
   408
/* vi: set ts=4 sw=4 expandtab: */