Mercurial > sdl-ios-xcode
comparison src/video/qnxgf/SDL_qnxgf.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 | 87182c69e080 |
children | 64ce267332c6 |
comparison
equal
deleted
inserted
replaced
3499:4cf8a1423d57 | 3500:4b594623401b |
---|---|
520 didata->custom_refresh = 0; | 520 didata->custom_refresh = 0; |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 /* Get all display modes for this display */ | 524 /* Get all display modes for this display */ |
525 _this->current_display = it; | 525 qnxgf_getdisplaymodes(_this, display); |
526 qnxgf_getdisplaymodes(_this); | 526 } |
527 } | |
528 | |
529 /* Restore default display */ | |
530 _this->current_display = 0; | |
531 | 527 |
532 /* Add GF renderer to SDL */ | 528 /* Add GF renderer to SDL */ |
533 gf_addrenderdriver(_this); | 529 gf_addrenderdriver(_this); |
534 | 530 |
535 /* Add GF input devices */ | 531 /* Add GF input devices */ |
612 didata->display = NULL; | 608 didata->display = NULL; |
613 } | 609 } |
614 } | 610 } |
615 | 611 |
616 void | 612 void |
617 qnxgf_getdisplaymodes(_THIS) | 613 qnxgf_getdisplaymodes(_THIS, SDL_VideoDisplay * display) |
618 { | 614 { |
619 SDL_DisplayData *didata = | 615 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; |
620 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
621 SDL_DisplayMode mode; | 616 SDL_DisplayMode mode; |
622 gf_modeinfo_t modeinfo; | 617 gf_modeinfo_t modeinfo; |
623 uint32_t it = 0; | 618 uint32_t it = 0; |
624 uint32_t jt = 0; | 619 uint32_t jt = 0; |
625 uint32_t kt = 0; | 620 uint32_t kt = 0; |
651 mode.h = generic_mode[jt].h; | 646 mode.h = generic_mode[jt].h; |
652 mode.refresh_rate = generic_mode[jt].refresh_rate; | 647 mode.refresh_rate = generic_mode[jt].refresh_rate; |
653 mode.format = | 648 mode.format = |
654 qnxgf_gf_to_sdl_pixelformat(modeinfo.primary_format); | 649 qnxgf_gf_to_sdl_pixelformat(modeinfo.primary_format); |
655 mode.driverdata = NULL; | 650 mode.driverdata = NULL; |
656 SDL_AddDisplayMode(_this->current_display, &mode); | 651 SDL_AddDisplayMode(display, &mode); |
657 | 652 |
658 /* If mode is RGBA8888, add the same mode as RGBx888 */ | 653 /* If mode is RGBA8888, add the same mode as RGBx888 */ |
659 if (modeinfo.primary_format == GF_FORMAT_BGRA8888) { | 654 if (modeinfo.primary_format == GF_FORMAT_BGRA8888) { |
660 mode.w = generic_mode[jt].w; | 655 mode.w = generic_mode[jt].w; |
661 mode.h = generic_mode[jt].h; | 656 mode.h = generic_mode[jt].h; |
662 mode.refresh_rate = generic_mode[jt].refresh_rate; | 657 mode.refresh_rate = generic_mode[jt].refresh_rate; |
663 mode.format = SDL_PIXELFORMAT_RGB888; | 658 mode.format = SDL_PIXELFORMAT_RGB888; |
664 mode.driverdata = NULL; | 659 mode.driverdata = NULL; |
665 SDL_AddDisplayMode(_this->current_display, &mode); | 660 SDL_AddDisplayMode(display, &mode); |
666 } | 661 } |
667 /* If mode is RGBA1555, add the same mode as RGBx555 */ | 662 /* If mode is RGBA1555, add the same mode as RGBx555 */ |
668 if (modeinfo.primary_format == GF_FORMAT_PACK_ARGB1555) { | 663 if (modeinfo.primary_format == GF_FORMAT_PACK_ARGB1555) { |
669 mode.w = generic_mode[jt].w; | 664 mode.w = generic_mode[jt].w; |
670 mode.h = generic_mode[jt].h; | 665 mode.h = generic_mode[jt].h; |
671 mode.refresh_rate = generic_mode[jt].refresh_rate; | 666 mode.refresh_rate = generic_mode[jt].refresh_rate; |
672 mode.format = SDL_PIXELFORMAT_RGB555; | 667 mode.format = SDL_PIXELFORMAT_RGB555; |
673 mode.driverdata = NULL; | 668 mode.driverdata = NULL; |
674 SDL_AddDisplayMode(_this->current_display, &mode); | 669 SDL_AddDisplayMode(display, &mode); |
675 } | 670 } |
676 | 671 |
677 jt++; | 672 jt++; |
678 } while (1); | 673 } while (1); |
679 } else { | 674 } else { |
687 mode.refresh_rate = modeinfo.refresh[jt]; | 682 mode.refresh_rate = modeinfo.refresh[jt]; |
688 mode.format = | 683 mode.format = |
689 qnxgf_gf_to_sdl_pixelformat(modeinfo. | 684 qnxgf_gf_to_sdl_pixelformat(modeinfo. |
690 primary_format); | 685 primary_format); |
691 mode.driverdata = NULL; | 686 mode.driverdata = NULL; |
692 SDL_AddDisplayMode(_this->current_display, &mode); | 687 SDL_AddDisplayMode(display, &mode); |
693 | 688 |
694 /* If mode is RGBA8888, add the same mode as RGBx888 */ | 689 /* If mode is RGBA8888, add the same mode as RGBx888 */ |
695 if (modeinfo.primary_format == GF_FORMAT_BGRA8888) { | 690 if (modeinfo.primary_format == GF_FORMAT_BGRA8888) { |
696 mode.w = modeinfo.xres; | 691 mode.w = modeinfo.xres; |
697 mode.h = modeinfo.yres; | 692 mode.h = modeinfo.yres; |
698 mode.refresh_rate = modeinfo.refresh[jt]; | 693 mode.refresh_rate = modeinfo.refresh[jt]; |
699 mode.format = SDL_PIXELFORMAT_RGB888; | 694 mode.format = SDL_PIXELFORMAT_RGB888; |
700 mode.driverdata = NULL; | 695 mode.driverdata = NULL; |
701 SDL_AddDisplayMode(_this->current_display, &mode); | 696 SDL_AddDisplayMode(display, &mode); |
702 } | 697 } |
703 /* If mode is RGBA1555, add the same mode as RGBx555 */ | 698 /* If mode is RGBA1555, add the same mode as RGBx555 */ |
704 if (modeinfo.primary_format == | 699 if (modeinfo.primary_format == |
705 GF_FORMAT_PACK_ARGB1555) { | 700 GF_FORMAT_PACK_ARGB1555) { |
706 mode.w = modeinfo.xres; | 701 mode.w = modeinfo.xres; |
707 mode.h = modeinfo.yres; | 702 mode.h = modeinfo.yres; |
708 mode.refresh_rate = modeinfo.refresh[jt]; | 703 mode.refresh_rate = modeinfo.refresh[jt]; |
709 mode.format = SDL_PIXELFORMAT_RGB555; | 704 mode.format = SDL_PIXELFORMAT_RGB555; |
710 mode.driverdata = NULL; | 705 mode.driverdata = NULL; |
711 SDL_AddDisplayMode(_this->current_display, &mode); | 706 SDL_AddDisplayMode(display, &mode); |
712 } | 707 } |
713 | 708 |
714 jt++; | 709 jt++; |
715 } else { | 710 } else { |
716 break; | 711 break; |
729 it++; | 724 it++; |
730 } while (1); | 725 } while (1); |
731 } | 726 } |
732 | 727 |
733 int | 728 int |
734 qnxgf_setdisplaymode(_THIS, SDL_DisplayMode * mode) | 729 qnxgf_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) |
735 { | 730 { |
736 SDL_DisplayData *didata = | 731 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; |
737 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
738 uint32_t refresh_rate = 0; | 732 uint32_t refresh_rate = 0; |
739 int status; | 733 int status; |
740 | 734 |
741 /* Current display dimensions and bpp are no more valid */ | 735 /* Current display dimensions and bpp are no more valid */ |
742 didata->current_mode.format = SDL_PIXELFORMAT_UNKNOWN; | 736 didata->current_mode.format = SDL_PIXELFORMAT_UNKNOWN; |
758 /* Clear display mode structure */ | 752 /* Clear display mode structure */ |
759 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); | 753 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); |
760 tempmode.refresh_rate = 0x0000FFFF; | 754 tempmode.refresh_rate = 0x0000FFFF; |
761 | 755 |
762 /* Check if window width and height matches one of our modes */ | 756 /* Check if window width and height matches one of our modes */ |
763 for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) { | 757 for (it = 0; it < display->num_display_modes; it++) { |
764 if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) && | 758 if ((display->display_modes[it].w == mode->w) && |
765 (SDL_CurrentDisplay.display_modes[it].h == mode->h) && | 759 (display->display_modes[it].h == mode->h) && |
766 (SDL_CurrentDisplay.display_modes[it].format == mode->format)) | 760 (display->display_modes[it].format == mode->format)) |
767 { | 761 { |
768 /* Find the lowest refresh rate available */ | 762 /* Find the lowest refresh rate available */ |
769 if (tempmode.refresh_rate > | 763 if (tempmode.refresh_rate > |
770 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | 764 display->display_modes[it].refresh_rate) { |
771 tempmode = SDL_CurrentDisplay.display_modes[it]; | 765 tempmode = display->display_modes[it]; |
772 } | 766 } |
773 } | 767 } |
774 } | 768 } |
775 if (tempmode.refresh_rate != 0x0000FFFF) { | 769 if (tempmode.refresh_rate != 0x0000FFFF) { |
776 refresh_rate = tempmode.refresh_rate; | 770 refresh_rate = tempmode.refresh_rate; |
788 /* Clear display mode structure */ | 782 /* Clear display mode structure */ |
789 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); | 783 SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); |
790 tempmode.refresh_rate = 0x0000FFFF; | 784 tempmode.refresh_rate = 0x0000FFFF; |
791 | 785 |
792 /* Check if window width and height matches one of our modes */ | 786 /* Check if window width and height matches one of our modes */ |
793 for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) { | 787 for (it = 0; it < display->num_display_modes; it++) { |
794 if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) && | 788 if ((display->display_modes[it].w == mode->w) && |
795 (SDL_CurrentDisplay.display_modes[it].h == mode->h) && | 789 (display->display_modes[it].h == mode->h) && |
796 (SDL_CurrentDisplay.display_modes[it].format == mode->format)) | 790 (display->display_modes[it].format == mode->format)) |
797 { | 791 { |
798 /* Find the lowest refresh rate available */ | 792 /* Find the lowest refresh rate available */ |
799 if (tempmode.refresh_rate > | 793 if (tempmode.refresh_rate > |
800 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | 794 display->display_modes[it].refresh_rate) { |
801 tempmode = SDL_CurrentDisplay.display_modes[it]; | 795 tempmode = display->display_modes[it]; |
802 } | 796 } |
803 | 797 |
804 /* Check if requested refresh rate found */ | 798 /* Check if requested refresh rate found */ |
805 if (refresh_rate == | 799 if (refresh_rate == |
806 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | 800 display->display_modes[it].refresh_rate) { |
807 tempmode = SDL_CurrentDisplay.display_modes[it]; | 801 tempmode = display->display_modes[it]; |
808 break; | 802 break; |
809 } | 803 } |
810 } | 804 } |
811 } | 805 } |
812 if (tempmode.refresh_rate != 0x0000FFFF) { | 806 if (tempmode.refresh_rate != 0x0000FFFF) { |
926 | 920 |
927 return 0; | 921 return 0; |
928 } | 922 } |
929 | 923 |
930 int | 924 int |
931 qnxgf_setdisplaypalette(_THIS, SDL_Palette * palette) | 925 qnxgf_setdisplaypalette(_THIS, SDL_VideoDisplay * display, SDL_Palette * palette) |
932 { | 926 { |
933 SDL_DisplayData *didata = | 927 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; |
934 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
935 | 928 |
936 /* QNX GF doesn't have support for global palette changing, but we */ | 929 /* QNX GF doesn't have support for global palette changing, but we */ |
937 /* could store it for usage in future */ | 930 /* could store it for usage in future */ |
938 | 931 |
939 /* Setting display palette operation has been failed */ | 932 SDL_Unsupported(); |
940 return -1; | 933 return -1; |
941 } | 934 } |
942 | 935 |
943 int | 936 int |
944 qnxgf_getdisplaypalette(_THIS, SDL_Palette * palette) | 937 qnxgf_getdisplaypalette(_THIS, SDL_VideoDisplay * display, SDL_Palette * palette) |
945 { | 938 { |
946 SDL_DisplayData *didata = | 939 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; |
947 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
948 | 940 |
949 /* We can't provide current palette settings and looks like SDL */ | 941 /* We can't provide current palette settings and looks like SDL */ |
950 /* do not call this function also, in such case this function returns -1 */ | 942 /* do not call this function also, in such case this function returns -1 */ |
951 | 943 |
952 /* Getting display palette operation has been failed */ | 944 SDL_Unsupported(); |
953 return -1; | 945 return -1; |
954 } | 946 } |
955 | 947 |
956 int | 948 int |
957 qnxgf_setdisplaygammaramp(_THIS, Uint16 * ramp) | 949 qnxgf_setdisplaygammaramp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp) |
958 { | 950 { |
959 SDL_DisplayData *didata = | 951 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; |
960 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | |
961 int status; | 952 int status; |
962 | 953 |
963 /* Setup gamma ramp, for each color channel */ | 954 /* Setup gamma ramp, for each color channel */ |
964 status = | 955 status = |
965 gf_display_set_color_lut16(didata->display, (uint16_t *) ramp, | 956 gf_display_set_color_lut16(didata->display, (uint16_t *) ramp, |
972 | 963 |
973 return 0; | 964 return 0; |
974 } | 965 } |
975 | 966 |
976 int | 967 int |
977 qnxgf_getdisplaygammaramp(_THIS, Uint16 * ramp) | 968 qnxgf_getdisplaygammaramp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp) |
978 { | 969 { |
979 /* TODO: We need to return previous gamma set */ | 970 /* TODO: We need to return previous gamma set */ |
980 /* Also we need some initial fake gamma to return */ | 971 /* Also we need some initial fake gamma to return */ |
981 | 972 |
982 /* Getting display gamma ramp operation has been failed */ | 973 SDL_Unsupported(); |
983 return -1; | 974 return -1; |
984 } | 975 } |
985 | 976 |
986 int | 977 int |
987 qnxgf_createwindow(_THIS, SDL_Window * window) | 978 qnxgf_createwindow(_THIS, SDL_Window * window) |
988 { | 979 { |
989 SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; | 980 SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; |
990 SDL_DisplayData *didata = | 981 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
991 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | 982 SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; |
992 SDL_WindowData *wdata; | 983 SDL_WindowData *wdata; |
993 int32_t status; | 984 int32_t status; |
994 | 985 |
995 /* QNX GF supports fullscreen window modes only */ | 986 /* QNX GF supports fullscreen window modes only */ |
996 if ((window->flags & SDL_WINDOW_FULLSCREEN) != SDL_WINDOW_FULLSCREEN) { | 987 if ((window->flags & SDL_WINDOW_FULLSCREEN) != SDL_WINDOW_FULLSCREEN) { |
1000 /* Clear display mode structure */ | 991 /* Clear display mode structure */ |
1001 SDL_memset(&mode, 0x00, sizeof(SDL_DisplayMode)); | 992 SDL_memset(&mode, 0x00, sizeof(SDL_DisplayMode)); |
1002 mode.refresh_rate = 0x0000FFFF; | 993 mode.refresh_rate = 0x0000FFFF; |
1003 | 994 |
1004 /* Check if window width and height matches one of our modes */ | 995 /* Check if window width and height matches one of our modes */ |
1005 for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) { | 996 for (it = 0; it < display->num_display_modes; it++) { |
1006 if ((SDL_CurrentDisplay.display_modes[it].w == window->w) && | 997 if ((display->display_modes[it].w == window->w) && |
1007 (SDL_CurrentDisplay.display_modes[it].h == window->h) && | 998 (display->display_modes[it].h == window->h) && |
1008 (SDL_CurrentDisplay.display_modes[it].format == | 999 (display->display_modes[it].format == |
1009 SDL_CurrentDisplay.desktop_mode.format)) { | 1000 display->desktop_mode.format)) { |
1010 /* Find the lowest refresh rate available */ | 1001 /* Find the lowest refresh rate available */ |
1011 if (mode.refresh_rate > | 1002 if (mode.refresh_rate > |
1012 SDL_CurrentDisplay.display_modes[it].refresh_rate) { | 1003 display->display_modes[it].refresh_rate) { |
1013 mode = SDL_CurrentDisplay.display_modes[it]; | 1004 mode = display->display_modes[it]; |
1014 } | 1005 } |
1015 } | 1006 } |
1016 } | 1007 } |
1017 | 1008 |
1018 /* Check if end of display list has been reached */ | 1009 /* Check if end of display list has been reached */ |
1162 void | 1153 void |
1163 qnxgf_destroywindow(_THIS, SDL_Window * window) | 1154 qnxgf_destroywindow(_THIS, SDL_Window * window) |
1164 { | 1155 { |
1165 SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; | 1156 SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; |
1166 SDL_DisplayData *didata = | 1157 SDL_DisplayData *didata = |
1167 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | 1158 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; |
1168 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | 1159 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1169 | 1160 |
1170 if (wdata != NULL) { | 1161 if (wdata != NULL) { |
1171 #if defined(SDL_VIDEO_OPENGL_ES) | 1162 #if defined(SDL_VIDEO_OPENGL_ES) |
1172 /* Destroy OpenGL ES surface if it was created */ | 1163 /* Destroy OpenGL ES surface if it was created */ |
1316 { | 1307 { |
1317 #if defined(SDL_VIDEO_OPENGL_ES) | 1308 #if defined(SDL_VIDEO_OPENGL_ES) |
1318 SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; | 1309 SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; |
1319 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; | 1310 SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; |
1320 SDL_DisplayData *didata = | 1311 SDL_DisplayData *didata = |
1321 (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | 1312 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; |
1322 EGLBoolean status; | 1313 EGLBoolean status; |
1323 int32_t gfstatus; | 1314 int32_t gfstatus; |
1324 EGLint configs; | 1315 EGLint configs; |
1325 uint32_t surfaces; | 1316 uint32_t surfaces; |
1326 uint32_t attr_pos; | 1317 uint32_t attr_pos; |