comparison src/video/SDL_video.c @ 3500:4b594623401b

Work in progress on multi-display support: * Added display parameter to many internal functions so video modes can be set on displays that aren't the public current one. * The fullscreen mode is associated with fullscreen windows - not displays, so different windows more naturally have a mode associated with them based on their width and height. It's no longer necessary to specify a fullscreen mode, a default one will be picked automatically for fullscreen windows.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 01 Dec 2009 05:57:15 +0000
parents e1bd98b56e94
children 467e67d301f3
comparison
equal deleted inserted replaced
3499:4cf8a1423d57 3500:4b594623401b
254 SDL_VideoQuit(); 254 SDL_VideoQuit();
255 return (-1); 255 return (-1);
256 } 256 }
257 /* The software renderer is always available */ 257 /* The software renderer is always available */
258 for (i = 0; i < _this->num_displays; ++i) { 258 for (i = 0; i < _this->num_displays; ++i) {
259 SDL_VideoDisplay *display = &_this->displays[i];
259 if (_this->GL_CreateContext) { 260 if (_this->GL_CreateContext) {
260 #if SDL_VIDEO_RENDER_OGL 261 #if SDL_VIDEO_RENDER_OGL
261 SDL_AddRenderDriver(i, &GL_RenderDriver); 262 SDL_AddRenderDriver(display, &GL_RenderDriver);
262 #endif 263 #endif
263 #if SDL_VIDEO_RENDER_OGL_ES 264 #if SDL_VIDEO_RENDER_OGL_ES
264 SDL_AddRenderDriver(i, &GL_ES_RenderDriver); 265 SDL_AddRenderDriver(display, &GL_ES_RenderDriver);
265 #endif 266 #endif
266 } 267 }
267 if (_this->displays[i].num_render_drivers > 0) { 268 if (display->num_render_drivers > 0) {
268 SDL_AddRenderDriver(i, &SW_RenderDriver); 269 SDL_AddRenderDriver(display, &SW_RenderDriver);
269 } 270 }
270 } 271 }
271 272
272 /* We're ready to go! */ 273 /* We're ready to go! */
273 return 0; 274 return 0;
358 } 359 }
359 return _this->current_display; 360 return _this->current_display;
360 } 361 }
361 362
362 SDL_bool 363 SDL_bool
363 SDL_AddDisplayMode(int displayIndex, const SDL_DisplayMode * mode) 364 SDL_AddDisplayMode(SDL_VideoDisplay * display, const SDL_DisplayMode * mode)
364 { 365 {
365 SDL_VideoDisplay *display = &_this->displays[displayIndex];
366 SDL_DisplayMode *modes; 366 SDL_DisplayMode *modes;
367 int i, nmodes; 367 int i, nmodes;
368 368
369 /* Make sure we don't already have the mode in the list */ 369 /* Make sure we don't already have the mode in the list */
370 modes = display->display_modes; 370 modes = display->display_modes;
395 395
396 return SDL_TRUE; 396 return SDL_TRUE;
397 } 397 }
398 398
399 int 399 int
400 SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display)
401 {
402 if (!display->num_display_modes && _this->GetDisplayModes) {
403 _this->GetDisplayModes(_this, display);
404 SDL_qsort(display->display_modes, display->num_display_modes,
405 sizeof(SDL_DisplayMode), cmpmodes);
406 }
407 return display->num_display_modes;
408 }
409
410 int
400 SDL_GetNumDisplayModes() 411 SDL_GetNumDisplayModes()
401 { 412 {
402 if (_this) { 413 if (_this) {
403 SDL_VideoDisplay *display = &SDL_CurrentDisplay; 414 return SDL_GetNumDisplayModesForDisplay(&SDL_CurrentDisplay);
404 if (!display->num_display_modes && _this->GetDisplayModes) {
405 _this->GetDisplayModes(_this);
406 SDL_qsort(display->display_modes, display->num_display_modes,
407 sizeof(SDL_DisplayMode), cmpmodes);
408 }
409 return display->num_display_modes;
410 } 415 }
411 return 0; 416 return 0;
412 } 417 }
413 418
414 int 419 int
420 SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayMode * mode)
421 {
422 if (index < 0 || index >= SDL_GetNumDisplayModesForDisplay(display)) {
423 SDL_SetError("index must be in the range of 0 - %d",
424 SDL_GetNumDisplayModesForDisplay(display) - 1);
425 return -1;
426 }
427 if (mode) {
428 *mode = display->display_modes[index];
429 }
430 return 0;
431 }
432
433 int
415 SDL_GetDisplayMode(int index, SDL_DisplayMode * mode) 434 SDL_GetDisplayMode(int index, SDL_DisplayMode * mode)
416 { 435 {
417 if (index < 0 || index >= SDL_GetNumDisplayModes()) { 436 return SDL_GetDisplayModeForDisplay(&SDL_CurrentDisplay, index, mode);
418 SDL_SetError("index must be in the range of 0 - %d", 437 }
419 SDL_GetNumDisplayModes() - 1); 438
420 return -1; 439 int
421 } 440 SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode)
441 {
422 if (mode) { 442 if (mode) {
423 *mode = SDL_CurrentDisplay.display_modes[index]; 443 *mode = display->desktop_mode;
424 } 444 }
425 return 0; 445 return 0;
426 } 446 }
427 447
428 int 448 int
430 { 450 {
431 if (!_this) { 451 if (!_this) {
432 SDL_UninitializedVideo(); 452 SDL_UninitializedVideo();
433 return -1; 453 return -1;
434 } 454 }
455 return SDL_GetDesktopDisplayModeForDisplay(&SDL_CurrentDisplay, mode);
456 }
457
458 int
459 SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode)
460 {
435 if (mode) { 461 if (mode) {
436 *mode = SDL_CurrentDisplay.desktop_mode; 462 *mode = display->current_mode;
437 } 463 }
438 return 0; 464 return 0;
439 } 465 }
440 466
441 int 467 int
443 { 469 {
444 if (!_this) { 470 if (!_this) {
445 SDL_UninitializedVideo(); 471 SDL_UninitializedVideo();
446 return -1; 472 return -1;
447 } 473 }
448 if (mode) { 474 return SDL_GetCurrentDisplayModeForDisplay(&SDL_CurrentDisplay, mode);
449 *mode = SDL_CurrentDisplay.current_mode;
450 }
451 return 0;
452 } 475 }
453 476
454 SDL_DisplayMode * 477 SDL_DisplayMode *
455 SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode, 478 SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display,
456 SDL_DisplayMode * closest) 479 const SDL_DisplayMode * mode,
480 SDL_DisplayMode * closest)
457 { 481 {
458 Uint32 target_format; 482 Uint32 target_format;
459 int target_refresh_rate; 483 int target_refresh_rate;
460 int i; 484 int i;
461 SDL_DisplayMode *current, *match; 485 SDL_DisplayMode *current, *match;
462 486
463 if (!_this || !mode || !closest) { 487 if (!mode || !closest) {
488 SDL_SetError("Missing desired mode or closest mode parameter");
464 return NULL; 489 return NULL;
465 } 490 }
491
466 /* Default to the desktop format */ 492 /* Default to the desktop format */
467 if (mode->format) { 493 if (mode->format) {
468 target_format = mode->format; 494 target_format = mode->format;
469 } else { 495 } else {
470 target_format = SDL_CurrentDisplay.desktop_mode.format; 496 target_format = display->desktop_mode.format;
471 } 497 }
472 498
473 /* Default to the desktop refresh rate */ 499 /* Default to the desktop refresh rate */
474 if (mode->refresh_rate) { 500 if (mode->refresh_rate) {
475 target_refresh_rate = mode->refresh_rate; 501 target_refresh_rate = mode->refresh_rate;
476 } else { 502 } else {
477 target_refresh_rate = SDL_CurrentDisplay.desktop_mode.refresh_rate; 503 target_refresh_rate = display->desktop_mode.refresh_rate;
478 } 504 }
479 505
480 match = NULL; 506 match = NULL;
481 for (i = 0; i < SDL_GetNumDisplayModes(); ++i) { 507 for (i = 0; i < SDL_GetNumDisplayModesForDisplay(display); ++i) {
482 current = &SDL_CurrentDisplay.display_modes[i]; 508 current = &display->display_modes[i];
483 509
484 if (current->w && (current->w < mode->w)) { 510 if (current->w && (current->w < mode->w)) {
485 /* Out of sorted modes large enough here */ 511 /* Out of sorted modes large enough here */
486 break; 512 break;
487 } 513 }
553 return closest; 579 return closest;
554 } 580 }
555 return NULL; 581 return NULL;
556 } 582 }
557 583
558 int 584 SDL_DisplayMode *
559 SDL_SetDisplayMode(const SDL_DisplayMode * mode) 585 SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode,
560 { 586 SDL_DisplayMode * closest)
561 SDL_VideoDisplay *display; 587 {
588 if (!_this) {
589 SDL_UninitializedVideo();
590 return NULL;
591 }
592 return SDL_GetClosestDisplayModeForDisplay(&SDL_CurrentDisplay, mode, closest);
593 }
594
595 int
596 SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode)
597 {
562 SDL_DisplayMode display_mode; 598 SDL_DisplayMode display_mode;
563 SDL_DisplayMode current_mode; 599 SDL_DisplayMode current_mode;
564 int i, ncolors; 600 int i, ncolors;
565 601
566 if (!_this) {
567 SDL_UninitializedVideo();
568 return -1;
569 }
570 display = &SDL_CurrentDisplay;
571 if (!mode) { 602 if (!mode) {
572 mode = &display->desktop_mode; 603 mode = &display->desktop_mode;
573 } 604 }
574 display_mode = *mode; 605 display_mode = *mode;
575 606
584 display_mode.h = display->current_mode.h; 615 display_mode.h = display->current_mode.h;
585 } 616 }
586 if (!display_mode.refresh_rate) { 617 if (!display_mode.refresh_rate) {
587 display_mode.refresh_rate = display->current_mode.refresh_rate; 618 display_mode.refresh_rate = display->current_mode.refresh_rate;
588 } 619 }
620
589 /* Get a good video mode, the closest one possible */ 621 /* Get a good video mode, the closest one possible */
590 if (!SDL_GetClosestDisplayMode(&display_mode, &display_mode)) { 622 if (!SDL_GetClosestDisplayModeForDisplay(display, &display_mode, &display_mode)) {
591 SDL_SetError("No video mode large enough for %dx%d", 623 SDL_SetError("No video mode large enough for %dx%d",
592 display_mode.w, display_mode.h); 624 display_mode.w, display_mode.h);
593 return -1; 625 return -1;
594 } 626 }
627
595 /* See if there's anything left to do */ 628 /* See if there's anything left to do */
596 SDL_GetCurrentDisplayMode(&current_mode); 629 SDL_GetCurrentDisplayModeForDisplay(display, &current_mode);
597 if (SDL_memcmp(&display_mode, &current_mode, sizeof(display_mode)) == 0) { 630 if (SDL_memcmp(&display_mode, &current_mode, sizeof(display_mode)) == 0) {
598 return 0; 631 return 0;
599 } 632 }
633
600 /* Actually change the display mode */ 634 /* Actually change the display mode */
601 if (_this->SetDisplayMode(_this, &display_mode) < 0) { 635 if (_this->SetDisplayMode(_this, display, &display_mode) < 0) {
602 return -1; 636 return -1;
603 } 637 }
604 display->current_mode = display_mode; 638 display->current_mode = display_mode;
605 639
606 /* Set up a palette, if necessary */ 640 /* Set up a palette, if necessary */
622 } 656 }
623 SDL_DitherColors(display->palette->colors, 657 SDL_DitherColors(display->palette->colors,
624 SDL_BITSPERPIXEL(display_mode.format)); 658 SDL_BITSPERPIXEL(display_mode.format));
625 } 659 }
626 } 660 }
627 /* Move any fullscreen windows into position */
628 for (i = 0; i < display->num_windows; ++i) {
629 SDL_Window *window = &display->windows[i];
630 if (FULLSCREEN_VISIBLE(window)) {
631 SDL_SetWindowPosition(window->id, window->x, window->y);
632 }
633 }
634 661
635 return 0; 662 return 0;
636 } 663 }
637 664
638 int 665 int
639 SDL_SetFullscreenDisplayMode(const SDL_DisplayMode * mode) 666 SDL_SetDisplayMode(const SDL_DisplayMode * mode)
640 { 667 {
641 SDL_VideoDisplay *display;
642 SDL_DisplayMode fullscreen_mode;
643 int i;
644
645 if (!_this) { 668 if (!_this) {
646 SDL_UninitializedVideo(); 669 SDL_UninitializedVideo();
647 return -1; 670 return -1;
648 } 671 }
649 display = &SDL_CurrentDisplay; 672 return SDL_SetDisplayModeForDisplay(&SDL_CurrentDisplay, mode);
650 if (!mode) { 673 }
651 mode = &display->desktop_mode; 674
652 } 675 int
653 if (!SDL_GetClosestDisplayMode(mode, &fullscreen_mode)) { 676 SDL_SetWindowDisplayMode(SDL_WindowID windowID, const SDL_DisplayMode * mode)
677 {
678 SDL_Window *window = SDL_GetWindowFromID(windowID);
679
680 if (!window) {
681 return -1;
682 }
683
684 if (mode) {
685 window->fullscreen_mode = *mode;
686 } else {
687 SDL_zero(window->fullscreen_mode);
688 }
689 }
690
691 int
692 SDL_GetWindowDisplayMode(SDL_WindowID windowID, SDL_DisplayMode * mode)
693 {
694 SDL_Window *window = SDL_GetWindowFromID(windowID);
695 SDL_DisplayMode fullscreen_mode;
696
697 if (!window) {
698 return -1;
699 }
700
701 fullscreen_mode = window->fullscreen_mode;
702 if (!fullscreen_mode.w) {
703 fullscreen_mode.w = window->w;
704 }
705 if (!fullscreen_mode.h) {
706 fullscreen_mode.h = window->h;
707 }
708
709 if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayFromWindow(window),
710 &fullscreen_mode,
711 &fullscreen_mode)) {
654 SDL_SetError("Couldn't find display mode match"); 712 SDL_SetError("Couldn't find display mode match");
655 return -1; 713 return -1;
656 } 714 }
657 715
658 if (SDL_memcmp 716 if (mode) {
659 (&fullscreen_mode, &display->fullscreen_mode, 717 *mode = fullscreen_mode;
660 sizeof(fullscreen_mode)) == 0) {
661 /* Nothing to do... */
662 return 0;
663 }
664 display->fullscreen_mode = fullscreen_mode;
665
666 /* Actually set the mode if we have a fullscreen window visible */
667 for (i = 0; i < display->num_windows; ++i) {
668 SDL_Window *window = &display->windows[i];
669 if (FULLSCREEN_VISIBLE(window)) {
670 if (SDL_SetDisplayMode(&display->fullscreen_mode) < 0) {
671 return -1;
672 }
673 }
674 if (window->flags & SDL_WINDOW_FULLSCREEN) {
675 SDL_OnWindowResized(window);
676 }
677 } 718 }
678 return 0; 719 return 0;
679 } 720 }
680 721
681 int 722 int
682 SDL_GetFullscreenDisplayMode(SDL_DisplayMode * mode) 723 SDL_SetDisplayPaletteForDisplay(SDL_VideoDisplay * display, const SDL_Color * colors, int firstcolor, int ncolors)
724 {
725 SDL_Palette *palette;
726 int status = 0;
727
728 palette = display->palette;
729 if (!palette) {
730 SDL_SetError("Display mode does not have a palette");
731 return -1;
732 }
733 status = SDL_SetPaletteColors(palette, colors, firstcolor, ncolors);
734
735 if (_this->SetDisplayPalette) {
736 if (_this->SetDisplayPalette(_this, display, palette) < 0) {
737 status = -1;
738 }
739 }
740 return status;
741 }
742
743 int
744 SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors)
683 { 745 {
684 if (!_this) { 746 if (!_this) {
685 SDL_UninitializedVideo(); 747 SDL_UninitializedVideo();
686 return -1; 748 return -1;
687 } 749 }
688 if (mode) { 750 return SDL_SetDisplayPaletteForDisplay(&SDL_CurrentDisplay, colors, firstcolor, ncolors);
689 *mode = SDL_CurrentDisplay.fullscreen_mode; 751 }
690 } 752
691 return 0; 753 int
692 } 754 SDL_GetDisplayPaletteForDisplay(SDL_VideoDisplay * display, SDL_Color * colors, int firstcolor, int ncolors)
693
694 int
695 SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors)
696 { 755 {
697 SDL_Palette *palette; 756 SDL_Palette *palette;
698 int status = 0; 757
699 758 palette = display->palette;
700 if (!_this) { 759 if (!palette || !palette->ncolors) {
701 SDL_UninitializedVideo();
702 return -1;
703 }
704 palette = SDL_CurrentDisplay.palette;
705 if (!palette) {
706 SDL_SetError("Display mode does not have a palette");
707 return -1;
708 }
709 status = SDL_SetPaletteColors(palette, colors, firstcolor, ncolors);
710
711 if (_this->SetDisplayPalette) {
712 if (_this->SetDisplayPalette(_this, palette) < 0) {
713 status = -1;
714 }
715 }
716 return status;
717 }
718
719 int
720 SDL_GetDisplayPalette(SDL_Color * colors, int firstcolor, int ncolors)
721 {
722 SDL_Palette *palette;
723
724 if (!_this) {
725 SDL_UninitializedVideo();
726 return -1;
727 }
728 palette = SDL_CurrentDisplay.palette;
729 if (!palette->ncolors) {
730 SDL_SetError("Display mode does not have a palette"); 760 SDL_SetError("Display mode does not have a palette");
731 return -1; 761 return -1;
732 } 762 }
733 if (firstcolor < 0 || (firstcolor + ncolors) > palette->ncolors) { 763 if (firstcolor < 0 || (firstcolor + ncolors) > palette->ncolors) {
734 SDL_SetError("Palette indices are out of range"); 764 SDL_SetError("Palette indices are out of range");
735 return -1; 765 return -1;
736 } 766 }
737 SDL_memcpy(colors, &palette->colors[firstcolor], 767 SDL_memcpy(colors, &palette->colors[firstcolor],
738 ncolors * sizeof(*colors)); 768 ncolors * sizeof(*colors));
739 return 0; 769 return 0;
770 }
771
772 int
773 SDL_GetDisplayPalette(SDL_Color * colors, int firstcolor, int ncolors)
774 {
775 SDL_Palette *palette;
776
777 if (!_this) {
778 SDL_UninitializedVideo();
779 return -1;
780 }
781 return SDL_GetDisplayPaletteForDisplay(&SDL_CurrentDisplay, colors, firstcolor, ncolors);
740 } 782 }
741 783
742 SDL_WindowID 784 SDL_WindowID
743 SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) 785 SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
744 { 786 {
833 875
834 if (!_this->CreateWindowFrom || 876 if (!_this->CreateWindowFrom ||
835 _this->CreateWindowFrom(_this, &window, data) < 0) { 877 _this->CreateWindowFrom(_this, &window, data) < 0) {
836 return 0; 878 return 0;
837 } 879 }
880 /* FIXME: Find out what display this window is actually on... */
838 display = &SDL_CurrentDisplay; 881 display = &SDL_CurrentDisplay;
839 num_windows = display->num_windows; 882 num_windows = display->num_windows;
840 windows = 883 windows =
841 SDL_realloc(display->windows, (num_windows + 1) * sizeof(*windows)); 884 SDL_realloc(display->windows, (num_windows + 1) * sizeof(*windows));
842 if (!windows) { 885 if (!windows) {
1246 if (fullscreen) { 1289 if (fullscreen) {
1247 window->flags |= SDL_WINDOW_FULLSCREEN; 1290 window->flags |= SDL_WINDOW_FULLSCREEN;
1248 1291
1249 if (FULLSCREEN_VISIBLE(window)) { 1292 if (FULLSCREEN_VISIBLE(window)) {
1250 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); 1293 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
1294 SDL_DisplayMode fullscreen_mode;
1251 1295
1252 /* Hide any other fullscreen windows */ 1296 /* Hide any other fullscreen windows */
1253 int i; 1297 int i;
1254 for (i = 0; i < display->num_windows; ++i) { 1298 for (i = 0; i < display->num_windows; ++i) {
1255 SDL_Window *other = &display->windows[i]; 1299 SDL_Window *other = &display->windows[i];
1256 if (other->id != windowID && FULLSCREEN_VISIBLE(other)) { 1300 if (other->id != windowID && FULLSCREEN_VISIBLE(other)) {
1257 SDL_MinimizeWindow(other->id); 1301 SDL_MinimizeWindow(other->id);
1258 } 1302 }
1259 } 1303 }
1260 1304
1261 SDL_SetDisplayMode(&display->fullscreen_mode); 1305 if (SDL_GetWindowDisplayMode(windowID, &fullscreen_mode) == 0) {
1306 SDL_SetDisplayModeForDisplay(display, &fullscreen_mode);
1307 }
1262 } 1308 }
1263 } else { 1309 } else {
1264 window->flags &= ~SDL_WINDOW_FULLSCREEN; 1310 window->flags &= ~SDL_WINDOW_FULLSCREEN;
1265 1311
1266 if (FULLSCREEN_VISIBLE(window)) { 1312 if (FULLSCREEN_VISIBLE(window)) {
1334 void 1380 void
1335 SDL_OnWindowFocusGained(SDL_Window * window) 1381 SDL_OnWindowFocusGained(SDL_Window * window)
1336 { 1382 {
1337 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); 1383 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
1338 1384
1339 if (window->flags & SDL_WINDOW_FULLSCREEN) { 1385 if (FULLSCREEN_VISIBLE(window)) {
1340 SDL_SetDisplayMode(&display->fullscreen_mode); 1386 SDL_SetDisplayMode(&window->fullscreen_mode);
1341 } 1387 }
1342 if (display->gamma && _this->SetDisplayGammaRamp) { 1388 if (display->gamma && _this->SetDisplayGammaRamp) {
1343 _this->SetDisplayGammaRamp(_this, display->gamma); 1389 _this->SetDisplayGammaRamp(_this, display, display->gamma);
1344 } 1390 }
1345 if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN)) 1391 if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN))
1346 && _this->SetWindowGrab) { 1392 && _this->SetWindowGrab) {
1347 _this->SetWindowGrab(_this, window); 1393 _this->SetWindowGrab(_this, window);
1348 } 1394 }
1351 void 1397 void
1352 SDL_OnWindowFocusLost(SDL_Window * window) 1398 SDL_OnWindowFocusLost(SDL_Window * window)
1353 { 1399 {
1354 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); 1400 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
1355 1401
1356 if (window->flags & SDL_WINDOW_FULLSCREEN) { 1402 if (FULLSCREEN_VISIBLE(window)) {
1357 SDL_MinimizeWindow(window->id); 1403 SDL_MinimizeWindow(window->id);
1358 SDL_SetDisplayMode(NULL); 1404 SDL_SetDisplayMode(NULL);
1359 } 1405 }
1360 if (display->gamma && _this->SetDisplayGammaRamp) { 1406 if (display->gamma && _this->SetDisplayGammaRamp) {
1361 _this->SetDisplayGammaRamp(_this, display->saved_gamma); 1407 _this->SetDisplayGammaRamp(_this, display, display->saved_gamma);
1362 } 1408 }
1363 if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN)) 1409 if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN))
1364 && _this->SetWindowGrab) { 1410 && _this->SetWindowGrab) {
1365 _this->SetWindowGrab(_this, window); 1411 _this->SetWindowGrab(_this, window);
1366 } 1412 }
1428 } 1474 }
1429 } 1475 }
1430 } 1476 }
1431 1477
1432 void 1478 void
1433 SDL_AddRenderDriver(int displayIndex, const SDL_RenderDriver * driver) 1479 SDL_AddRenderDriver(SDL_VideoDisplay * display, const SDL_RenderDriver * driver)
1434 { 1480 {
1435 SDL_VideoDisplay *display;
1436 SDL_RenderDriver *render_drivers; 1481 SDL_RenderDriver *render_drivers;
1437
1438 if (displayIndex >= _this->num_displays) {
1439 return;
1440 }
1441 display = &_this->displays[displayIndex];
1442 1482
1443 render_drivers = 1483 render_drivers =
1444 SDL_realloc(display->render_drivers, 1484 SDL_realloc(display->render_drivers,
1445 (display->num_render_drivers + 1485 (display->num_render_drivers +
1446 1) * sizeof(*render_drivers)); 1486 1) * sizeof(*render_drivers));