comparison 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
comparison
equal deleted inserted replaced
1668:4da1ee79c9af 1669:9857d21967bb
230 return -1; 230 return -1;
231 } 231 }
232 _this = video; 232 _this = video;
233 _this->name = bootstrap[i]->name; 233 _this->name = bootstrap[i]->name;
234 _this->next_window_id = 1; 234 _this->next_window_id = 1;
235
235 236
236 /* Set some very sane GL defaults */ 237 /* Set some very sane GL defaults */
237 _this->gl_config.driver_loaded = 0; 238 _this->gl_config.driver_loaded = 0;
238 _this->gl_config.dll_handle = NULL; 239 _this->gl_config.dll_handle = NULL;
239 _this->gl_config.red_size = 3; 240 _this->gl_config.red_size = 3;
265 SDL_SetError("The video driver did not add any displays"); 266 SDL_SetError("The video driver did not add any displays");
266 SDL_VideoQuit(); 267 SDL_VideoQuit();
267 return (-1); 268 return (-1);
268 } 269 }
269 270
271 /* Temporarily here for backwards compatibility */
272 {
273 int bpp;
274 Uint32 Rmask, Gmask, Bmask, Amask;
275
276 SDL_PixelFormatEnumToMasks(SDL_GetDesktopDisplayMode()->format, &bpp,
277 &Rmask, &Gmask, &Bmask, &Amask);
278 _this->info.vfmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
279 }
280
270 /* Sort the video modes */ 281 /* Sort the video modes */
271 for (i = 0; i < _this->num_displays; ++i) { 282 for (i = 0; i < _this->num_displays; ++i) {
272 SDL_qsort(_this->displays[i].display_modes, 283 SDL_qsort(_this->displays[i].display_modes,
273 _this->displays[i].num_display_modes, 284 _this->displays[i].num_display_modes,
274 sizeof(SDL_DisplayMode), cmpmodes); 285 sizeof(SDL_DisplayMode), cmpmodes);
323 334
324 SDL_AddVideoDisplay(&display); 335 SDL_AddVideoDisplay(&display);
325 } 336 }
326 337
327 void 338 void
328 SDL_AddVideoDisplay(SDL_VideoDisplay * display) 339 SDL_AddVideoDisplay(const SDL_VideoDisplay * display)
329 { 340 {
330 SDL_VideoDisplay *displays; 341 SDL_VideoDisplay *displays;
331 342
332 displays = 343 displays =
333 SDL_realloc(_this->displays, 344 SDL_realloc(_this->displays,
1032 _this->CreateWindowSurface(_this, window, flags); 1043 _this->CreateWindowSurface(_this, window, flags);
1033 if (!window->surface) { 1044 if (!window->surface) {
1034 return NULL; 1045 return NULL;
1035 } 1046 }
1036 window->surface->flags |= SDL_SCREEN_SURFACE; 1047 window->surface->flags |= SDL_SCREEN_SURFACE;
1048
1049 /* If we have a palettized surface, create a default palette */
1050 if (window->surface->format->palette) {
1051 SDL_Color colors[256];
1052 SDL_PixelFormat *vf = window->surface->format;
1053 SDL_DitherColors(colors, vf->BitsPerPixel);
1054 SDL_SetColors(window->surface, colors, 0, vf->palette->ncolors);
1055 }
1037 } 1056 }
1038 surface = window->surface; 1057 surface = window->surface;
1039 1058
1040 if (window->shadow) { 1059 if (window->shadow) {
1041 SDL_FreeSurface(window->shadow); 1060 SDL_FreeSurface(window->shadow);
1057 Rmask, Gmask, Bmask, Amask); 1076 Rmask, Gmask, Bmask, Amask);
1058 if (window->shadow == NULL) { 1077 if (window->shadow == NULL) {
1059 return NULL; 1078 return NULL;
1060 } 1079 }
1061 window->shadow->flags |= SDL_SHADOW_SURFACE; 1080 window->shadow->flags |= SDL_SHADOW_SURFACE;
1081
1062 surface = window->shadow; 1082 surface = window->shadow;
1063 1083
1064 /* 8-bit shadow surfaces report that they have exclusive palette */ 1084 /* 8-bit shadow surfaces report that they have exclusive palette */
1065 if (surface->format->palette) { 1085 if (surface->format->palette) {
1066 surface->flags |= SDL_HWPALETTE; 1086 surface->flags |= SDL_HWPALETTE;
1399 } 1419 }
1400 _this->VideoQuit(_this); 1420 _this->VideoQuit(_this);
1401 if (_this->displays) { 1421 if (_this->displays) {
1402 SDL_free(_this->displays); 1422 SDL_free(_this->displays);
1403 } 1423 }
1424 SDL_free(_this->info.vfmt);
1404 _this->free(_this); 1425 _this->free(_this);
1405 _this = NULL; 1426 _this = NULL;
1406 } 1427 }
1407 1428
1408 /* Load the GL driver library */ 1429 /* Load the GL driver library */