comparison src/video/photon/SDL_ph_modes.c @ 966:f72cc0c7305f

Video modes are sorted width first, then height
author Sam Lantinga <slouken@libsdl.org>
date Fri, 12 Nov 2004 21:25:42 +0000
parents 4ab6d1fd028f
children c07c6ef7c93e
comparison
equal deleted inserted replaced
965:b68e551205e9 966:f72cc0c7305f
36 SDL_Rect SDL_modelist[PH_MAX_VIDEOMODES]; 36 SDL_Rect SDL_modelist[PH_MAX_VIDEOMODES];
37 SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES]; 37 SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES];
38 38
39 static int compare_modes_by_res(const void* mode1, const void* mode2) 39 static int compare_modes_by_res(const void* mode1, const void* mode2)
40 { 40 {
41 if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0) 41 PgVideoModeInfo_t mode1_info;
42 PgVideoModeInfo_t mode2_info;
43
44 if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode1_info) < 0)
42 { 45 {
43 return 0; 46 return 0;
44 } 47 }
45 48
46 key1 = mode_info.width * mode_info.height; 49 if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode2_info) < 0)
47
48 if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
49 { 50 {
50 return 0; 51 return 0;
51 } 52 }
52 53
53 key2 = mode_info.width * mode_info.height; 54 if (mode1_info.width == mode2_info.width)
54 55 {
55 if (key1 > key2) 56 return mode2_info.height - mode1_info.height;
56 {
57 return 1;
58 } 57 }
59 else 58 else
60 { 59 {
61 if (key1 == key2) 60 return mode2_info.width - mode1_info.width;
62 {
63 return 0;
64 }
65 else
66 {
67 return -1;
68 }
69 } 61 }
70 } 62 }
71 63
72 SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) 64 SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
73 { 65 {