comparison src/video/photon/SDL_ph_modes.c @ 266:c6abdda2f666

Added QNX cleanups by Mike Gorchak (thanks!)
author Sam Lantinga <slouken@libsdl.org>
date Fri, 18 Jan 2002 18:14:03 +0000
parents e8157fcb3114
children f6ffac90895c
comparison
equal deleted inserted replaced
265:35d9c8a5aa10 266:c6abdda2f666
23 #ifdef SAVE_RCSID 23 #ifdef SAVE_RCSID
24 static char rcsid = 24 static char rcsid =
25 "@(#) $Id$"; 25 "@(#) $Id$";
26 #endif 26 #endif
27 27
28
29 #include "SDL_ph_modes_c.h" 28 #include "SDL_ph_modes_c.h"
30 29
31 static unsigned long key1, key2; 30 static unsigned long key1, key2;
32 static PgVideoModeInfo_t mode_info; 31 static PgVideoModeInfo_t mode_info;
33 static PgVideoModes_t mode_list; 32 static PgVideoModes_t mode_list;
33
34 /* The current list of available video modes */ 34 /* The current list of available video modes */
35 SDL_Rect SDL_modelist[127]; 35 SDL_Rect SDL_modelist[PH_MAX_VIDEOMODES];
36 SDL_Rect *SDLmod_ptr; 36 SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES];
37 SDL_Rect **SDLmod_ptrptr ;
38 37
39 static int compare_modes_by_res(const void* mode1, const void* mode2) 38 static int compare_modes_by_res(const void* mode1, const void* mode2)
40 { 39 {
41 40
42 if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0) 41 if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
43 { 42 {
44 fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n", 43 fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
45 *(unsigned short*)mode1); 44 *(unsigned short*)mode1);
46 return 0; 45 return 0;
47 } 46 }
48 key1 = mode_info.width * mode_info.height; 47 key1 = mode_info.width * mode_info.height;
49 48
50 if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0) 49 if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
51 { 50 {
52 fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n", 51 fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
53 *(unsigned short*)mode2); 52 *(unsigned short*)mode2);
54 return 0; 53 return 0;
55 } 54 }
56 key2 = mode_info.width * mode_info.height; 55 key2 = mode_info.width * mode_info.height;
57 56
58 if (key1 > key2) 57 if (key1 > key2)
59 return 1; 58 return 1;
60 else if (key1 == key2) 59 else if (key1 == key2)
61 return 0; 60 return 0;
62 else 61 else
63 return -1; 62 return -1;
64 } 63 }
65 64
65 /*
66 static int compare_modes_by_bpp(const void* mode1, const void* mode2) 66 static int compare_modes_by_bpp(const void* mode1, const void* mode2)
67 { 67 {
68 68
69 if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0) 69 if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
70 { 70 {
87 else if (key1 == key2) 87 else if (key1 == key2)
88 return 0; 88 return 0;
89 else 89 else
90 return -1; 90 return -1;
91 } 91 }
92 92 */
93
94 /*
93 int ph_GetVideoModes(_THIS) 95 int ph_GetVideoModes(_THIS)
94 { 96 {
95 unsigned short *front; 97 unsigned short *front;
96 int i, bpp_group_size; 98 int i, bpp_group_size;
97 99
147 return -1; 149 return -1;
148 } 150 }
149 151
150 return 0; 152 return 0;
151 } 153 }
152 154 */
153 static SDL_Rect** ph_SupportedVisual( SDL_PixelFormat *format) 155
156 SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
154 { 157 {
155 int i = 0; 158 int i = 0;
156 int j = 0; 159 int j = 0;
157 SDL_Rect Amodelist[127]; 160 SDL_Rect Amodelist[PH_MAX_VIDEOMODES];
158 161
162 for (i=0; i<PH_MAX_VIDEOMODES; i++)
163 {
164 SDL_modearray[i]=&SDL_modelist[i];
165 }
159 166
160 if (PgGetVideoModeList( &mode_list ) < 0) 167 if (PgGetVideoModeList( &mode_list ) < 0)
161 { 168 {
162 fprintf(stderr,"error: PgGetVideoModeList failed\n"); 169 fprintf(stderr,"error: PgGetVideoModeList failed\n");
163 return NULL; 170 return NULL;
164 } 171 }
165 172
166 mode_info.bits_per_pixel = 0; 173 mode_info.bits_per_pixel = 0;
167 174
168 for (i=0; i < mode_list.num_modes; i++) 175 for (i=0; i < mode_list.num_modes; i++)
169 { 176 {
171 { 178 {
172 fprintf(stderr,"error: PgGetVideoModeInfo failed on mode: 0x%x\n", 179 fprintf(stderr,"error: PgGetVideoModeInfo failed on mode: 0x%x\n",
173 mode_list.modes[i]); 180 mode_list.modes[i]);
174 return NULL; 181 return NULL;
175 } 182 }
176 183
177 if(mode_info.bits_per_pixel == format->BitsPerPixel) 184 if(mode_info.bits_per_pixel == format->BitsPerPixel)
178 { 185 {
179 Amodelist[j].w = mode_info.width; 186 Amodelist[j].w = mode_info.width;
180 Amodelist[j].h = mode_info.height; 187 Amodelist[j].h = mode_info.height;
181 Amodelist[j].x = 0; 188 Amodelist[j].x = 0;
182 Amodelist[j].y = 0; 189 Amodelist[j].y = 0;
183 j++; 190 j++;
184 } 191 }
185 } 192 }
186 193
187 //reorder biggest for smallest , assume width dominates 194 //reorder biggest for smallest, assume width dominates
188 for(i=0; i< j ; i++) 195
189 { 196 for(i=0; i< j ; i++)
190 SDL_modelist[i].w = Amodelist[j - i -1].w; 197 {
191 SDL_modelist[i].h = Amodelist[j - i -1].h; 198 SDL_modelist[i].w = Amodelist[j - i -1].w;
192 SDL_modelist[i].x = Amodelist[j - i -1].x; 199 SDL_modelist[i].h = Amodelist[j - i -1].h;
193 SDL_modelist[i].y = Amodelist[j - i -1].y; 200 SDL_modelist[i].x = Amodelist[j - i -1].x;
194 } 201 SDL_modelist[i].y = Amodelist[j - i -1].y;
195 202 }
196 SDLmod_ptr = SDL_modelist; 203 SDL_modearray[j]=NULL;
197 SDLmod_ptrptr = &SDLmod_ptr; 204
198 return SDLmod_ptrptr; 205 return SDL_modearray;
199 }
200
201 SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
202 {
203 return ph_SupportedVisual( format);
204 } 206 }
205 207
206 void ph_FreeVideoModes(_THIS) 208 void ph_FreeVideoModes(_THIS)
207 { 209 {
208 // int i; 210 return;
209
210 // if ( SDL_modelist ) {
211 // for ( i=0; SDL_modelist[i]; ++i ) {
212 // free(SDL_modelist[i]);
213 // }
214 // free(SDL_modelist);
215 // SDL_modelist = NULL;
216 // }
217 } 211 }
218 212
219 static void set_best_resolution(_THIS, int width, int height) 213 static void set_best_resolution(_THIS, int width, int height)
220 { 214 {
221 215
285 } 279 }
286 } 280 }
287 } 281 }
288 } 282 }
289 283
284 /*
290 static void get_real_resolution(_THIS, int* w, int* h) 285 static void get_real_resolution(_THIS, int* w, int* h)
291 { 286 {
292 287
293 if ( use_vidmode ) { 288 if ( use_vidmode ) {
294 //PgDisplaySettings_t settings; 289 //PgDisplaySettings_t settings;
295 PgVideoModeInfo_t current_mode_info; 290 PgVideoModeInfo_t current_mode_info;
296 PgHWCaps_t my_hwcaps; 291 PgHWCaps_t my_hwcaps;
297 int unused; 292 // int unused;
298 /* 293
299 if (PgGetVideoMode( &settings ) >= 0) { 294 // if (PgGetVideoMode( &settings ) >= 0) {
300 *w = settings.xres; 295 // *w = settings.xres;
301 *h = settings.yres; 296 // *h = settings.yres;
302 return; 297 // return;
303 }*/ 298 // }
304 if (PgGetGraphicsHWCaps(&my_hwcaps) >= 0) 299 if (PgGetGraphicsHWCaps(&my_hwcaps) >= 0)
305 { 300 {
306 if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &current_mode_info) < 0) 301 if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &current_mode_info) < 0)
307 { 302 {
308 fprintf(stderr,"get_real_resolution: PgGetVideoModeInfo failed\n"); 303 fprintf(stderr,"get_real_resolution: PgGetVideoModeInfo failed\n");
312 } 307 }
313 } 308 }
314 // *w = DisplayWidth(SDL_Display, SDL_Screen); 309 // *w = DisplayWidth(SDL_Display, SDL_Screen);
315 // *h = DisplayHeight(SDL_Display, SDL_Screen); 310 // *h = DisplayHeight(SDL_Display, SDL_Screen);
316 } 311 }
312 */
317 313
318 int ph_ResizeFullScreen(_THIS) 314 int ph_ResizeFullScreen(_THIS)
319 { 315 {
320 316
321 if ( currently_fullscreen ) { 317 if ( currently_fullscreen ) {
494 { 490 {
495 mymode_settings.mode= (unsigned short) old_video_mode; 491 mymode_settings.mode= (unsigned short) old_video_mode;
496 mymode_settings.refresh= (unsigned short) old_refresh_rate; 492 mymode_settings.refresh= (unsigned short) old_refresh_rate;
497 mymode_settings.flags = 0; 493 mymode_settings.flags = 0;
498 if(PgSetVideoMode(&mymode_settings) < 0) 494 if(PgSetVideoMode(&mymode_settings) < 0)
499 { 495 {
500 fprintf(stderr,"error: PgSetVideoMode failed\n"); 496 fprintf(stderr,"error: PgSetVideoMode failed\n");
501 } 497 }
502 } 498 }
503 499
504 old_video_mode=-1; 500 old_video_mode=-1;
505 old_refresh_rate=-1; 501 old_refresh_rate=-1;
506 502