diff src/video/SDL_video.c @ 1669:9857d21967bb SDL-1.3

The test programs compile again. The dummy video driver is partially functional now.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 05:08:33 +0000
parents 4da1ee79c9af
children eef792d31de8
line wrap: on
line diff
--- a/src/video/SDL_video.c	Mon May 29 04:04:35 2006 +0000
+++ b/src/video/SDL_video.c	Mon May 29 05:08:33 2006 +0000
@@ -233,6 +233,7 @@
     _this->name = bootstrap[i]->name;
     _this->next_window_id = 1;
 
+
     /* Set some very sane GL defaults */
     _this->gl_config.driver_loaded = 0;
     _this->gl_config.dll_handle = NULL;
@@ -267,6 +268,16 @@
         return (-1);
     }
 
+    /* Temporarily here for backwards compatibility */
+    {
+        int bpp;
+        Uint32 Rmask, Gmask, Bmask, Amask;
+
+        SDL_PixelFormatEnumToMasks(SDL_GetDesktopDisplayMode()->format, &bpp,
+                                   &Rmask, &Gmask, &Bmask, &Amask);
+        _this->info.vfmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
+    }
+
     /* Sort the video modes */
     for (i = 0; i < _this->num_displays; ++i) {
         SDL_qsort(_this->displays[i].display_modes,
@@ -325,7 +336,7 @@
 }
 
 void
-SDL_AddVideoDisplay(SDL_VideoDisplay * display)
+SDL_AddVideoDisplay(const SDL_VideoDisplay * display)
 {
     SDL_VideoDisplay *displays;
 
@@ -1034,6 +1045,14 @@
             return NULL;
         }
         window->surface->flags |= SDL_SCREEN_SURFACE;
+
+        /* If we have a palettized surface, create a default palette */
+        if (window->surface->format->palette) {
+            SDL_Color colors[256];
+            SDL_PixelFormat *vf = window->surface->format;
+            SDL_DitherColors(colors, vf->BitsPerPixel);
+            SDL_SetColors(window->surface, colors, 0, vf->palette->ncolors);
+        }
     }
     surface = window->surface;
 
@@ -1059,6 +1078,7 @@
             return NULL;
         }
         window->shadow->flags |= SDL_SHADOW_SURFACE;
+
         surface = window->shadow;
 
         /* 8-bit shadow surfaces report that they have exclusive palette */
@@ -1401,6 +1421,7 @@
     if (_this->displays) {
         SDL_free(_this->displays);
     }
+    SDL_free(_this->info.vfmt);
     _this->free(_this);
     _this = NULL;
 }