test/teststreaming.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Sat, 20 Jul 2013 21:47:16 +0200
changeset 7478 0d02f6a323f5
parent 5535 96594ac5fd1a
child 7517 965d57022c01
permissions -rw-r--r--
Removed not needed SDL_WINDOW_SHOWN from test programs. See bug #1667.
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: 5255
diff changeset
     1
/*
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5255
diff changeset
     2
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5255
diff changeset
     3
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5255
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: 5255
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: 5255
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: 5255
diff changeset
     7
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5255
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: 5255
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: 5255
diff changeset
    10
  freely.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5255
diff changeset
    11
*/
5254
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
/********************************************************************************
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
 *                                                                              *
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
 * Running moose :) Coded by Mike Gorchak.                                      *
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
 *                                                                              *
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
 ********************************************************************************/
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
#include <stdlib.h>
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
#include <stdio.h>
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
#include "SDL.h"
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
#define MOOSEPIC_W 64
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
#define MOOSEPIC_H 88
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
#define MOOSEFRAME_SIZE (MOOSEPIC_W * MOOSEPIC_H)
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
#define MOOSEFRAMES_COUNT 10
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
SDL_Color MooseColors[84] = {
5255
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    30
    {49, 49, 49}, {66, 24, 0}, {66, 33, 0}, {66, 66, 66},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    31
    {66, 115, 49}, {74, 33, 0}, {74, 41, 16}, {82, 33, 8},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    32
    {82, 41, 8}, {82, 49, 16}, {82, 82, 82}, {90, 41, 8},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    33
    {90, 41, 16}, {90, 57, 24}, {99, 49, 16}, {99, 66, 24},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    34
    {99, 66, 33}, {99, 74, 33}, {107, 57, 24}, {107, 82, 41},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    35
    {115, 57, 33}, {115, 66, 33}, {115, 66, 41}, {115, 74, 0},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    36
    {115, 90, 49}, {115, 115, 115}, {123, 82, 0}, {123, 99, 57},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    37
    {132, 66, 41}, {132, 74, 41}, {132, 90, 8}, {132, 99, 33},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    38
    {132, 99, 66}, {132, 107, 66}, {140, 74, 49}, {140, 99, 16},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    39
    {140, 107, 74}, {140, 115, 74}, {148, 107, 24}, {148, 115, 82},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    40
    {148, 123, 74}, {148, 123, 90}, {156, 115, 33}, {156, 115, 90},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    41
    {156, 123, 82}, {156, 132, 82}, {156, 132, 99}, {156, 156, 156},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    42
    {165, 123, 49}, {165, 123, 90}, {165, 132, 82}, {165, 132, 90},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    43
    {165, 132, 99}, {165, 140, 90}, {173, 132, 57}, {173, 132, 99},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    44
    {173, 140, 107}, {173, 140, 115}, {173, 148, 99}, {173, 173, 173},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    45
    {181, 140, 74}, {181, 148, 115}, {181, 148, 123}, {181, 156, 107},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    46
    {189, 148, 123}, {189, 156, 82}, {189, 156, 123}, {189, 156, 132},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    47
    {189, 189, 189}, {198, 156, 123}, {198, 165, 132}, {206, 165, 99},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    48
    {206, 165, 132}, {206, 173, 140}, {206, 206, 206}, {214, 173, 115},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    49
    {214, 173, 140}, {222, 181, 148}, {222, 189, 132}, {222, 189, 156},
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    50
    {222, 222, 222}, {231, 198, 165}, {231, 231, 231}, {239, 206, 173}
5254
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
};
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
Uint8 MooseFrames[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE];
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
5255
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    55
void quit(int rc)
5254
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
{
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
    SDL_Quit();
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
    exit(rc);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
}
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
5255
b0f5108fda60 Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents: 5254
diff changeset
    61
void UpdateTexture(SDL_Texture *texture, int frame)
5254
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
{
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
    SDL_Color *color;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
    Uint8 *src;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
    Uint32 *dst;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
    int row, col;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
    void *pixels;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
    int pitch;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
    if (SDL_LockTexture(texture, NULL, &pixels, &pitch) < 0) {
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
        fprintf(stderr, "Couldn't lock texture: %s\n", SDL_GetError());
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
        quit(5);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
    }
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
    src = MooseFrames[frame];
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
    for (row = 0; row < MOOSEPIC_H; ++row) {
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
        dst = (Uint32*)((Uint8*)pixels + row * pitch);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
        for (col = 0; col < MOOSEPIC_W; ++col) {
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
            color = &MooseColors[*src++];
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
            *dst++ = (0xFF000000|(color->r<<16)|(color->g<<8)|color->b);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
        }
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
    }
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
    SDL_UnlockTexture(texture);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
}
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
int
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
main(int argc, char **argv)
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
{
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
    SDL_Window *window;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
    SDL_Renderer *renderer;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
    SDL_RWops *handle;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
    SDL_Texture *MooseTexture;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
    SDL_Event event;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
    SDL_bool done = SDL_FALSE;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
    int frame;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
        return 1;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
    }
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
    /* load the moose images */
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
    handle = SDL_RWFromFile("moose.dat", "rb");
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
    if (handle == NULL) {
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
        fprintf(stderr, "Can't find the file moose.dat !\n");
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
        quit(2);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
    }
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
    SDL_RWread(handle, MooseFrames, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
    SDL_RWclose(handle);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
    /* Create the window and renderer */
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
    window = SDL_CreateWindow("Happy Moose",
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
                              SDL_WINDOWPOS_UNDEFINED,
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
                              SDL_WINDOWPOS_UNDEFINED,
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
                              MOOSEPIC_W*4, MOOSEPIC_H*4,
7478
0d02f6a323f5 Removed not needed SDL_WINDOW_SHOWN from test programs.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 5535
diff changeset
   116
                              SDL_WINDOW_RESIZABLE);
5254
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
    if (!window) {
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
        fprintf(stderr, "Couldn't set create window: %s\n", SDL_GetError());
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
        quit(3);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
    }
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
    renderer = SDL_CreateRenderer(window, -1, 0);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
    if (!renderer) {
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
        fprintf(stderr, "Couldn't set create renderer: %s\n", SDL_GetError());
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
        quit(4);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
    }
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
    MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
    if (!MooseTexture) {
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
        fprintf(stderr, "Couldn't set create texture: %s\n", SDL_GetError());
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
        quit(5);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
    }
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
    /* Loop, waiting for QUIT or the escape key */
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
    frame = 0;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
    while (!done) {
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
        while (SDL_PollEvent(&event)) {
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
            switch (event.type) {
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
            case SDL_KEYDOWN:
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
                if (event.key.keysym.sym == SDLK_ESCAPE) {
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
                    done = SDL_TRUE;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
                }
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
                break;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
            case SDL_QUIT:
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
                done = SDL_TRUE;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
                break;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
            }
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
        }
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
        frame = (frame + 1) % MOOSEFRAMES_COUNT;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
        UpdateTexture(MooseTexture, frame);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
        SDL_RenderClear(renderer);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
        SDL_RenderCopy(renderer, MooseTexture, NULL, NULL);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
        SDL_RenderPresent(renderer);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
    }
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
    SDL_DestroyRenderer(renderer);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
    quit(0);
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
    return 0;
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
}
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
f650566b2f51 Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
/* vi: set ts=4 sw=4 expandtab: */