comparison src/video/windx5/SDL_dx5video.c @ 1771:8d3ca155c396

Fixed bug #217 Sort the DirectX video modes largest to smallest
author Sam Lantinga <slouken@libsdl.org>
date Sun, 07 May 2006 04:02:48 +0000
parents 8d9bb0cf2c2a
children 2280e314a978
comparison
equal deleted inserted replaced
1770:1632155c67e5 1771:8d3ca155c396
634 VideoBootStrap DIRECTX_bootstrap = { 634 VideoBootStrap DIRECTX_bootstrap = {
635 "directx", "Win95/98/2000 DirectX", 635 "directx", "Win95/98/2000 DirectX",
636 DX5_Available, DX5_CreateDevice 636 DX5_Available, DX5_CreateDevice
637 }; 637 };
638 638
639 static int cmpmodes(const void *va, const void *vb)
640 {
641 SDL_Rect *a = *(SDL_Rect **)va;
642 SDL_Rect *b = *(SDL_Rect **)vb;
643 if ( a->w == b->w )
644 return b->h - a->h;
645 else
646 return b->w - a->w;
647 }
648
639 static HRESULT WINAPI EnumModes2(DDSURFACEDESC *desc, VOID *udata) 649 static HRESULT WINAPI EnumModes2(DDSURFACEDESC *desc, VOID *udata)
640 { 650 {
641 SDL_VideoDevice *this = (SDL_VideoDevice *)udata; 651 SDL_VideoDevice *this = (SDL_VideoDevice *)udata;
642 struct DX5EnumRect *enumrect; 652 struct DX5EnumRect *enumrect;
643 #if defined(NONAMELESSUNION) 653 #if defined(NONAMELESSUNION)
953 } 963 }
954 for ( j = 0, rect = enumlists[i]; rect; ++j, rect = rect->next ) { 964 for ( j = 0, rect = enumlists[i]; rect; ++j, rect = rect->next ) {
955 SDL_modelist[i][j] = &rect->r; 965 SDL_modelist[i][j] = &rect->r;
956 } 966 }
957 SDL_modelist[i][j] = NULL; 967 SDL_modelist[i][j] = NULL;
968
969 if ( SDL_nummodes[i] > 0 ) {
970 SDL_qsort(SDL_modelist[i], SDL_nummodes[i], sizeof *SDL_modelist[i], cmpmodes);
971 }
958 } 972 }
959 973
960 /* Fill in some window manager capabilities */ 974 /* Fill in some window manager capabilities */
961 this->info.wm_available = 1; 975 this->info.wm_available = 1;
962 976