comparison src/video/photon/SDL_ph_modes.c @ 821:30168104389f

Date: Sat, 14 Feb 2004 14:52:40 +0200 From: "Mike Gorchak" Subject: Batch of the QNX6 fixes for the SDL 1. Updated readme.QNX 2. Fixed crashes during intensive window updating under fast machines (got over 200 rectangles for update). 3. Fixed double-buffered fullscreen modes, now it works as needed. 4. Fixed Photon detection algorithm. 5. Fixed HWSURFACE update function. 6. Added SDL_PHOTON_FULLSCREEN_REFRESH environment variable support for control refresh rates under Photon. 7. Added 640x400 fullscreen mode emulation via 640x480 (if videodriver not supports original 640x400 mode of course) shifted by 40 vertical pixels from begin, to center it. It's needed for some old DOS games which ran in doubled 320x200 mode. 8. Added available video ram amount support. 8. Added hardware surface allocation/deallocation support if current videomode and videodriver supports it. 9. Added hardware filling support. 10. Added hardware blits support (simple and colorkeyed). And I've added to testvidinfo test color-keyed blits benchmark (maybe need to add alpha blits benchmark too ?). Currently Photon not supporting any alpha hardware blittings (all drivers lack of alpha blitting code support, only software alpha blitting exist in photon, which is hundreds times slowest than the SDL's one). So I've not added the alpha support. I suppose new QNX 6.3 will have the hardware alpha support, so when it will be done, I'll add alpha support.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 14 Feb 2004 20:22:21 +0000
parents b8d311d90021
children 4ab6d1fd028f
comparison
equal deleted inserted replaced
820:0b9b4bf3c1e7 821:30168104389f
78 for (i=0; i<PH_MAX_VIDEOMODES; i++) 78 for (i=0; i<PH_MAX_VIDEOMODES; i++)
79 { 79 {
80 SDL_modearray[i]=&SDL_modelist[i]; 80 SDL_modearray[i]=&SDL_modelist[i];
81 } 81 }
82 82
83 if (PgGetVideoModeList( &mode_list ) < 0) 83 if (PgGetVideoModeList(&mode_list) < 0)
84 { 84 {
85 SDL_SetError("ph_ListModes(): PgGetVideoModeList() function failed !\n"); 85 SDL_SetError("ph_ListModes(): PgGetVideoModeList() function failed !\n");
86 return NULL; 86 return NULL;
87 } 87 }
88 88
107 107
108 /* reorder biggest for smallest, assume width dominates */ 108 /* reorder biggest for smallest, assume width dominates */
109 109
110 for(i=0; i<j; i++) 110 for(i=0; i<j; i++)
111 { 111 {
112 SDL_modelist[i].w = Amodelist[j - i -1].w; 112 SDL_modelist[i].w = Amodelist[j - i - 1].w;
113 SDL_modelist[i].h = Amodelist[j - i -1].h; 113 SDL_modelist[i].h = Amodelist[j - i - 1].h;
114 SDL_modelist[i].x = Amodelist[j - i -1].x; 114 SDL_modelist[i].x = Amodelist[j - i - 1].x;
115 SDL_modelist[i].y = Amodelist[j - i -1].y; 115 SDL_modelist[i].y = Amodelist[j - i - 1].y;
116 } 116 }
117 SDL_modearray[j]=NULL; 117 SDL_modearray[j]=NULL;
118 118
119 return SDL_modearray; 119 return SDL_modearray;
120 } 120 }
127 /* return the mode associated with width, height and bpp */ 127 /* return the mode associated with width, height and bpp */
128 /* if there is no mode then zero is returned */ 128 /* if there is no mode then zero is returned */
129 int ph_GetVideoMode(int width, int height, int bpp) 129 int ph_GetVideoMode(int width, int height, int bpp)
130 { 130 {
131 int i; 131 int i;
132 int modestage=0;
133 int closestmode=0;
132 134
133 if (PgGetVideoModeList(&mode_list) < 0) 135 if (PgGetVideoModeList(&mode_list) < 0)
134 { 136 {
135 return -1; 137 return -1;
136 } 138 }
137 139
140 /* special case for the double-sized 320x200 mode */
141 if ((width==640) && (height==400))
142 {
143 modestage=1;
144 }
145
138 /* search list for exact match */ 146 /* search list for exact match */
139 for (i=0;i<mode_list.num_modes;i++) 147 for (i=0; i<mode_list.num_modes; i++)
140 { 148 {
141 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) 149 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
142 { 150 {
143 return 0; 151 return 0;
144 } 152 }
145 153
146 if ((mode_info.width == width) && 154 if ((mode_info.width == width) && (mode_info.height == height) &&
147 (mode_info.height == height) &&
148 (mode_info.bits_per_pixel == bpp)) 155 (mode_info.bits_per_pixel == bpp))
149 { 156 {
150 return mode_list.modes[i]; 157 return mode_list.modes[i];
151 } 158 }
159 else
160 {
161 if ((modestage) && (mode_info.width == width) && (mode_info.height == height+80) &&
162 (mode_info.bits_per_pixel == bpp))
163 {
164 modestage=2;
165 closestmode=mode_list.modes[i];
166 }
167 }
168 }
169
170 /* if we are here, then no 640x400xbpp mode found and we'll emulate it via 640x480xbpp mode */
171 if (modestage==2)
172 {
173 return closestmode;
152 } 174 }
153 175
154 return (i == mode_list.num_modes) ? 0 : mode_list.modes[i]; 176 return (i == mode_list.num_modes) ? 0 : mode_list.modes[i];
155 } 177 }
156 178
157 /* return the mode associated with width, height and bpp */ 179 /* return the mode associated with width, height and bpp */
158 /* if requested bpp is not found the mode with closest bpp is returned */ 180 /* if requested bpp is not found the mode with closest bpp is returned */
159 int get_mode_any_format(int width, int height, int bpp) 181 int get_mode_any_format(int width, int height, int bpp)
160 { 182 {
161 int i, closest, delta, min_delta; 183 int i, closest, delta, min_delta;
162 184
233 255
234 int ph_EnterFullScreen(_THIS, SDL_Surface* screen) 256 int ph_EnterFullScreen(_THIS, SDL_Surface* screen)
235 { 257 {
236 PgDisplaySettings_t settings; 258 PgDisplaySettings_t settings;
237 int mode; 259 int mode;
260 char* refreshrate;
261 int refreshratenum;
238 262
239 if (!currently_fullscreen) 263 if (!currently_fullscreen)
240 { 264 {
241 /* Get the video mode and set it */ 265 /* Get the video mode and set it */
242 if (screen->flags & SDL_ANYFORMAT) 266 if (screen->flags & SDL_ANYFORMAT)
251 { 275 {
252 if ((mode = ph_GetVideoMode(screen->w, screen->h, screen->format->BitsPerPixel)) == 0) 276 if ((mode = ph_GetVideoMode(screen->w, screen->h, screen->format->BitsPerPixel)) == 0)
253 { 277 {
254 SDL_SetError("ph_EnterFullScreen(): can't find appropriate video mode !\n"); 278 SDL_SetError("ph_EnterFullScreen(): can't find appropriate video mode !\n");
255 return 0; 279 return 0;
280 }
281 if (PgGetVideoModeInfo(mode, &mode_info) < 0)
282 {
283 SDL_SetError("ph_EnterFullScreen(): can't get video mode capabilities !\n");
284 return 0;
285 }
286 if (mode_info.height != screen->h)
287 {
288 if ((mode_info.height==480) && (screen->h==400))
289 {
290 videomode_emulatemode=1;
291 }
292 }
293 else
294 {
295 videomode_emulatemode=0;
256 } 296 }
257 } 297 }
258 298
259 /* save old video mode caps */ 299 /* save old video mode caps */
260 PgGetVideoMode(&settings); 300 PgGetVideoMode(&settings);
263 303
264 /* setup new video mode */ 304 /* setup new video mode */
265 settings.mode = mode; 305 settings.mode = mode;
266 settings.refresh = 0; 306 settings.refresh = 0;
267 settings.flags = 0; 307 settings.flags = 0;
308
309 refreshrate=getenv("SDL_PHOTON_FULLSCREEN_REFRESH");
310 if (refreshrate!=NULL)
311 {
312 if (sscanf(refreshrate, "%d", &refreshratenum)==1)
313 {
314 settings.refresh = refreshratenum;
315 }
316 }
268 317
269 if (PgSetVideoMode(&settings) < 0) 318 if (PgSetVideoMode(&settings) < 0)
270 { 319 {
271 SDL_SetError("ph_EnterFullScreen(): PgSetVideoMode() call failed !\n"); 320 SDL_SetError("ph_EnterFullScreen(): PgSetVideoMode() call failed !\n");
272 return 0; 321 return 0;