Mercurial > sdl-ios-xcode
comparison src/video/SDL_video.c @ 1967:01e29c3e9a29
In general, fill in pointers to structures, rather than return them.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 05 Aug 2006 22:34:23 +0000 |
parents | a788656ca29a |
children | 5d3724f64f2b |
comparison
equal
deleted
inserted
replaced
1966:6472256c21eb | 1967:01e29c3e9a29 |
---|---|
420 return display->num_display_modes; | 420 return display->num_display_modes; |
421 } | 421 } |
422 return 0; | 422 return 0; |
423 } | 423 } |
424 | 424 |
425 const SDL_DisplayMode * | 425 int |
426 SDL_GetDisplayMode(int index) | 426 SDL_GetDisplayMode(int index, SDL_DisplayMode * mode) |
427 { | 427 { |
428 if (index < 0 || index >= SDL_GetNumDisplayModes()) { | 428 if (index < 0 || index >= SDL_GetNumDisplayModes()) { |
429 SDL_SetError("index must be in the range of 0 - %d", | 429 SDL_SetError("index must be in the range of 0 - %d", |
430 SDL_GetNumDisplayModes() - 1); | 430 SDL_GetNumDisplayModes() - 1); |
431 return NULL; | 431 return -1; |
432 } | 432 } |
433 return &SDL_CurrentDisplay.display_modes[index]; | 433 if (mode) { |
434 } | 434 *mode = SDL_CurrentDisplay.display_modes[index]; |
435 | 435 } |
436 const SDL_DisplayMode * | 436 return 0; |
437 SDL_GetDesktopDisplayMode(void) | 437 } |
438 { | 438 |
439 if (_this) { | 439 int |
440 return &SDL_CurrentDisplay.desktop_mode; | 440 SDL_GetDesktopDisplayMode(SDL_DisplayMode * mode) |
441 } | 441 { |
442 return NULL; | 442 if (!_this) { |
443 } | 443 SDL_UninitializedVideo(); |
444 | 444 return -1; |
445 const SDL_DisplayMode * | 445 } |
446 SDL_GetCurrentDisplayMode(void) | 446 if (mode) { |
447 { | 447 *mode = SDL_CurrentDisplay.desktop_mode; |
448 if (_this) { | 448 } |
449 return &SDL_CurrentDisplay.current_mode; | 449 return 0; |
450 } | 450 } |
451 return NULL; | 451 |
452 int | |
453 SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode) | |
454 { | |
455 if (!_this) { | |
456 SDL_UninitializedVideo(); | |
457 return -1; | |
458 } | |
459 if (mode) { | |
460 *mode = SDL_CurrentDisplay.current_mode; | |
461 } | |
462 return 0; | |
452 } | 463 } |
453 | 464 |
454 SDL_DisplayMode * | 465 SDL_DisplayMode * |
455 SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode, | 466 SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode, |
456 SDL_DisplayMode * closest) | 467 SDL_DisplayMode * closest) |
547 int | 558 int |
548 SDL_SetDisplayMode(const SDL_DisplayMode * mode) | 559 SDL_SetDisplayMode(const SDL_DisplayMode * mode) |
549 { | 560 { |
550 SDL_VideoDisplay *display; | 561 SDL_VideoDisplay *display; |
551 SDL_DisplayMode display_mode; | 562 SDL_DisplayMode display_mode; |
563 SDL_DisplayMode current_mode; | |
552 int i, ncolors; | 564 int i, ncolors; |
553 | 565 |
554 if (!_this) { | 566 if (!_this) { |
555 SDL_UninitializedVideo(); | 567 SDL_UninitializedVideo(); |
556 return -1; | 568 return -1; |
557 } | 569 } |
558 | 570 |
571 display = &SDL_CurrentDisplay; | |
559 if (!mode) { | 572 if (!mode) { |
560 mode = SDL_GetDesktopDisplayMode(); | 573 mode = &display->desktop_mode; |
561 } | 574 } |
562 display = &SDL_CurrentDisplay; | |
563 display_mode = *mode; | 575 display_mode = *mode; |
564 | 576 |
565 /* Default to the current mode */ | 577 /* Default to the current mode */ |
566 if (!display_mode.format) { | 578 if (!display_mode.format) { |
567 display_mode.format = display->current_mode.format; | 579 display_mode.format = display->current_mode.format; |
582 display_mode.w, display_mode.h); | 594 display_mode.w, display_mode.h); |
583 return -1; | 595 return -1; |
584 } | 596 } |
585 | 597 |
586 /* See if there's anything left to do */ | 598 /* See if there's anything left to do */ |
587 if (SDL_memcmp | 599 SDL_GetCurrentDisplayMode(¤t_mode); |
588 (&display_mode, SDL_GetCurrentDisplayMode(), | 600 if (SDL_memcmp(&display_mode, ¤t_mode, sizeof(display_mode)) == 0) { |
589 sizeof(display_mode)) == 0) { | |
590 return 0; | 601 return 0; |
591 } | 602 } |
592 | 603 |
593 /* Actually change the display mode */ | 604 /* Actually change the display mode */ |
594 if (_this->SetDisplayMode(_this, &display_mode) < 0) { | 605 if (_this->SetDisplayMode(_this, &display_mode) < 0) { |
657 } | 668 } |
658 } | 669 } |
659 return 0; | 670 return 0; |
660 } | 671 } |
661 | 672 |
662 const SDL_DisplayMode * | 673 int |
663 SDL_GetFullscreenDisplayMode(void) | 674 SDL_GetFullscreenDisplayMode(SDL_DisplayMode * mode) |
664 { | 675 { |
665 if (_this) { | 676 if (!_this) { |
666 return SDL_CurrentDisplay.fullscreen_mode; | 677 SDL_UninitializedVideo(); |
667 } | 678 return -1; |
668 return NULL; | 679 } |
680 if (mode) { | |
681 *mode = *SDL_CurrentDisplay.fullscreen_mode; | |
682 } | |
683 return 0; | |
669 } | 684 } |
670 | 685 |
671 int | 686 int |
672 SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors) | 687 SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors) |
673 { | 688 { |