Mercurial > sdl-ios-xcode
annotate test/teststreaming.c @ 5260:b0f5108fda60
Cleaned up the file a bit for tutorial viewing
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 11 Feb 2011 13:06:35 -0800 |
parents | f650566b2f51 |
children |
rev | line source |
---|---|
5259
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /******************************************************************************** |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 * * |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 * Running moose :) Coded by Mike Gorchak. * |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 * * |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 ********************************************************************************/ |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 #include "SDL.h" |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 #define MOOSEPIC_W 64 |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 #define MOOSEPIC_H 88 |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 #define MOOSEFRAME_SIZE (MOOSEPIC_W * MOOSEPIC_H) |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 #define MOOSEFRAMES_COUNT 10 |
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 SDL_Color MooseColors[84] = { |
5260
b0f5108fda60
Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents:
5259
diff
changeset
|
19 {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:
5259
diff
changeset
|
20 {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:
5259
diff
changeset
|
21 {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:
5259
diff
changeset
|
22 {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:
5259
diff
changeset
|
23 {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:
5259
diff
changeset
|
24 {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:
5259
diff
changeset
|
25 {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:
5259
diff
changeset
|
26 {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:
5259
diff
changeset
|
27 {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:
5259
diff
changeset
|
28 {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:
5259
diff
changeset
|
29 {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:
5259
diff
changeset
|
30 {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:
5259
diff
changeset
|
31 {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:
5259
diff
changeset
|
32 {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:
5259
diff
changeset
|
33 {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:
5259
diff
changeset
|
34 {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:
5259
diff
changeset
|
35 {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:
5259
diff
changeset
|
36 {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:
5259
diff
changeset
|
37 {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:
5259
diff
changeset
|
38 {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:
5259
diff
changeset
|
39 {222, 222, 222}, {231, 198, 165}, {231, 231, 231}, {239, 206, 173} |
5259
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 }; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 Uint8 MooseFrames[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE]; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 |
5260
b0f5108fda60
Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents:
5259
diff
changeset
|
44 void quit(int rc) |
5259
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 { |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 SDL_Quit(); |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 exit(rc); |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 } |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 |
5260
b0f5108fda60
Cleaned up the file a bit for tutorial viewing
Sam Lantinga <slouken@libsdl.org>
parents:
5259
diff
changeset
|
50 void UpdateTexture(SDL_Texture *texture, int frame) |
5259
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 SDL_Color *color; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 Uint8 *src; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 Uint32 *dst; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 int row, col; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 void *pixels; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 int pitch; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 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
|
60 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
|
61 quit(5); |
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 src = MooseFrames[frame]; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 for (row = 0; row < MOOSEPIC_H; ++row) { |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 dst = (Uint32*)((Uint8*)pixels + row * pitch); |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 for (col = 0; col < MOOSEPIC_W; ++col) { |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 color = &MooseColors[*src++]; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 *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
|
69 } |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 } |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 SDL_UnlockTexture(texture); |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 } |
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 int |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 main(int argc, char **argv) |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 { |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 SDL_Window *window; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 SDL_Renderer *renderer; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 SDL_RWops *handle; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 SDL_Texture *MooseTexture; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 SDL_Event event; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 SDL_bool done = SDL_FALSE; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 int frame; |
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 if (SDL_Init(SDL_INIT_VIDEO) < 0) { |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 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
|
87 return 1; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 } |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 /* load the moose images */ |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 handle = SDL_RWFromFile("moose.dat", "rb"); |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 if (handle == NULL) { |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 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
|
94 quit(2); |
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 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
|
97 SDL_RWclose(handle); |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
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 /* Create the window and renderer */ |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 window = SDL_CreateWindow("Happy Moose", |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 SDL_WINDOWPOS_UNDEFINED, |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 SDL_WINDOWPOS_UNDEFINED, |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 MOOSEPIC_W*4, MOOSEPIC_H*4, |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE); |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 if (!window) { |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 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
|
108 quit(3); |
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 renderer = SDL_CreateRenderer(window, -1, 0); |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 if (!renderer) { |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 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
|
114 quit(4); |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 } |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 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
|
118 if (!MooseTexture) { |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 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
|
120 quit(5); |
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 |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 /* 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
|
124 frame = 0; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 while (!done) { |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 while (SDL_PollEvent(&event)) { |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 switch (event.type) { |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 case SDL_KEYDOWN: |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 if (event.key.keysym.sym == SDLK_ESCAPE) { |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 done = SDL_TRUE; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 } |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 break; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 case SDL_QUIT: |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 done = SDL_TRUE; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 break; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 } |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 } |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 frame = (frame + 1) % MOOSEFRAMES_COUNT; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 UpdateTexture(MooseTexture, frame); |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 SDL_RenderClear(renderer); |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 SDL_RenderCopy(renderer, MooseTexture, NULL, NULL); |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 SDL_RenderPresent(renderer); |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 } |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 SDL_DestroyRenderer(renderer); |
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 quit(0); |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 return 0; |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 } |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 |
f650566b2f51
Added a very simple example of texture streaming
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 /* vi: set ts=4 sw=4 expandtab: */ |