annotate src/video/photon/SDL_ph_modes.c @ 512:fd7d603845dd

*** empty log message ***
author Sam Lantinga <slouken@libsdl.org>
date Sun, 06 Oct 2002 18:38:12 +0000
parents 3333b6e68289
children 8e3ce997621c
rev   line source
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
13 Library General Public License for more details.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
22
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23 #ifdef SAVE_RCSID
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 static char rcsid =
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25 "@(#) $Id$";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 #include "SDL_ph_modes_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 static unsigned long key1, key2;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 static PgVideoModeInfo_t mode_info;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
37
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38 static int compare_modes_by_res(const void* mode1, const void* mode2)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
42 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43 fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44 *(unsigned short*)mode1);
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
45 return 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47 key1 = mode_info.width * mode_info.height;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50 {
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
51 fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52 *(unsigned short*)mode2);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
53 return 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
54 }
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
55 key2 = mode_info.width * mode_info.height;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
56
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
57 if (key1 > key2)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
58 return 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
59 else if (key1 == key2)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
60 return 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
61 else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
62 return -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
63 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
64
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
65 SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
66 {
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
67 int i = 0;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
68 int j = 0;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
69 SDL_Rect Amodelist[PH_MAX_VIDEOMODES];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
70
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
71 for (i=0; i<PH_MAX_VIDEOMODES; i++)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
72 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
73 SDL_modearray[i]=&SDL_modelist[i];
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
74 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
75
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
76 if (PgGetVideoModeList( &mode_list ) < 0)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
77 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
78 fprintf(stderr,"error: PgGetVideoModeList failed\n");
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
79 return NULL;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
80 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
81
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
82 mode_info.bits_per_pixel = 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
83
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
84 for (i=0; i < mode_list.num_modes; i++)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
85 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
86 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
87 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
88 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
89 return NULL;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
90 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
91 if(mode_info.bits_per_pixel == format->BitsPerPixel)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
92 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
93 Amodelist[j].w = mode_info.width;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
94 Amodelist[j].h = mode_info.height;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
95 Amodelist[j].x = 0;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
96 Amodelist[j].y = 0;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
97 j++;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
98 }
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 /* 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
102
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
103 for(i=0; i<j; i++)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
104 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
105 SDL_modelist[i].w = Amodelist[j - i -1].w;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
106 SDL_modelist[i].h = Amodelist[j - i -1].h;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
107 SDL_modelist[i].x = Amodelist[j - i -1].x;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
108 SDL_modelist[i].y = Amodelist[j - i -1].y;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
109 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
110 SDL_modearray[j]=NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
111
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
112 return SDL_modearray;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
114
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115 void ph_FreeVideoModes(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
116 {
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
117 return;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
120 #if 0
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121 static void set_best_resolution(_THIS, int width, int height)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122 {
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
123 /* warning ! dead variable use_vidmode ! */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
124 if ( use_vidmode ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
125 PgDisplaySettings_t settings;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126 PgVideoModeInfo_t current_mode_info;
204
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
127 PgHWCaps_t my_hwcaps;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
128 unsigned short current_bpp;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 int i;
204
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
130 /*
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 if (PgGetVideoMode( &settings ) < 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
132 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
133 fprintf(stderr,"error: PgGetVideoMode failed\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
134 return;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
135 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
136 if (PgGetVideoModeInfo( settings.mode, &current_mode_info ) < 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
137 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
138 fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
139 return;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
140 }
204
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
141 */
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
142 //lu_zero
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
143 if (PgGetGraphicsHWCaps(&my_hwcaps) < 0)
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
144 {
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
145 fprintf(stderr,"set_best_resolution: GetGraphicsHWCaps failed!! \n");
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
146 //that HAVE to work
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
147 }
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
148 if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &current_mode_info) < 0)
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
149 {
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
150 fprintf(stderr,"set_best_resolution: PgGetVideoModeInfo failed\n");
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 0
diff changeset
151 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152 current_bpp = current_mode_info.bits_per_pixel;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
153
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154 if (PgGetVideoModeList(&mode_list) >= 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
155 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156 qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157 #ifdef PH_DEBUG
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 printf("Available modes:\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
159 for ( i = 0; i < mode_list.num_modes; ++i )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
161 PgGetVideoModeInfo(mode_list.modes[i], &mode_info);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
162 printf("Mode %d: %dx%d\n", i, mode_info.width, mode_info.height);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
163 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
164 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
165 for ( i = mode_list.num_modes-1; i >= 0 ; --i )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
166 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
167 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
168 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
169 fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
170 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
171 if ( (mode_info.width >= width) &&
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
172 (mode_info.height >= height) &&
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173 (mode_info.bits_per_pixel == current_bpp) )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
174 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
175 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
176 if (i >= 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
177 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 if ( (mode_info.width != current_mode_info.width) ||
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
179 (mode_info.height != current_mode_info.height) )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
181 settings.mode = mode_list.modes[i];
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182 if(PgSetVideoMode( &settings ) < 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
183 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184 fprintf(stderr,"error: PgSetVideoMode failed\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
185 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
186 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
187 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
188 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
189 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
190 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
191
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
192 int ph_ResizeFullScreen(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
193 {
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
194 if (currently_fullscreen)
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
195 {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
196 set_best_resolution(this, current_w, current_h);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
197 }
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
198
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
199 return (1);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
200 }
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
201 #endif /* 0 */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
202
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
203 /* return the mode associated with width, height and bpp */
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
204 /* if there is no mode then zero is returned */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
205 int get_mode(int width, int height, int bpp)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
206 {
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
207 int i;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
208
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
209 if(width<640)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
210 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
211 width=640;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
212 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
213 if(height<480)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
214 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
215 height=480;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
216 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
217
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
218 if (PgGetVideoModeList(&mode_list) < 0)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
219 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
220 fprintf(stderr,"error: PgGetVideoModeList failed\n");
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
221 return -1;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
222 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
223
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
224 /* search list for exact match */
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
225 for (i=0;i<mode_list.num_modes;i++)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
226 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
227 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
228 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
229 fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
230 return 0;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
231 }
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 if ((mode_info.width == width) &&
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
234 (mode_info.height == height) &&
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
235 (mode_info.bits_per_pixel == bpp))
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
236 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
237 return mode_list.modes[i];
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
238 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
239 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
240
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
241 return (i == mode_list.num_modes) ? 0 : mode_list.modes[i];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
242 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
243
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
244 int get_mode_any_format(int width, int height, int bpp)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
245 /* return the mode associated with width, height and bpp */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
246 /* if requested bpp is not found the mode with closest bpp is returned */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
247 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
248 int i, closest, delta, min_delta;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
249
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
250 if (PgGetVideoModeList( &mode_list ) < 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
251 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
252 fprintf(stderr,"error: PgGetVideoModeList failed\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
253 return -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
254 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
255
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
256 qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
257 for(i=0;i<mode_list.num_modes;i++)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
258 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
259 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
260 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
261 fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
262 return 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
263 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
264 if ((mode_info.width == width) &&
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
265 (mode_info.height == height))
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
266 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
267 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
268 if (i<mode_list.num_modes)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
269 {
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
270 /* get closest bpp */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
271 closest = i++;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
272 if (mode_info.bits_per_pixel == bpp)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
273 return mode_list.modes[ closest ];
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
274
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
275 min_delta = abs(mode_info.bits_per_pixel - bpp);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
276 while(1)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
277 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
278 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
279 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
280 fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
281 return 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
282 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
283
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
284 if ((mode_info.width != width) ||
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
285 (mode_info.height != height))
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
286 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
287 else if (mode_info.bits_per_pixel == bpp)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
288 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
289 closest = i;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
290 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
291 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
292 else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
293 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
294 delta = abs(mode_info.bits_per_pixel - bpp);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
295 if (delta < min_delta)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
296 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
297 closest = i;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
298 min_delta = delta;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
299 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
300 i++;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
301 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
302 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
303 return mode_list.modes[ closest ];
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
304 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
305 else
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
306 return 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
307 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
308
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
309 void ph_WaitMapped(_THIS);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
310 void ph_WaitUnmapped(_THIS);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
311 void ph_QueueEnterFullScreen(_THIS);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
312
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
313 int ph_ToggleFullScreen(_THIS, int on)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
314 {
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
315 if (currently_fullscreen)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
316 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
317 return ph_LeaveFullScreen(this);
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
318 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
319 else
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
320 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
321 return ph_EnterFullScreen(this);
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
322 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
323
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
324 return 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
325 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
326
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
327 int ph_EnterFullScreen(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
328 {
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
329 if (!currently_fullscreen)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
330 {
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
331 if (this->screen)
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
332 {
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
333 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
334 {
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
335 #ifdef HAVE_OPENGL
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
336 #endif /* HAVE_OPENGL */
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
337 return 0;
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
338 }
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
339 }
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
340
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
341 if (OCImage.direct_context == NULL)
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
342 {
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
343 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
344 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
345
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
346 if (!OCImage.direct_context)
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
347 {
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
348 fprintf(stderr, "ph_EnterFullScreen: Can't create direct context\n" );
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
349 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
350
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
351 PdDirectStart(OCImage.direct_context);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
352
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
353 currently_fullscreen = 1;
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
354 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
355
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
356 return 1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
357 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
358
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
359 int ph_LeaveFullScreen(_THIS)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
360 {
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
361 PgDisplaySettings_t mymode_settings;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
362
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
363 if (currently_fullscreen)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
364 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
365 if ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
366 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
367 #ifdef HAVE_OPENGL
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
368 #endif /* HAVE_OPENGL */
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
369 return 0;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
370 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
371 else
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
372 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
373 PdDirectStop(OCImage.direct_context);
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
374 PdReleaseDirectContext(OCImage.direct_context);
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
375
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
376 currently_fullscreen=0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
377
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
378 /* Restore old video mode */
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
379 if (old_video_mode != -1)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
380 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
381 mymode_settings.mode= (unsigned short) old_video_mode;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
382 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
383 mymode_settings.flags= 0;
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
384
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
385 if (PgSetVideoMode(&mymode_settings) < 0)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
386 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
387 fprintf(stderr,"error: PgSetVideoMode failed\n");
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
388 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
389 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
390
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
391 old_video_mode=-1;
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
392 old_refresh_rate=-1;
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
393 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
394
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
395 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
396 return 1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
397 }