Clear the screen to actual black based on the format of the screen.
authorSam Lantinga <slouken@libsdl.org>
Fri, 28 Nov 2008 17:42:40 +0000
changeset 27969f6601537163
parent 2795 9e7ce3069096
child 2797 c81150fedf6f
Clear the screen to actual black based on the format of the screen.

Use a better texture format for YUV overlay software fallbacks
src/SDL_compat.c
     1.1 --- a/src/SDL_compat.c	Thu Nov 27 22:11:01 2008 +0000
     1.2 +++ b/src/SDL_compat.c	Fri Nov 28 17:42:40 2008 +0000
     1.3 @@ -371,6 +371,7 @@
     1.4      Uint32 desktop_format;
     1.5      Uint32 desired_format;
     1.6      Uint32 surface_flags;
     1.7 +    Uint32 black;
     1.8  
     1.9      if (!SDL_GetVideoDevice()) {
    1.10          if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) {
    1.11 @@ -580,7 +581,8 @@
    1.12          (SDL_ShadowSurface ? SDL_ShadowSurface : SDL_VideoSurface);
    1.13  
    1.14      /* Clear the surface for display */
    1.15 -    SDL_FillRect(SDL_PublicSurface, NULL, 0);
    1.16 +    black = SDL_MapRGB(SDL_PublicSurface->format, 0, 0, 0);
    1.17 +    SDL_FillRect(SDL_PublicSurface, NULL, black);
    1.18      SDL_UpdateRect(SDL_PublicSurface, 0, 0, 0, 0);
    1.19  
    1.20      /* We're finally done! */
    1.21 @@ -1437,6 +1439,8 @@
    1.22      if (overlay->hwdata->textureID) {
    1.23          overlay->hwdata->sw = NULL;
    1.24      } else {
    1.25 +        SDL_DisplayMode current_mode;
    1.26 +
    1.27          overlay->hwdata->sw = SDL_SW_CreateYUVTexture(texture_format, w, h);
    1.28          if (!overlay->hwdata->sw) {
    1.29              SDL_FreeYUVOverlay(overlay);
    1.30 @@ -1444,8 +1448,9 @@
    1.31          }
    1.32  
    1.33          /* Create a supported RGB format texture for display */
    1.34 +        SDL_GetCurrentDisplayMode(&current_mode);
    1.35          overlay->hwdata->textureID =
    1.36 -            SDL_CreateTexture(SDL_PIXELFORMAT_RGB888,
    1.37 +            SDL_CreateTexture(current_mode.format,
    1.38                                SDL_TEXTUREACCESS_STREAMING, w, h);
    1.39      }
    1.40      if (!overlay->hwdata->textureID) {