test/testoverlay2.c
author Ryan C. Gordon <icculus@icculus.org>
Fri, 12 Aug 2016 19:59:00 -0400
changeset 10266 c09f06c4e8c8
parent 9998 f67cf37e9cd4
permissions -rw-r--r--
emscripten: send fake mouse events for touches, like other targets do. (This really should be handled at the higher level and not in the individual targets, but this fixes the immediate bug.)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5357
diff changeset
     1
/*
9998
f67cf37e9cd4 Updated copyright to 2016
Sam Lantinga <slouken@libsdl.org>
parents: 9619
diff changeset
     2
  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5357
diff changeset
     3
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5357
diff changeset
     4
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5357
diff changeset
     5
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5357
diff changeset
     6
  arising from the use of this software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5357
diff changeset
     7
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5357
diff changeset
     8
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5357
diff changeset
     9
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5357
diff changeset
    10
  freely.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5357
diff changeset
    11
*/
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
/********************************************************************************
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
 *                                                                              *
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
 * Test of the overlay used for moved pictures, test more closed to real life.  *
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
 * Running trojan moose :) Coded by Mike Gorchak.                               *
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
 *                                                                              *
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
 ********************************************************************************/
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
1030
6b8f0543337c Date: Sat, 15 Jan 2005 15:06:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 886
diff changeset
    19
#include <stdlib.h>
6b8f0543337c Date: Sat, 15 Jan 2005 15:06:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 886
diff changeset
    20
#include <stdio.h>
6b8f0543337c Date: Sat, 15 Jan 2005 15:06:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 886
diff changeset
    21
#include <string.h>
6b8f0543337c Date: Sat, 15 Jan 2005 15:06:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 886
diff changeset
    22
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
    23
#ifdef __EMSCRIPTEN__
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
    24
#include <emscripten/emscripten.h>
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
    25
#endif
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
    26
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
#include "SDL.h"
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
#define MOOSEPIC_W 64
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
#define MOOSEPIC_H 88
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
#define MOOSEFRAME_SIZE (MOOSEPIC_W * MOOSEPIC_H)
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
#define MOOSEFRAMES_COUNT 10
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    35
SDL_Color MooseColors[84] = {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    36
    {49, 49, 49}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    37
    , {66, 24, 0}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    38
    , {66, 33, 0}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    39
    , {66, 66, 66}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    40
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    41
    {66, 115, 49}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    42
    , {74, 33, 0}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    43
    , {74, 41, 16}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    44
    , {82, 33, 8}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    45
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    46
    {82, 41, 8}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    47
    , {82, 49, 16}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    48
    , {82, 82, 82}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    49
    , {90, 41, 8}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    50
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    51
    {90, 41, 16}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    52
    , {90, 57, 24}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    53
    , {99, 49, 16}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    54
    , {99, 66, 24}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    55
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    56
    {99, 66, 33}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    57
    , {99, 74, 33}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    58
    , {107, 57, 24}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    59
    , {107, 82, 41}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    60
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    61
    {115, 57, 33}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    62
    , {115, 66, 33}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    63
    , {115, 66, 41}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    64
    , {115, 74, 0}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    65
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    66
    {115, 90, 49}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    67
    , {115, 115, 115}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    68
    , {123, 82, 0}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    69
    , {123, 99, 57}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    70
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    71
    {132, 66, 41}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    72
    , {132, 74, 41}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    73
    , {132, 90, 8}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    74
    , {132, 99, 33}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    75
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    76
    {132, 99, 66}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    77
    , {132, 107, 66}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    78
    , {140, 74, 49}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    79
    , {140, 99, 16}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    80
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    81
    {140, 107, 74}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    82
    , {140, 115, 74}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    83
    , {148, 107, 24}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    84
    , {148, 115, 82}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    85
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    86
    {148, 123, 74}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    87
    , {148, 123, 90}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    88
    , {156, 115, 33}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    89
    , {156, 115, 90}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    90
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    91
    {156, 123, 82}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    92
    , {156, 132, 82}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    93
    , {156, 132, 99}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    94
    , {156, 156, 156}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    95
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    96
    {165, 123, 49}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    97
    , {165, 123, 90}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    98
    , {165, 132, 82}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
    99
    , {165, 132, 90}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   100
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   101
    {165, 132, 99}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   102
    , {165, 140, 90}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   103
    , {173, 132, 57}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   104
    , {173, 132, 99}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   105
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   106
    {173, 140, 107}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   107
    , {173, 140, 115}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   108
    , {173, 148, 99}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   109
    , {173, 173, 173}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   110
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   111
    {181, 140, 74}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   112
    , {181, 148, 115}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   113
    , {181, 148, 123}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   114
    , {181, 156, 107}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   115
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   116
    {189, 148, 123}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   117
    , {189, 156, 82}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   118
    , {189, 156, 123}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   119
    , {189, 156, 132}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   120
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   121
    {189, 189, 189}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   122
    , {198, 156, 123}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   123
    , {198, 165, 132}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   124
    , {206, 165, 99}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   125
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   126
    {206, 165, 132}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   127
    , {206, 173, 140}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   128
    , {206, 206, 206}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   129
    , {214, 173, 115}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   130
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   131
    {214, 173, 140}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   132
    , {222, 181, 148}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   133
    , {222, 189, 132}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   134
    , {222, 189, 156}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   135
    ,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   136
    {222, 222, 222}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   137
    , {231, 198, 165}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   138
    , {231, 231, 231}
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   139
    , {239, 206, 173}
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
};
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   142
Uint8 MooseFrame[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE*2];
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   143
SDL_Texture *MooseTexture;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   144
SDL_Rect displayrect;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   145
int window_w;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   146
int window_h;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   147
SDL_Window *window;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   148
SDL_Renderer *renderer;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   149
int paused = 0;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   150
int i;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   151
SDL_bool done = SDL_FALSE;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   152
Uint32 pixel_format = SDL_PIXELFORMAT_YV12;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   153
int fpsdelay;
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   154
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   155
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   156
static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   157
quit(int rc)
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   158
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   159
    SDL_Quit();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   160
    exit(rc);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   161
}
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   162
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
/* All RGB2YUV conversion code and some other parts of code has been taken from testoverlay.c */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
/* NOTE: These RGB conversion functions are not intended for speed,
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   166
         only as examples.
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
*/
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   169
void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   170
RGBtoYUV(Uint8 * rgb, int *yuv, int monochrome, int luminance)
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   172
    if (monochrome) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   173
#if 1                           /* these are the two formulas that I found on the FourCC site... */
4884
27ab20a36eba - added directx include path to VS2008 solution
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 2267
diff changeset
   174
        yuv[0] = (int)(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
        yuv[1] = 128;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
        yuv[2] = 128;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   177
#else
4884
27ab20a36eba - added directx include path to VS2008 solution
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 2267
diff changeset
   178
        yuv[0] = (int)(0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   179
        yuv[1] = 128;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   180
        yuv[2] = 128;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   181
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   182
    } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   183
#if 1                           /* these are the two formulas that I found on the FourCC site... */
4884
27ab20a36eba - added directx include path to VS2008 solution
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 2267
diff changeset
   184
        yuv[0] = (int)(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]);
27ab20a36eba - added directx include path to VS2008 solution
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 2267
diff changeset
   185
        yuv[1] = (int)((rgb[2] - yuv[0]) * 0.565 + 128);
27ab20a36eba - added directx include path to VS2008 solution
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 2267
diff changeset
   186
        yuv[2] = (int)((rgb[0] - yuv[0]) * 0.713 + 128);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
#else
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   188
        yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
        yuv[1] = 128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
        yuv[2] = 128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
#endif
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   192
    }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   193
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   194
    if (luminance != 100) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   195
        yuv[0] = yuv[0] * luminance / 100;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   196
        if (yuv[0] > 255)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   197
            yuv[0] = 255;
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
    }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   199
}
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   200
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   201
void
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   202
ConvertRGBtoYV12(Uint8 *rgb, Uint8 *out, int w, int h,
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   203
                 int monochrome, int luminance)
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   204
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   205
    int x, y;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   206
    int yuv[3];
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   207
    Uint8 *op[3];
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   208
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   209
    op[0] = out;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   210
    op[1] = op[0] + w*h;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   211
    op[2] = op[1] + w*h/4;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   212
    for (y = 0; y < h; ++y) {
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   213
        for (x = 0; x < w; ++x) {
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   214
            RGBtoYUV(rgb, yuv, monochrome, luminance);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   215
            *(op[0]++) = yuv[0];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   216
            if (x % 2 == 0 && y % 2 == 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   217
                *(op[1]++) = yuv[2];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   218
                *(op[2]++) = yuv[1];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   219
            }
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   220
            rgb += 3;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   221
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   222
    }
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   223
}
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   224
9046
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   225
void
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   226
ConvertRGBtoNV12(Uint8 *rgb, Uint8 *out, int w, int h,
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   227
                 int monochrome, int luminance)
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   228
{
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   229
    int x, y;
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   230
    int yuv[3];
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   231
    Uint8 *op[2];
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   232
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   233
    op[0] = out;
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   234
    op[1] = op[0] + w*h;
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   235
    for (y = 0; y < h; ++y) {
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   236
        for (x = 0; x < w; ++x) {
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   237
            RGBtoYUV(rgb, yuv, monochrome, luminance);
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   238
            *(op[0]++) = yuv[0];
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   239
            if (x % 2 == 0 && y % 2 == 0) {
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   240
                *(op[1]++) = yuv[1];
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   241
                *(op[1]++) = yuv[2];
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   242
            }
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   243
            rgb += 3;
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   244
        }
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   245
    }
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   246
}
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   247
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   248
static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   249
PrintUsage(char *argv0)
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
{
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   251
    SDL_Log("Usage: %s [arg] [arg] [arg] ...\n", argv0);
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   252
    SDL_Log("\n");
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   253
    SDL_Log("Where 'arg' is any of the following options:\n");
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   254
    SDL_Log("\n");
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   255
    SDL_Log("    -fps <frames per second>\n");
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   256
    SDL_Log("    -nodelay\n");
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   257
    SDL_Log("    -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   258
    SDL_Log("    -scale <scale factor> (initial scale of the overlay)\n");
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   259
    SDL_Log("    -help (shows this help)\n");
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   260
    SDL_Log("\n");
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   261
    SDL_Log("Press ESC to exit, or SPACE to freeze the movie while application running.\n");
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   262
    SDL_Log("\n");
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   263
}
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   264
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   265
void
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   266
loop()
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   267
{
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   268
    SDL_Event event;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   269
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   270
    while (SDL_PollEvent(&event)) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   271
        switch (event.type) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   272
        case SDL_WINDOWEVENT:
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   273
            if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   274
                SDL_RenderSetViewport(renderer, NULL);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   275
                displayrect.w = window_w = event.window.data1;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   276
                displayrect.h = window_h = event.window.data2;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   277
            }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   278
            break;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   279
        case SDL_MOUSEBUTTONDOWN:
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   280
            displayrect.x = event.button.x - window_w / 2;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   281
            displayrect.y = event.button.y - window_h / 2;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   282
            break;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   283
        case SDL_MOUSEMOTION:
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   284
            if (event.motion.state) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   285
                displayrect.x = event.motion.x - window_w / 2;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   286
                displayrect.y = event.motion.y - window_h / 2;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   287
            }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   288
            break;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   289
        case SDL_KEYDOWN:
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   290
            if (event.key.keysym.sym == SDLK_SPACE) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   291
                paused = !paused;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   292
                break;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   293
            }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   294
            if (event.key.keysym.sym != SDLK_ESCAPE) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   295
                break;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   296
            }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   297
        case SDL_QUIT:
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   298
            done = SDL_TRUE;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   299
            break;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   300
        }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   301
    }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   302
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   303
#ifndef __EMSCRIPTEN__
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   304
    SDL_Delay(fpsdelay);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   305
#endif
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   306
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   307
    if (!paused) {
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   308
        i = (i + 1) % MOOSEFRAMES_COUNT;
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   309
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   310
        SDL_UpdateTexture(MooseTexture, NULL, MooseFrame[i], MOOSEPIC_W*SDL_BYTESPERPIXEL(pixel_format));
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   311
    }
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   312
    SDL_RenderClear(renderer);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   313
    SDL_RenderCopy(renderer, MooseTexture, NULL, &displayrect);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   314
    SDL_RenderPresent(renderer);
9607
7746ab058d12 Added missing loop cancel for Emscripten in test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   315
7746ab058d12 Added missing loop cancel for Emscripten in test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   316
#ifdef __EMSCRIPTEN__
7746ab058d12 Added missing loop cancel for Emscripten in test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   317
    if (done) {
7746ab058d12 Added missing loop cancel for Emscripten in test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   318
        emscripten_cancel_main_loop();
7746ab058d12 Added missing loop cancel for Emscripten in test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   319
    }
7746ab058d12 Added missing loop cancel for Emscripten in test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 9278
diff changeset
   320
#endif
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   321
}
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   322
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   323
int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   324
main(int argc, char **argv)
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   325
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   326
    Uint8 *RawMooseData;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   327
    SDL_RWops *handle;
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   328
    SDL_Window *window;
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   329
    int j;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   330
    int fps = 12;
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   331
    int fpsdelay;
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   332
    int nodelay = 0;
9046
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   333
#ifdef TEST_NV12
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   334
    Uint32 pixel_format = SDL_PIXELFORMAT_NV12;
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   335
#else
5264
7ace5f8f432f Initial pass at shader YV12 support - doesn't quite work yet.
Sam Lantinga <slouken@libsdl.org>
parents: 5252
diff changeset
   336
    Uint32 pixel_format = SDL_PIXELFORMAT_YV12;
9046
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   337
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   338
    int scale = 5;
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   339
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   340
    /* Enable standard application logging */
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   341
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   342
7504
5a45a9536a65 Finished updating testoverlay2 for the new API and added it to the Visual Studio 2010 projects
Sam Lantinga <slouken@libsdl.org>
parents: 7478
diff changeset
   343
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   344
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   345
        return 3;
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   346
    }
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   347
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   348
    while (argc > 1) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   349
        if (strcmp(argv[1], "-fps") == 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   350
            if (argv[2]) {
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   351
                fps = atoi(argv[2]);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   352
                if (fps == 0) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   353
                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   354
                            "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   355
                    quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   356
                }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   357
                if ((fps < 0) || (fps > 1000)) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   358
                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   359
                            "The -fps option must be in range from 1 to 1000, default is 12.\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   360
                    quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   361
                }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   362
                argv += 2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   363
                argc -= 2;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   364
            } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   365
                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   366
                        "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   367
                quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   368
            }
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   369
        } else if (strcmp(argv[1], "-nodelay") == 0) {
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   370
            nodelay = 1;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   371
            argv += 1;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   372
            argc -= 1;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   373
        } else if (strcmp(argv[1], "-scale") == 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   374
            if (argv[2]) {
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   375
                scale = atoi(argv[2]);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   376
                if (scale == 0) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   377
                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   378
                            "The -scale option requires an argument [from 1 to 50], default is 5.\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   379
                    quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   380
                }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   381
                if ((scale < 0) || (scale > 50)) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   382
                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   383
                            "The -scale option must be in range from 1 to 50, default is 5.\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   384
                    quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   385
                }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   386
                argv += 2;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   387
                argc -= 2;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   388
            } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   389
                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   390
                        "The -fps option requires an argument [from 1 to 1000], default is 12.\n");
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   391
                quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   392
            }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   393
        } else if ((strcmp(argv[1], "-help") == 0)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   394
                   || (strcmp(argv[1], "-h") == 0)) {
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   395
            PrintUsage(argv[0]);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   396
            quit(0);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   397
        } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   398
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unrecognized option: %s.\n", argv[1]);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   399
            quit(10);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   400
        }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   401
        break;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   402
    }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   403
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   404
    RawMooseData = (Uint8 *) malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   405
    if (RawMooseData == NULL) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   406
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n");
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   407
        free(RawMooseData);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   408
        quit(1);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   409
    }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   410
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   411
    /* load the trojan moose images */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   412
    handle = SDL_RWFromFile("moose.dat", "rb");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   413
    if (handle == NULL) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   414
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   415
        free(RawMooseData);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   416
        quit(2);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   417
    }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   418
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   419
    SDL_RWread(handle, RawMooseData, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   420
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   421
    SDL_RWclose(handle);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   422
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   423
    /* Create the window and renderer */
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   424
    window_w = MOOSEPIC_W * scale;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   425
    window_h = MOOSEPIC_H * scale;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   426
    window = SDL_CreateWindow("Happy Moose",
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   427
                              SDL_WINDOWPOS_UNDEFINED,
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   428
                              SDL_WINDOWPOS_UNDEFINED,
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   429
                              window_w, window_h,
7478
0d02f6a323f5 Removed not needed SDL_WINDOW_SHOWN from test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 6256
diff changeset
   430
                              SDL_WINDOW_RESIZABLE);
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   431
    if (!window) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   432
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   433
        free(RawMooseData);
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   434
        quit(4);
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   435
    }
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   436
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   437
    renderer = SDL_CreateRenderer(window, -1, 0);
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   438
    if (!renderer) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   439
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   440
        free(RawMooseData);
1151
be9c9c8f6d53 Removed atexit() from most of the test programs; atexit(SDL_Quit) isn't safe
Ryan C. Gordon <icculus@icculus.org>
parents: 1030
diff changeset
   441
        quit(4);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   442
    }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   443
5264
7ace5f8f432f Initial pass at shader YV12 support - doesn't quite work yet.
Sam Lantinga <slouken@libsdl.org>
parents: 5252
diff changeset
   444
    MooseTexture = SDL_CreateTexture(renderer, pixel_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
5252
ec30f9d4c2a8 Fixed error check
Sam Lantinga <slouken@libsdl.org>
parents: 5216
diff changeset
   445
    if (!MooseTexture) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   446
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   447
        free(RawMooseData);
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   448
        quit(5);
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   449
    }
7504
5a45a9536a65 Finished updating testoverlay2 for the new API and added it to the Visual Studio 2010 projects
Sam Lantinga <slouken@libsdl.org>
parents: 7478
diff changeset
   450
    /* Uncomment this to check vertex color with a YUV texture */
7678
286c42d7c5ed OCD fixes: Adds a space after /* (glory to regular expressions!)
Gabriel Jacobo <gabomdq@gmail.com>
parents: 7677
diff changeset
   451
    /* SDL_SetTextureColorMod(MooseTexture, 0xff, 0x80, 0x80); */
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   452
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   453
    for (i = 0; i < MOOSEFRAMES_COUNT; i++) {
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   454
        Uint8 MooseFrameRGB[MOOSEFRAME_SIZE*3];
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   455
        Uint8 *rgb;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   456
        Uint8 *frame;
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   457
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   458
        rgb = MooseFrameRGB;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   459
        frame = RawMooseData + i * MOOSEFRAME_SIZE;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   460
        for (j = 0; j < MOOSEFRAME_SIZE; ++j) {
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   461
            rgb[0] = MooseColors[frame[j]].r;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   462
            rgb[1] = MooseColors[frame[j]].g;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   463
            rgb[2] = MooseColors[frame[j]].b;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   464
            rgb += 3;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1642
diff changeset
   465
        }
9046
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   466
        switch (pixel_format) {
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   467
        case SDL_PIXELFORMAT_YV12:
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   468
            ConvertRGBtoYV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100);
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   469
            break;
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   470
        case SDL_PIXELFORMAT_NV12:
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   471
            ConvertRGBtoNV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100);
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   472
            break;
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   473
        default:
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   474
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unsupported pixel format\n");
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   475
            break;
c3ec7c3e6c24 Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   476
        }
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   477
    }
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   478
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   479
    free(RawMooseData);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   480
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   481
    /* set the start frame */
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   482
    i = 0;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   483
    if (nodelay) {
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   484
        fpsdelay = 0;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   485
    } else {
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   486
        fpsdelay = 1000 / fps;
886
05c551e5bc64 Date: Sat, 24 Apr 2004 15:13:32 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 753
diff changeset
   487
    }
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   488
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   489
    displayrect.x = 0;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   490
    displayrect.y = 0;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   491
    displayrect.w = window_w;
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   492
    displayrect.h = window_h;
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   493
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   494
    /* Ignore key up events, they don't even get filtered */
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   495
    SDL_EventState(SDL_KEYUP, SDL_IGNORE);
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   496
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   497
    /* Loop, waiting for QUIT or RESIZE */
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   498
#ifdef __EMSCRIPTEN__
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   499
    emscripten_set_main_loop(loop, nodelay ? 0 : fps, 1);
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   500
#else
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   501
    while (!done) {
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   502
        loop();
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   503
            }
9278
8900afb78a19 Initial merge of Emscripten port!
Ryan C. Gordon <icculus@icculus.org>
parents: 9046
diff changeset
   504
#endif
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   505
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   506
    SDL_DestroyRenderer(renderer);
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   507
    quit(0);
672
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   508
    return 0;
5955fa16d4b8 Date: Mon, 28 Jul 2003 18:30:50 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   509
}
5216
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   510
16d5e8e90e01 Updated testoverlay2 to use the SDL 2D rendering API
Sam Lantinga <slouken@libsdl.org>
parents: 4884
diff changeset
   511
/* vi: set ts=4 sw=4 expandtab: */