Mercurial > sdl-ios-xcode
annotate src/video/photon/SDL_ph_modes.c @ 597:5e738444b658
*** empty log message ***
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 10 Feb 2003 00:39:33 +0000 |
parents | 8e3ce997621c |
children | 8bedd6d61642 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
297
f6ffac90895c
Updated copyright information for 2002
Sam Lantinga <slouken@libsdl.org>
parents:
266
diff
changeset
|
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
204
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 #include "SDL_ph_modes_c.h" | |
29 | |
30 static unsigned long key1, key2; | |
31 static PgVideoModeInfo_t mode_info; | |
32 static PgVideoModes_t mode_list; | |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
33 |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
34 /* The current list of available video modes */ |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
35 SDL_Rect SDL_modelist[PH_MAX_VIDEOMODES]; |
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
36 SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES]; |
0 | 37 |
38 static int compare_modes_by_res(const void* mode1, const void* mode2) | |
39 { | |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
40 if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0) |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
41 { |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
42 fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n", |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
43 *(unsigned short*)mode1); |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
44 return 0; |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
45 } |
0 | 46 |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
47 key1 = mode_info.width * mode_info.height; |
0 | 48 |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
49 if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0) |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
50 { |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
51 fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n", |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
52 *(unsigned short*)mode2); |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
53 return 0; |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
54 } |
0 | 55 |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
56 key2 = mode_info.width * mode_info.height; |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
57 |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
58 if (key1 > key2) |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
59 return 1; |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
60 else if (key1 == key2) |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
61 return 0; |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
62 else |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
63 return -1; |
0 | 64 } |
65 | |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
66 SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) |
0 | 67 { |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
68 int i = 0; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
69 int j = 0; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
70 SDL_Rect Amodelist[PH_MAX_VIDEOMODES]; |
0 | 71 |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
72 for (i=0; i<PH_MAX_VIDEOMODES; i++) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
73 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
74 SDL_modearray[i]=&SDL_modelist[i]; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
75 } |
0 | 76 |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
77 if (PgGetVideoModeList( &mode_list ) < 0) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
78 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
79 fprintf(stderr,"error: PgGetVideoModeList failed\n"); |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
80 return NULL; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
81 } |
0 | 82 |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
83 mode_info.bits_per_pixel = 0; |
0 | 84 |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
85 for (i=0; i < mode_list.num_modes; i++) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
86 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
87 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
88 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
89 fprintf(stderr,"error: PgGetVideoModeInfo failed on mode: 0x%x\n", mode_list.modes[i]); |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
90 return NULL; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
91 } |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
92 if(mode_info.bits_per_pixel == format->BitsPerPixel) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
93 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
94 Amodelist[j].w = mode_info.width; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
95 Amodelist[j].h = mode_info.height; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
96 Amodelist[j].x = 0; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
97 Amodelist[j].y = 0; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
98 j++; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
99 } |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
100 } |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
101 |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
102 /* reorder biggest for smallest, assume width dominates */ |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
103 |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
104 for(i=0; i<j; i++) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
105 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
106 SDL_modelist[i].w = Amodelist[j - i -1].w; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
107 SDL_modelist[i].h = Amodelist[j - i -1].h; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
108 SDL_modelist[i].x = Amodelist[j - i -1].x; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
109 SDL_modelist[i].y = Amodelist[j - i -1].y; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
110 } |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
111 SDL_modearray[j]=NULL; |
0 | 112 |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
113 return SDL_modearray; |
0 | 114 } |
115 | |
116 void ph_FreeVideoModes(_THIS) | |
117 { | |
266
c6abdda2f666
Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
118 return; |
0 | 119 } |
120 | |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
121 /* return the mode associated with width, height and bpp */ |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
122 /* if there is no mode then zero is returned */ |
0 | 123 int get_mode(int width, int height, int bpp) |
124 { | |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
125 int i; |
0 | 126 |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
127 if(width<640) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
128 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
129 width=640; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
130 } |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
131 if(height<480) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
132 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
133 height=480; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
134 } |
0 | 135 |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
136 if (PgGetVideoModeList(&mode_list) < 0) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
137 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
138 fprintf(stderr,"error: PgGetVideoModeList failed\n"); |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
139 return -1; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
140 } |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
141 |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
142 /* search list for exact match */ |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
143 for (i=0;i<mode_list.num_modes;i++) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
144 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
145 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
146 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
147 fprintf(stderr,"error: PgGetVideoModeInfo failed\n"); |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
148 return 0; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
149 } |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
150 |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
151 if ((mode_info.width == width) && |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
152 (mode_info.height == height) && |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
153 (mode_info.bits_per_pixel == bpp)) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
154 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
155 return mode_list.modes[i]; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
156 } |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
157 } |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
158 |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
159 return (i == mode_list.num_modes) ? 0 : mode_list.modes[i]; |
0 | 160 } |
161 | |
162 int get_mode_any_format(int width, int height, int bpp) | |
163 /* return the mode associated with width, height and bpp */ | |
164 /* if requested bpp is not found the mode with closest bpp is returned */ | |
165 { | |
166 int i, closest, delta, min_delta; | |
167 | |
168 if (PgGetVideoModeList( &mode_list ) < 0) | |
169 { | |
170 fprintf(stderr,"error: PgGetVideoModeList failed\n"); | |
171 return -1; | |
172 } | |
173 | |
174 qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res); | |
175 for(i=0;i<mode_list.num_modes;i++) | |
176 { | |
177 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) | |
178 { | |
179 fprintf(stderr,"error: PgGetVideoModeInfo failed\n"); | |
180 return 0; | |
181 } | |
182 if ((mode_info.width == width) && | |
183 (mode_info.height == height)) | |
184 break; | |
185 } | |
186 if (i<mode_list.num_modes) | |
187 { | |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
188 /* get closest bpp */ |
0 | 189 closest = i++; |
190 if (mode_info.bits_per_pixel == bpp) | |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
191 return mode_list.modes[closest]; |
0 | 192 |
193 min_delta = abs(mode_info.bits_per_pixel - bpp); | |
194 while(1) | |
195 { | |
196 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) | |
197 { | |
198 fprintf(stderr,"error: PgGetVideoModeInfo failed\n"); | |
199 return 0; | |
200 } | |
201 | |
202 if ((mode_info.width != width) || | |
203 (mode_info.height != height)) | |
204 break; | |
205 else if (mode_info.bits_per_pixel == bpp) | |
206 { | |
207 closest = i; | |
208 break; | |
209 } | |
210 else | |
211 { | |
212 delta = abs(mode_info.bits_per_pixel - bpp); | |
213 if (delta < min_delta) | |
214 { | |
215 closest = i; | |
216 min_delta = delta; | |
217 } | |
218 i++; | |
219 } | |
220 } | |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
221 return mode_list.modes[closest]; |
0 | 222 } |
223 else | |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
224 return 0; |
0 | 225 } |
226 | |
227 int ph_ToggleFullScreen(_THIS, int on) | |
228 { | |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
229 if (currently_fullscreen) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
230 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
231 return ph_LeaveFullScreen(this); |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
232 } |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
233 else |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
234 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
235 return ph_EnterFullScreen(this); |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
236 } |
0 | 237 |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
238 return 0; |
0 | 239 } |
240 | |
241 int ph_EnterFullScreen(_THIS) | |
242 { | |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
243 if (!currently_fullscreen) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
244 { |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
245 if (this->screen) |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
246 { |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
247 if ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL) |
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
248 { |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
249 #ifdef HAVE_OPENGL |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
250 #endif /* HAVE_OPENGL */ |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
251 return 0; |
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
252 } |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
253 } |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
254 |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
255 if (OCImage.direct_context==NULL) |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
256 { |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
257 OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext(); |
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
258 } |
0 | 259 |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
260 if (!OCImage.direct_context) |
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
261 { |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
262 fprintf(stderr, "ph_EnterFullScreen(): Can't create direct context !\n"); |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
263 return 0; |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
264 } |
0 | 265 |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
266 OCImage.oldDC=PdDirectStart(OCImage.direct_context); |
0 | 267 |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
268 currently_fullscreen = 1; |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
269 } |
0 | 270 |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
271 return 1; |
0 | 272 } |
273 | |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
274 int ph_LeaveFullScreen(_THIS) |
0 | 275 { |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
276 PgDisplaySettings_t mymode_settings; |
0 | 277 |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
278 if (currently_fullscreen) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
279 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
280 if ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
281 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
282 #ifdef HAVE_OPENGL |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
283 #endif /* HAVE_OPENGL */ |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
284 return 0; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
285 } |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
286 else |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
287 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
288 PdDirectStop(OCImage.direct_context); |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
289 PdReleaseDirectContext(OCImage.direct_context); |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
290 PhDCSetCurrent(OCImage.oldDC); |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
291 |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
292 currently_fullscreen=0; |
0 | 293 |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
294 /* Restore old video mode */ |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
295 if (old_video_mode != -1) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
296 { |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
297 mymode_settings.mode= (unsigned short) old_video_mode; |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
298 mymode_settings.refresh= (unsigned short) old_refresh_rate; |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
299 mymode_settings.flags= 0; |
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
300 |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
301 if (PgSetVideoMode(&mymode_settings) < 0) |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
302 { |
571
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
303 fprintf(stderr, "Ph_LeaveFullScreen(): PgSetVideoMode failed !\n"); |
8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
315
diff
changeset
|
304 return 0; |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
305 } |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
306 } |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
307 |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
308 old_video_mode=-1; |
315
3333b6e68289
Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
309
diff
changeset
|
309 old_refresh_rate=-1; |
309
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
310 } |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
311 |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
312 } |
2de77f7b7a28
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
313 return 1; |
0 | 314 } |