mirror of https://github.com/encounter/SDL.git
Fixed ignoring first event in testshape program.
Found by Cppcheck.
This commit is contained in:
parent
456bc301d9
commit
cb591ee611
|
@ -48,7 +48,6 @@ int main(int argc,char** argv)
|
||||||
SDL_Renderer *renderer;
|
SDL_Renderer *renderer;
|
||||||
SDL_Color black = {0,0,0,0xff};
|
SDL_Color black = {0,0,0,0xff};
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
int event_pending = 0;
|
|
||||||
int should_exit = 0;
|
int should_exit = 0;
|
||||||
unsigned int current_picture;
|
unsigned int current_picture;
|
||||||
int button_down;
|
int button_down;
|
||||||
|
@ -143,9 +142,7 @@ int main(int argc,char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event_pending = 0;
|
|
||||||
should_exit = 0;
|
should_exit = 0;
|
||||||
event_pending = SDL_PollEvent(&event);
|
|
||||||
current_picture = 0;
|
current_picture = 0;
|
||||||
button_down = 0;
|
button_down = 0;
|
||||||
texture_dimensions.h = 0;
|
texture_dimensions.h = 0;
|
||||||
|
@ -157,8 +154,7 @@ int main(int argc,char** argv)
|
||||||
SDL_SetWindowSize(window,texture_dimensions.w,texture_dimensions.h);
|
SDL_SetWindowSize(window,texture_dimensions.w,texture_dimensions.h);
|
||||||
SDL_SetWindowShape(window,pictures[current_picture].surface,&pictures[current_picture].mode);
|
SDL_SetWindowShape(window,pictures[current_picture].surface,&pictures[current_picture].mode);
|
||||||
while(should_exit == 0) {
|
while(should_exit == 0) {
|
||||||
event_pending = SDL_PollEvent(&event);
|
if (SDL_PollEvent(&event)) {
|
||||||
if(event_pending == 1) {
|
|
||||||
if(event.type == SDL_KEYDOWN) {
|
if(event.type == SDL_KEYDOWN) {
|
||||||
button_down = 1;
|
button_down = 1;
|
||||||
if(event.key.keysym.sym == SDLK_ESCAPE) {
|
if(event.key.keysym.sym == SDLK_ESCAPE) {
|
||||||
|
@ -178,7 +174,6 @@ int main(int argc,char** argv)
|
||||||
}
|
}
|
||||||
if(event.type == SDL_QUIT)
|
if(event.type == SDL_QUIT)
|
||||||
should_exit = 1;
|
should_exit = 1;
|
||||||
event_pending = 0;
|
|
||||||
}
|
}
|
||||||
render(renderer,pictures[current_picture].texture,texture_dimensions);
|
render(renderer,pictures[current_picture].texture,texture_dimensions);
|
||||||
SDL_Delay(10);
|
SDL_Delay(10);
|
||||||
|
|
Loading…
Reference in New Issue