diff 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
line wrap: on
line diff
--- a/src/video/windx5/SDL_dx5video.c	Sun May 07 03:44:58 2006 +0000
+++ b/src/video/windx5/SDL_dx5video.c	Sun May 07 04:02:48 2006 +0000
@@ -636,6 +636,16 @@
 	DX5_Available, DX5_CreateDevice
 };
 
+static int cmpmodes(const void *va, const void *vb)
+{
+    SDL_Rect *a = *(SDL_Rect **)va;
+    SDL_Rect *b = *(SDL_Rect **)vb;
+    if ( a->w == b->w )
+        return b->h - a->h;
+    else
+        return b->w - a->w;
+}
+
 static HRESULT WINAPI EnumModes2(DDSURFACEDESC *desc, VOID *udata)
 {
 	SDL_VideoDevice *this = (SDL_VideoDevice *)udata;
@@ -955,6 +965,10 @@
 			SDL_modelist[i][j] = &rect->r;
 		}
 		SDL_modelist[i][j] = NULL;
+
+		if ( SDL_nummodes[i] > 0 ) {
+			SDL_qsort(SDL_modelist[i], SDL_nummodes[i], sizeof *SDL_modelist[i], cmpmodes);
+		}
 	}
 	
 	/* Fill in some window manager capabilities */