Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed bug #217
Sort the DirectX video modes largest to smallest
  • Loading branch information
slouken committed May 7, 2006
1 parent f057af6 commit b9ea7f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/video/windib/SDL_dibvideo.c
Expand Up @@ -348,7 +348,6 @@ int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat)
#endif
}
/* Sort the mode lists */
if( i > 1 )
for ( i=0; i<NUM_MODELISTS; ++i ) {
if ( SDL_nummodes[i] > 0 ) {
SDL_qsort(SDL_modelist[i], SDL_nummodes[i], sizeof *SDL_modelist[i], cmpmodes);
Expand All @@ -361,7 +360,7 @@ int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat)
// because SDL surface conversion is much faster than the WinCE one.
// Although it should be tested on devices with graphics accelerator.

DIB_AddMode(this, vformat->BitsPerPixel,
DIB_AddMode(this, vformat->BitsPerPixel,
GetDeviceCaps(GetDC(NULL), HORZRES),
GetDeviceCaps(GetDC(NULL), VERTRES));

Expand Down
14 changes: 14 additions & 0 deletions src/video/windx5/SDL_dx5video.c
Expand Up @@ -636,6 +636,16 @@ VideoBootStrap DIRECTX_bootstrap = {
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;
Expand Down Expand Up @@ -955,6 +965,10 @@ int DX5_VideoInit(_THIS, SDL_PixelFormat *vformat)
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 */
Expand Down
2 changes: 1 addition & 1 deletion src/video/x11/SDL_x11modes.c
Expand Up @@ -617,7 +617,7 @@ int X11_GetVideoModes(_THIS)

}
/* sort the mode list descending as SDL expects */
qsort(SDL_modelist, nsizes, sizeof *SDL_modelist, cmpmodelist);
SDL_qsort(SDL_modelist, nsizes, sizeof *SDL_modelist, cmpmodelist);
SDL_modelist[i] = NULL; /* terminator */

use_xrandr = xrandr_major * 100 + xrandr_minor;
Expand Down

0 comments on commit b9ea7f6

Please sign in to comment.