Mercurial > sdl-ios-xcode
comparison src/video/photon/SDL_ph_modes.c @ 571:8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
From: "Mike Gorchak"
Subject: All QNX patches
whole patches concerning QNX. Almost all code has been rewritten by Julian
and me. Added initial support for hw overlays in QNX and many many others
fixes.
P.S. This patches has been reviewed by Dave Rempel from QSSL and included in
SDL 1.2.5 distribution, which coming on 3rd party CD for newest 6.2.1
version of QNX, which will be available soon.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 20 Jan 2003 01:38:37 +0000 |
parents | 3333b6e68289 |
children | 8bedd6d61642 |
comparison
equal
deleted
inserted
replaced
570:04d6411da49d | 571:8e3ce997621c |
---|---|
29 | 29 |
30 static unsigned long key1, key2; | 30 static unsigned long key1, key2; |
31 static PgVideoModeInfo_t mode_info; | 31 static PgVideoModeInfo_t mode_info; |
32 static PgVideoModes_t mode_list; | 32 static PgVideoModes_t mode_list; |
33 | 33 |
34 /* The current list of available video modes */ | 34 /* The current list of available video modes */ |
35 SDL_Rect SDL_modelist[PH_MAX_VIDEOMODES]; | 35 SDL_Rect SDL_modelist[PH_MAX_VIDEOMODES]; |
36 SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES]; | 36 SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES]; |
37 | 37 |
38 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) |
39 { | 39 { |
40 | 40 if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0) |
41 if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0) | 41 { |
42 { | 42 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", | 43 *(unsigned short*)mode1); |
44 *(unsigned short*)mode1); | 44 return 0; |
45 return 0; | 45 } |
46 } | 46 |
47 key1 = mode_info.width * mode_info.height; | 47 key1 = mode_info.width * mode_info.height; |
48 | 48 |
49 if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0) | 49 if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0) |
50 { | 50 { |
51 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", |
52 *(unsigned short*)mode2); | 52 *(unsigned short*)mode2); |
53 return 0; | 53 return 0; |
54 } | 54 } |
55 key2 = mode_info.width * mode_info.height; | 55 |
56 | 56 key2 = mode_info.width * mode_info.height; |
57 if (key1 > key2) | 57 |
58 return 1; | 58 if (key1 > key2) |
59 else if (key1 == key2) | 59 return 1; |
60 return 0; | 60 else if (key1 == key2) |
61 else | 61 return 0; |
62 return -1; | 62 else |
63 return -1; | |
63 } | 64 } |
64 | 65 |
65 SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | 66 SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) |
66 { | 67 { |
67 int i = 0; | 68 int i = 0; |
114 | 115 |
115 void ph_FreeVideoModes(_THIS) | 116 void ph_FreeVideoModes(_THIS) |
116 { | 117 { |
117 return; | 118 return; |
118 } | 119 } |
119 | |
120 #if 0 | |
121 static void set_best_resolution(_THIS, int width, int height) | |
122 { | |
123 /* warning ! dead variable use_vidmode ! */ | |
124 if ( use_vidmode ) { | |
125 PgDisplaySettings_t settings; | |
126 PgVideoModeInfo_t current_mode_info; | |
127 PgHWCaps_t my_hwcaps; | |
128 unsigned short current_bpp; | |
129 int i; | |
130 /* | |
131 if (PgGetVideoMode( &settings ) < 0) | |
132 { | |
133 fprintf(stderr,"error: PgGetVideoMode failed\n"); | |
134 return; | |
135 } | |
136 if (PgGetVideoModeInfo( settings.mode, ¤t_mode_info ) < 0) | |
137 { | |
138 fprintf(stderr,"error: PgGetVideoModeInfo failed\n"); | |
139 return; | |
140 } | |
141 */ | |
142 //lu_zero | |
143 if (PgGetGraphicsHWCaps(&my_hwcaps) < 0) | |
144 { | |
145 fprintf(stderr,"set_best_resolution: GetGraphicsHWCaps failed!! \n"); | |
146 //that HAVE to work | |
147 } | |
148 if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, ¤t_mode_info) < 0) | |
149 { | |
150 fprintf(stderr,"set_best_resolution: PgGetVideoModeInfo failed\n"); | |
151 } | |
152 current_bpp = current_mode_info.bits_per_pixel; | |
153 | |
154 if (PgGetVideoModeList(&mode_list) >= 0) | |
155 { | |
156 qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res); | |
157 #ifdef PH_DEBUG | |
158 printf("Available modes:\n"); | |
159 for ( i = 0; i < mode_list.num_modes; ++i ) | |
160 { | |
161 PgGetVideoModeInfo(mode_list.modes[i], &mode_info); | |
162 printf("Mode %d: %dx%d\n", i, mode_info.width, mode_info.height); | |
163 } | |
164 #endif | |
165 for ( i = mode_list.num_modes-1; i >= 0 ; --i ) | |
166 { | |
167 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) | |
168 { | |
169 fprintf(stderr,"error: PgGetVideoModeInfo failed\n"); | |
170 } | |
171 if ( (mode_info.width >= width) && | |
172 (mode_info.height >= height) && | |
173 (mode_info.bits_per_pixel == current_bpp) ) | |
174 break; | |
175 } | |
176 if (i >= 0) | |
177 { | |
178 if ( (mode_info.width != current_mode_info.width) || | |
179 (mode_info.height != current_mode_info.height) ) | |
180 { | |
181 settings.mode = mode_list.modes[i]; | |
182 if(PgSetVideoMode( &settings ) < 0) | |
183 { | |
184 fprintf(stderr,"error: PgSetVideoMode failed\n"); | |
185 } | |
186 } | |
187 } | |
188 } | |
189 } | |
190 } | |
191 | |
192 int ph_ResizeFullScreen(_THIS) | |
193 { | |
194 if (currently_fullscreen) | |
195 { | |
196 set_best_resolution(this, current_w, current_h); | |
197 } | |
198 | |
199 return (1); | |
200 } | |
201 #endif /* 0 */ | |
202 | 120 |
203 /* return the mode associated with width, height and bpp */ | 121 /* return the mode associated with width, height and bpp */ |
204 /* if there is no mode then zero is returned */ | 122 /* if there is no mode then zero is returned */ |
205 int get_mode(int width, int height, int bpp) | 123 int get_mode(int width, int height, int bpp) |
206 { | 124 { |
268 if (i<mode_list.num_modes) | 186 if (i<mode_list.num_modes) |
269 { | 187 { |
270 /* get closest bpp */ | 188 /* get closest bpp */ |
271 closest = i++; | 189 closest = i++; |
272 if (mode_info.bits_per_pixel == bpp) | 190 if (mode_info.bits_per_pixel == bpp) |
273 return mode_list.modes[ closest ]; | 191 return mode_list.modes[closest]; |
274 | 192 |
275 min_delta = abs(mode_info.bits_per_pixel - bpp); | 193 min_delta = abs(mode_info.bits_per_pixel - bpp); |
276 while(1) | 194 while(1) |
277 { | 195 { |
278 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) | 196 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) |
298 min_delta = delta; | 216 min_delta = delta; |
299 } | 217 } |
300 i++; | 218 i++; |
301 } | 219 } |
302 } | 220 } |
303 return mode_list.modes[ closest ]; | 221 return mode_list.modes[closest]; |
304 } | 222 } |
305 else | 223 else |
306 return 0; | 224 return 0; |
307 } | 225 } |
308 | |
309 void ph_WaitMapped(_THIS); | |
310 void ph_WaitUnmapped(_THIS); | |
311 void ph_QueueEnterFullScreen(_THIS); | |
312 | 226 |
313 int ph_ToggleFullScreen(_THIS, int on) | 227 int ph_ToggleFullScreen(_THIS, int on) |
314 { | 228 { |
315 if (currently_fullscreen) | 229 if (currently_fullscreen) |
316 { | 230 { |
336 #endif /* HAVE_OPENGL */ | 250 #endif /* HAVE_OPENGL */ |
337 return 0; | 251 return 0; |
338 } | 252 } |
339 } | 253 } |
340 | 254 |
341 if (OCImage.direct_context == NULL) | 255 if (OCImage.direct_context==NULL) |
342 { | 256 { |
343 OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext(); | 257 OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext(); |
344 } | 258 } |
345 | 259 |
346 if (!OCImage.direct_context) | 260 if (!OCImage.direct_context) |
347 { | 261 { |
348 fprintf(stderr, "ph_EnterFullScreen: Can't create direct context\n" ); | 262 fprintf(stderr, "ph_EnterFullScreen(): Can't create direct context !\n"); |
349 } | 263 return 0; |
350 | 264 } |
351 PdDirectStart(OCImage.direct_context); | 265 |
266 OCImage.oldDC=PdDirectStart(OCImage.direct_context); | |
352 | 267 |
353 currently_fullscreen = 1; | 268 currently_fullscreen = 1; |
354 } | 269 } |
355 | 270 |
356 return 1; | 271 return 1; |
370 } | 285 } |
371 else | 286 else |
372 { | 287 { |
373 PdDirectStop(OCImage.direct_context); | 288 PdDirectStop(OCImage.direct_context); |
374 PdReleaseDirectContext(OCImage.direct_context); | 289 PdReleaseDirectContext(OCImage.direct_context); |
375 | 290 PhDCSetCurrent(OCImage.oldDC); |
291 | |
376 currently_fullscreen=0; | 292 currently_fullscreen=0; |
377 | 293 |
378 /* Restore old video mode */ | 294 /* Restore old video mode */ |
379 if (old_video_mode != -1) | 295 if (old_video_mode != -1) |
380 { | 296 { |
382 mymode_settings.refresh= (unsigned short) old_refresh_rate; | 298 mymode_settings.refresh= (unsigned short) old_refresh_rate; |
383 mymode_settings.flags= 0; | 299 mymode_settings.flags= 0; |
384 | 300 |
385 if (PgSetVideoMode(&mymode_settings) < 0) | 301 if (PgSetVideoMode(&mymode_settings) < 0) |
386 { | 302 { |
387 fprintf(stderr,"error: PgSetVideoMode failed\n"); | 303 fprintf(stderr, "Ph_LeaveFullScreen(): PgSetVideoMode failed !\n"); |
304 return 0; | |
388 } | 305 } |
389 } | 306 } |
390 | 307 |
391 old_video_mode=-1; | 308 old_video_mode=-1; |
392 old_refresh_rate=-1; | 309 old_refresh_rate=-1; |