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

Date: Sat, 14 Feb 2004 14:52:40 +0200 From: "Mike Gorchak" Subject: Batch of the QNX6 fixes for the SDL 1. Updated readme.QNX 2. Fixed crashes during intensive window updating under fast machines (got over 200 rectangles for update). 3. Fixed double-buffered fullscreen modes, now it works as needed. 4. Fixed Photon detection algorithm. 5. Fixed HWSURFACE update function. 6. Added SDL_PHOTON_FULLSCREEN_REFRESH environment variable support for control refresh rates under Photon. 7. Added 640x400 fullscreen mode emulation via 640x480 (if videodriver not supports original 640x400 mode of course) shifted by 40 vertical pixels from begin, to center it. It's needed for some old DOS games which ran in doubled 320x200 mode. 8. Added available video ram amount support. 8. Added hardware surface allocation/deallocation support if current videomode and videodriver supports it. 9. Added hardware filling support. 10. Added hardware blits support (simple and colorkeyed). And I've added to testvidinfo test color-keyed blits benchmark (maybe need to add alpha blits benchmark too ?). Currently Photon not supporting any alpha hardware blittings (all drivers lack of alpha blitting code support, only software alpha blitting exist in photon, which is hundreds times slowest than the SDL's one). So I've not added the alpha support. I suppose new QNX 6.3 will have the hardware alpha support, so when it will be done, I'll add alpha support.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 14 Feb 2004 20:22:21 +0000
parents b8d311d90021
children 4ab6d1fd028f
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
769
b8d311d90021 Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents: 692
diff changeset
3 Copyright (C) 1997-2004 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
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
83 if (PgGetVideoModeList(&mode_list) < 0)
309
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 {
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
112 SDL_modelist[i].w = Amodelist[j - i - 1].w;
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
113 SDL_modelist[i].h = Amodelist[j - i - 1].h;
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
114 SDL_modelist[i].x = Amodelist[j - i - 1].x;
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
115 SDL_modelist[i].y = Amodelist[j - i - 1].y;
309
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;
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
132 int modestage=0;
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
133 int closestmode=0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
134
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
135 if (PgGetVideoModeList(&mode_list) < 0)
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 return -1;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
138 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
139
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
140 /* special case for the double-sized 320x200 mode */
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
141 if ((width==640) && (height==400))
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
142 {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
143 modestage=1;
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
144 }
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
145
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
146 /* search list for exact match */
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
147 for (i=0; i<mode_list.num_modes; i++)
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
148 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
149 if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
150 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
151 return 0;
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
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
154 if ((mode_info.width == width) && (mode_info.height == height) &&
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
155 (mode_info.bits_per_pixel == bpp))
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
156 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
157 return mode_list.modes[i];
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
158 }
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
159 else
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
160 {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
161 if ((modestage) && (mode_info.width == width) && (mode_info.height == height+80) &&
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
162 (mode_info.bits_per_pixel == bpp))
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
163 {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
164 modestage=2;
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
165 closestmode=mode_list.modes[i];
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
166 }
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
167 }
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
168 }
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
169
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
170 /* if we are here, then no 640x400xbpp mode found and we'll emulate it via 640x480xbpp mode */
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
171 if (modestage==2)
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
172 {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
173 return closestmode;
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
174 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
175
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
176 return (i == mode_list.num_modes) ? 0 : mode_list.modes[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
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
179 /* return the mode associated with width, height and bpp */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180 /* 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
181 int get_mode_any_format(int width, int height, int bpp)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
183 int i, closest, delta, min_delta;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
185 if (PgGetVideoModeList(&mode_list) < 0)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
186 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
187 return -1;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
188 }
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 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
191
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
192 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
193 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
194 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
195 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
196 return 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
197 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
198 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
199 {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
200 break;
663
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 }
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 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
205 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
206 /* get closest bpp */
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
207 closest = i++;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
208 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
209 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
210 return mode_list.modes[closest];
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
211 }
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 min_delta = abs(mode_info.bits_per_pixel - bpp);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
214
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
215 while(1)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
216 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
217 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
218 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
219 return 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
220 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
221
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
222 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
223 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
224 break;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
225 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
226 else
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
227 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
228 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
229 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
230 closest = i;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
231 break;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
232 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
233 else
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
234 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
235 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
236 if (delta < min_delta)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
237 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
238 closest = i;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
239 min_delta = delta;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
240 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
241 i++;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
242 }
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 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
245 return mode_list.modes[closest];
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
246 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
247
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
248 return 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
249 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
250
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
251 int ph_ToggleFullScreen(_THIS, int on)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
252 {
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
253 return -1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
254 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
255
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
256 int ph_EnterFullScreen(_THIS, SDL_Surface* screen)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
257 {
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
258 PgDisplaySettings_t settings;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
259 int mode;
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
260 char* refreshrate;
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
261 int refreshratenum;
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
262
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
263 if (!currently_fullscreen)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
264 {
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
265 /* 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
266 if (screen->flags & SDL_ANYFORMAT)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
267 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
268 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
269 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
270 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
271 return 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
272 }
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 else
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
275 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
276 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
277 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
278 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
279 return 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
280 }
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
281 if (PgGetVideoModeInfo(mode, &mode_info) < 0)
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
282 {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
283 SDL_SetError("ph_EnterFullScreen(): can't get video mode capabilities !\n");
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
284 return 0;
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
285 }
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
286 if (mode_info.height != screen->h)
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
287 {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
288 if ((mode_info.height==480) && (screen->h==400))
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
289 {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
290 videomode_emulatemode=1;
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
291 }
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
292 }
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
293 else
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
294 {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
295 videomode_emulatemode=0;
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
296 }
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
297 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
298
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
299 /* save old video mode caps */
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
300 PgGetVideoMode(&settings);
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
301 old_video_mode=settings.mode;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
302 old_refresh_rate=settings.refresh;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
303
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
304 /* setup new video mode */
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
305 settings.mode = mode;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
306 settings.refresh = 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
307 settings.flags = 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
308
821
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
309 refreshrate=getenv("SDL_PHOTON_FULLSCREEN_REFRESH");
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
310 if (refreshrate!=NULL)
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
311 {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
312 if (sscanf(refreshrate, "%d", &refreshratenum)==1)
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
313 {
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
314 settings.refresh = refreshratenum;
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
315 }
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
316 }
30168104389f Date: Sat, 14 Feb 2004 14:52:40 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
317
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
318 if (PgSetVideoMode(&settings) < 0)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
319 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
320 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
321 return 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
322 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
323
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
324 if (this->screen)
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
325 {
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
326 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
327 {
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
328 #ifdef HAVE_OPENGL
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
329 #endif /* HAVE_OPENGL */
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
330 return 0;
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
331 }
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
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
334 if (OCImage.direct_context==NULL)
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
335 {
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
336 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
337 if (!OCImage.direct_context)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
338 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
339 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
340 ph_LeaveFullScreen(this);
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
341 return 0;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
342 }
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
343 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
344
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
345 OCImage.oldDC=PdDirectStart(OCImage.direct_context);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
346
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
347 currently_fullscreen = 1;
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
348 }
692
04dd6c6d7c30 Date: Fri, 15 Aug 2003 09:13:59 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
349 PgFlush();
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
350
309
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 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
353
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
354 int ph_LeaveFullScreen(_THIS)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
355 {
692
04dd6c6d7c30 Date: Fri, 15 Aug 2003 09:13:59 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
356 PgDisplaySettings_t oldmode_settings;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
357
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
358 if (currently_fullscreen)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
359 {
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
360 if ((this->screen) && ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL))
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
361 {
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
362 #ifdef HAVE_OPENGL
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
363 #endif /* HAVE_OPENGL */
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
364 return 0;
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
365 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
366 else
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
367 {
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
368 if (OCImage.direct_context)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
369 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
370 PdDirectStop(OCImage.direct_context);
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
371 PdReleaseDirectContext(OCImage.direct_context);
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
372 OCImage.direct_context=NULL;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
373 }
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
374 if (OCImage.oldDC)
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
375 {
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
376 PhDCSetCurrent(OCImage.oldDC);
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
377 OCImage.oldDC=NULL;
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
378 }
571
8e3ce997621c Date: Thu, 16 Jan 2003 13:48:31 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 315
diff changeset
379
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
380 currently_fullscreen=0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
381
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
382 /* Restore old video mode */
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
383 if (old_video_mode != -1)
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
384 {
692
04dd6c6d7c30 Date: Fri, 15 Aug 2003 09:13:59 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
385 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
386 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
387 oldmode_settings.flags = 0;
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
388
692
04dd6c6d7c30 Date: Fri, 15 Aug 2003 09:13:59 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 663
diff changeset
389 if (PgSetVideoMode(&oldmode_settings) < 0)
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
390 {
663
8bedd6d61642 Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 571
diff changeset
391 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
392 return 0;
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 old_video_mode=-1;
315
3333b6e68289 Date: Sat, 23 Mar 2002 13:53:37 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 309
diff changeset
397 old_refresh_rate=-1;
309
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
398 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
399 }
2de77f7b7a28 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
400 return 1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
401 }