Skip to content

Commit

Permalink
Run an update loop to refresh the display if the window is obscured f…
Browse files Browse the repository at this point in the history
…or some reason.

This fixes black screen on Linux in VMware
  • Loading branch information
slouken committed Jun 8, 2013
1 parent 4440f5c commit b544ad4
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions showimage.c
Expand Up @@ -117,16 +117,9 @@ int main(int argc, char *argv[])
SDL_SetWindowSize(window, w, h);
SDL_ShowWindow(window);

/* Draw a background pattern in case the image has transparency */
draw_background(renderer, w, h);

/* Display the image */
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);

done = 0;
while ( ! done ) {
if ( SDL_PollEvent(&event) ) {
while ( SDL_PollEvent(&event) ) {
switch (event.type) {
case SDL_KEYUP:
switch (event.key.keysym.sym) {
Expand Down Expand Up @@ -163,9 +156,15 @@ int main(int argc, char *argv[])
default:
break;
}
} else {
SDL_Delay(10);
}
/* Draw a background pattern in case the image has transparency */
draw_background(renderer, w, h);

/* Display the image */
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);

SDL_Delay(100);
}
SDL_DestroyTexture(texture);
}
Expand Down

0 comments on commit b544ad4

Please sign in to comment.