annotate src/video/photon/SDL_ph_modes.c @ 712:8be92df64b22

Finally bugfixed: the simpler the better
author Patrice Mandin <patmandin@gmail.com>
date Wed, 03 Sep 2003 20:07:16 +0000
parents 04dd6c6d7c30
children b8d311d90021
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
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
28 #include "SDL_error.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29 #include "SDL_ph_modes_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 static unsigned long key1, key2;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32 static PgVideoModeInfo_t mode_info;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 static PgVideoModes_t mode_list;
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
34
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
35 /* 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
36 SDL_Rect SDL_modelist[PH_MAX_VIDEOMODES];
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
37 SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39 static int compare_modes_by_res(const void* mode1, const void* mode2)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40 {
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
41 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
42 {
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
43 return 0;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
44 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
46 key1 = mode_info.width * mode_info.height;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
48 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
49 {
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
50 return 0;
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
51 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
53 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
54
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
55 if (key1 > key2)
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
56 {
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
57 return 1;
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
58 }
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
59 else
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
60 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
61 if (key1 == key2)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
62 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
63 return 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
64 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
65 else
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
66 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
67 return -1;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
68 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
69 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
70 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
71
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
72 SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 {
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
74 int i = 0;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
75 int j = 0;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
76 SDL_Rect Amodelist[PH_MAX_VIDEOMODES];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
77
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
78 for (i=0; i<PH_MAX_VIDEOMODES; i++)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
79 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
80 SDL_modearray[i]=&SDL_modelist[i];
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
81 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
82
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
83 if (PgGetVideoModeList( &mode_list ) < 0)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
84 {
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
85 SDL_SetError("ph_ListModes(): PgGetVideoModeList() function failed !\n");
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
86 return NULL;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
87 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
88
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
89 mode_info.bits_per_pixel = 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
90
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
91 for (i=0; i < mode_list.num_modes; i++)
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 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
94 {
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
95 SDL_SetError("ph_ListModes(): PgGetVideoModeInfo() function failed on mode: 0x%X.\n", mode_list.modes[i]);
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
96 return NULL;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
97 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
98 if(mode_info.bits_per_pixel == format->BitsPerPixel)
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 Amodelist[j].w = mode_info.width;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
101 Amodelist[j].h = mode_info.height;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
102 Amodelist[j].x = 0;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
103 Amodelist[j].y = 0;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
104 j++;
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 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
107
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
108 /* 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
109
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
110 for(i=0; i<j; i++)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
111 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
112 SDL_modelist[i].w = Amodelist[j - i -1].w;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
113 SDL_modelist[i].h = Amodelist[j - i -1].h;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
114 SDL_modelist[i].x = Amodelist[j - i -1].x;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
115 SDL_modelist[i].y = Amodelist[j - i -1].y;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
116 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
117 SDL_modearray[j]=NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
119 return SDL_modearray;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
120 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122 void ph_FreeVideoModes(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
123 {
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
124 return;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
125 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
127 /* return the mode associated with width, height and bpp */
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
128 /* if there is no mode then zero is returned */
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
129 int ph_GetVideoMode(int width, int height, int bpp)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
130 {
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
131 int i;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
132
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
133 if (PgGetVideoModeList(&mode_list) < 0)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
134 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
135 return -1;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
136 }
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 /* search list for exact match */
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
139 for (i=0;i<mode_list.num_modes;i++)
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 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
142 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
143 return 0;
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
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
146 if ((mode_info.width == width) &&
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
147 (mode_info.height == height) &&
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
148 (mode_info.bits_per_pixel == bpp))
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 return mode_list.modes[i];
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
151 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
152 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
153
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
154 return (i == mode_list.num_modes) ? 0 : mode_list.modes[i];
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157 /* return the mode associated with width, height and bpp */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 /* if requested bpp is not found the mode with closest bpp is returned */
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
159 int get_mode_any_format(int width, int height, int bpp)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
161 int i, closest, delta, min_delta;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
162
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
163 if (PgGetVideoModeList(&mode_list) < 0)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
164 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
165 return -1;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
166 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
167
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
168 qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
169
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
170 for(i=0;i<mode_list.num_modes;i++)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
171 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
172 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
173 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
174 return 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
175 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
176 if ((mode_info.width == width) && (mode_info.height == height))
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
177 {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 break;
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
179 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
180 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
181
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
182 if (i<mode_list.num_modes)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
183 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
184 /* get closest bpp */
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
185 closest = i++;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
186 if (mode_info.bits_per_pixel == bpp)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
187 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
188 return mode_list.modes[closest];
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
189 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
190
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
191 min_delta = abs(mode_info.bits_per_pixel - bpp);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
192
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
193 while(1)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
194 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
195 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
196 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
197 return 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
198 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
199
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
200 if ((mode_info.width != width) || (mode_info.height != height))
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
201 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
202 break;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
203 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
204 else
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
205 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
206 if (mode_info.bits_per_pixel == bpp)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
207 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
208 closest = i;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
209 break;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
210 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
211 else
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
212 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
213 delta = abs(mode_info.bits_per_pixel - bpp);
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
214 if (delta < min_delta)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
215 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
216 closest = i;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
217 min_delta = delta;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
218 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
219 i++;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
220 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
221 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
222 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
223 return mode_list.modes[closest];
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
224 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
225
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
226 return 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
227 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
228
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
229 int ph_ToggleFullScreen(_THIS, int on)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
230 {
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
231 return -1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
232 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
233
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
234 int ph_EnterFullScreen(_THIS, SDL_Surface* screen)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
235 {
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
236 PgDisplaySettings_t settings;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
237 int mode;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
238
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
239 if (!currently_fullscreen)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
240 {
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
241 /* Get the video mode and set it */
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
242 if (screen->flags & SDL_ANYFORMAT)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
243 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
244 if ((mode = get_mode_any_format(screen->w, screen->h, screen->format->BitsPerPixel)) == 0)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
245 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
246 SDL_SetError("ph_EnterFullScreen(): can't find appropriate video mode !\n");
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
247 return 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
248 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
249 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
250 else
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
251 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
252 if ((mode = ph_GetVideoMode(screen->w, screen->h, screen->format->BitsPerPixel)) == 0)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
253 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
254 SDL_SetError("ph_EnterFullScreen(): can't find appropriate video mode !\n");
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
255 return 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
256 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
257 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
258
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
259 /* save old video mode caps */
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
260 PgGetVideoMode(&settings);
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
261 old_video_mode=settings.mode;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
262 old_refresh_rate=settings.refresh;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
263
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
264 /* setup new video mode */
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
265 settings.mode = mode;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
266 settings.refresh = 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
267 settings.flags = 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
268
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
269 if (PgSetVideoMode(&settings) < 0)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
270 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
271 SDL_SetError("ph_EnterFullScreen(): PgSetVideoMode() call failed !\n");
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
272 return 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
273 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
274
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
275 if (this->screen)
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
276 {
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
277 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
278 {
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
279 #ifdef HAVE_OPENGL
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
280 #endif /* HAVE_OPENGL */
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
281 return 0;
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
282 }
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
283 }
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
284
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
285 if (OCImage.direct_context==NULL)
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
286 {
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
287 OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext();
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
288 if (!OCImage.direct_context)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
289 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
290 SDL_SetError("ph_EnterFullScreen(): Can't create direct context !\n");
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
291 ph_LeaveFullScreen(this);
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
292 return 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
293 }
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
294 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
295
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
296 OCImage.oldDC=PdDirectStart(OCImage.direct_context);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
297
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
298 currently_fullscreen = 1;
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
299 }
692
04dd6c6d7c30 Date: Fri, 15 Aug 2003 09:13:59 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
300 PgFlush();
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
301
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
302 return 1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
303 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
304
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
305 int ph_LeaveFullScreen(_THIS)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
306 {
692
04dd6c6d7c30 Date: Fri, 15 Aug 2003 09:13:59 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
307 PgDisplaySettings_t oldmode_settings;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
308
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
309 if (currently_fullscreen)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
310 {
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
311 if ((this->screen) && ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL))
309
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 #ifdef HAVE_OPENGL
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
314 #endif /* HAVE_OPENGL */
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
315 return 0;
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 else
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
318 {
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
319 if (OCImage.direct_context)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
320 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
321 PdDirectStop(OCImage.direct_context);
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
322 PdReleaseDirectContext(OCImage.direct_context);
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
323 OCImage.direct_context=NULL;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
324 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
325 if (OCImage.oldDC)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
326 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
327 PhDCSetCurrent(OCImage.oldDC);
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
328 OCImage.oldDC=NULL;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
329 }
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
330
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
331 currently_fullscreen=0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
332
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
333 /* Restore old video mode */
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
334 if (old_video_mode != -1)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
335 {
692
04dd6c6d7c30 Date: Fri, 15 Aug 2003 09:13:59 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
336 oldmode_settings.mode = (unsigned short) old_video_mode;
04dd6c6d7c30 Date: Fri, 15 Aug 2003 09:13:59 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
337 oldmode_settings.refresh = (unsigned short) old_refresh_rate;
04dd6c6d7c30 Date: Fri, 15 Aug 2003 09:13:59 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
338 oldmode_settings.flags = 0;
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
339
692
04dd6c6d7c30 Date: Fri, 15 Aug 2003 09:13:59 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
340 if (PgSetVideoMode(&oldmode_settings) < 0)
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
341 {
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
342 SDL_SetError("Ph_LeaveFullScreen(): PgSetVideoMode() function failed !\n");
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
343 return 0;
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
344 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
345 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
346
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
347 old_video_mode=-1;
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
348 old_refresh_rate=-1;
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
349 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
350 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
351 return 1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
352 }