Mercurial > sdl-ios-xcode
annotate src/video/windib/SDL_dibvideo.c @ 1318:f95502c6fc72
Eliminate duplicate modes with different refresh rates
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 01 Feb 2006 09:28:42 +0000 |
parents | c9b51268668f |
children | 450721ad5436 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1295
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
169
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 #include <stdio.h> | |
24 #include <stdlib.h> | |
25 #include <malloc.h> | |
26 #include <windows.h> | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
27 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
28 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
29 #if defined(_WIN32_WCE) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
30 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
31 // defined and used in SDL_sysevents.c |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
32 extern HINSTANCE aygshell; |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
33 |
514
1080bfc4aa96
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
34 #endif |
0 | 35 |
36 /* Not yet in the mingw32 cross-compile headers */ | |
37 #ifndef CDS_FULLSCREEN | |
38 #define CDS_FULLSCREEN 4 | |
39 #endif | |
40 | |
41 #include "SDL.h" | |
42 #include "SDL_mutex.h" | |
43 #include "SDL_syswm.h" | |
44 #include "SDL_sysvideo.h" | |
45 #include "SDL_sysevents.h" | |
46 #include "SDL_events_c.h" | |
47 #include "SDL_pixels_c.h" | |
48 #include "SDL_dibvideo.h" | |
49 #include "SDL_syswm_c.h" | |
50 #include "SDL_sysmouse_c.h" | |
51 #include "SDL_dibevents_c.h" | |
52 #include "SDL_wingl_c.h" | |
53 | |
54 #ifdef _WIN32_WCE | |
55 #define NO_GETDIBITS | |
56 #define NO_CHANGEDISPLAYSETTINGS | |
57 #define NO_GAMMA_SUPPORT | |
58 #endif | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
448
diff
changeset
|
59 #ifndef WS_MAXIMIZE |
766
ed57c876700d
Date: Wed, 26 Nov 2003 01:52:02 +0800
Sam Lantinga <slouken@libsdl.org>
parents:
515
diff
changeset
|
60 #define WS_MAXIMIZE 0 |
ed57c876700d
Date: Wed, 26 Nov 2003 01:52:02 +0800
Sam Lantinga <slouken@libsdl.org>
parents:
515
diff
changeset
|
61 #endif |
ed57c876700d
Date: Wed, 26 Nov 2003 01:52:02 +0800
Sam Lantinga <slouken@libsdl.org>
parents:
515
diff
changeset
|
62 #ifndef WS_THICKFRAME |
ed57c876700d
Date: Wed, 26 Nov 2003 01:52:02 +0800
Sam Lantinga <slouken@libsdl.org>
parents:
515
diff
changeset
|
63 #define WS_THICKFRAME 0 |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
448
diff
changeset
|
64 #endif |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
448
diff
changeset
|
65 #ifndef SWP_NOCOPYBITS |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
448
diff
changeset
|
66 #define SWP_NOCOPYBITS 0 |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
448
diff
changeset
|
67 #endif |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
448
diff
changeset
|
68 #ifndef PC_NOCOLLAPSE |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
448
diff
changeset
|
69 #define PC_NOCOLLAPSE 0 |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
448
diff
changeset
|
70 #endif |
0 | 71 |
72 /* Initialization/Query functions */ | |
73 static int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat); | |
74 static SDL_Rect **DIB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); | |
75 SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | |
76 static int DIB_SetColors(_THIS, int firstcolor, int ncolors, | |
77 SDL_Color *colors); | |
78 static void DIB_CheckGamma(_THIS); | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
79 void DIB_SwapGamma(_THIS); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
80 void DIB_QuitGamma(_THIS); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
81 int DIB_SetGammaRamp(_THIS, Uint16 *ramp); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
82 int DIB_GetGammaRamp(_THIS, Uint16 *ramp); |
0 | 83 static void DIB_VideoQuit(_THIS); |
84 | |
85 /* Hardware surface functions */ | |
86 static int DIB_AllocHWSurface(_THIS, SDL_Surface *surface); | |
87 static int DIB_LockHWSurface(_THIS, SDL_Surface *surface); | |
88 static void DIB_UnlockHWSurface(_THIS, SDL_Surface *surface); | |
89 static void DIB_FreeHWSurface(_THIS, SDL_Surface *surface); | |
90 | |
91 /* Windows message handling functions */ | |
92 static void DIB_RealizePalette(_THIS); | |
93 static void DIB_PaletteChanged(_THIS, HWND window); | |
94 static void DIB_WinPAINT(_THIS, HDC hdc); | |
95 | |
96 /* helper fn */ | |
97 static int DIB_SussScreenDepth(); | |
98 | |
99 /* DIB driver bootstrap functions */ | |
100 | |
101 static int DIB_Available(void) | |
102 { | |
103 return(1); | |
104 } | |
105 | |
106 static void DIB_DeleteDevice(SDL_VideoDevice *device) | |
107 { | |
108 if ( device ) { | |
109 if ( device->hidden ) { | |
110 free(device->hidden); | |
111 } | |
112 if ( device->gl_data ) { | |
113 free(device->gl_data); | |
114 } | |
115 free(device); | |
116 } | |
117 } | |
118 | |
119 static SDL_VideoDevice *DIB_CreateDevice(int devindex) | |
120 { | |
121 SDL_VideoDevice *device; | |
122 | |
123 /* Initialize all variables that we clean on shutdown */ | |
124 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); | |
125 if ( device ) { | |
126 memset(device, 0, (sizeof *device)); | |
127 device->hidden = (struct SDL_PrivateVideoData *) | |
128 malloc((sizeof *device->hidden)); | |
129 device->gl_data = (struct SDL_PrivateGLData *) | |
130 malloc((sizeof *device->gl_data)); | |
131 } | |
132 if ( (device == NULL) || (device->hidden == NULL) || | |
133 (device->gl_data == NULL) ) { | |
134 SDL_OutOfMemory(); | |
135 DIB_DeleteDevice(device); | |
136 return(NULL); | |
137 } | |
138 memset(device->hidden, 0, (sizeof *device->hidden)); | |
139 memset(device->gl_data, 0, (sizeof *device->gl_data)); | |
140 | |
141 /* Set the function pointers */ | |
142 device->VideoInit = DIB_VideoInit; | |
143 device->ListModes = DIB_ListModes; | |
144 device->SetVideoMode = DIB_SetVideoMode; | |
145 device->UpdateMouse = WIN_UpdateMouse; | |
146 device->SetColors = DIB_SetColors; | |
147 device->UpdateRects = NULL; | |
148 device->VideoQuit = DIB_VideoQuit; | |
149 device->AllocHWSurface = DIB_AllocHWSurface; | |
150 device->CheckHWBlit = NULL; | |
151 device->FillHWRect = NULL; | |
152 device->SetHWColorKey = NULL; | |
153 device->SetHWAlpha = NULL; | |
154 device->LockHWSurface = DIB_LockHWSurface; | |
155 device->UnlockHWSurface = DIB_UnlockHWSurface; | |
156 device->FlipHWSurface = NULL; | |
157 device->FreeHWSurface = DIB_FreeHWSurface; | |
158 device->SetGammaRamp = DIB_SetGammaRamp; | |
159 device->GetGammaRamp = DIB_GetGammaRamp; | |
160 #ifdef HAVE_OPENGL | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
448
diff
changeset
|
161 device->GL_LoadLibrary = WIN_GL_LoadLibrary; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
448
diff
changeset
|
162 device->GL_GetProcAddress = WIN_GL_GetProcAddress; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
448
diff
changeset
|
163 device->GL_GetAttribute = WIN_GL_GetAttribute; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
448
diff
changeset
|
164 device->GL_MakeCurrent = WIN_GL_MakeCurrent; |
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
448
diff
changeset
|
165 device->GL_SwapBuffers = WIN_GL_SwapBuffers; |
0 | 166 #endif |
167 device->SetCaption = WIN_SetWMCaption; | |
168 device->SetIcon = WIN_SetWMIcon; | |
169 device->IconifyWindow = WIN_IconifyWindow; | |
170 device->GrabInput = WIN_GrabInput; | |
171 device->GetWMInfo = WIN_GetWMInfo; | |
172 device->FreeWMCursor = WIN_FreeWMCursor; | |
173 device->CreateWMCursor = WIN_CreateWMCursor; | |
174 device->ShowWMCursor = WIN_ShowWMCursor; | |
175 device->WarpWMCursor = WIN_WarpWMCursor; | |
176 device->CheckMouseMode = WIN_CheckMouseMode; | |
177 device->InitOSKeymap = DIB_InitOSKeymap; | |
178 device->PumpEvents = DIB_PumpEvents; | |
179 | |
180 /* Set up the windows message handling functions */ | |
181 WIN_RealizePalette = DIB_RealizePalette; | |
182 WIN_PaletteChanged = DIB_PaletteChanged; | |
183 WIN_WinPAINT = DIB_WinPAINT; | |
184 HandleMessage = DIB_HandleMessage; | |
185 | |
186 device->free = DIB_DeleteDevice; | |
187 | |
188 /* We're finally ready */ | |
189 return device; | |
190 } | |
191 | |
192 VideoBootStrap WINDIB_bootstrap = { | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
193 "windib", "Win95/98/NT/2000/CE GDI", |
0 | 194 DIB_Available, DIB_CreateDevice |
195 }; | |
196 | |
197 #ifndef NO_CHANGEDISPLAYSETTINGS | |
198 | |
199 static int cmpmodes(const void *va, const void *vb) | |
200 { | |
201 SDL_Rect *a = *(SDL_Rect **)va; | |
202 SDL_Rect *b = *(SDL_Rect **)vb; | |
966
f72cc0c7305f
Video modes are sorted width first, then height
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
203 if ( a->w == b->w ) |
f72cc0c7305f
Video modes are sorted width first, then height
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
204 return b->h - a->h; |
f72cc0c7305f
Video modes are sorted width first, then height
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
205 else |
f72cc0c7305f
Video modes are sorted width first, then height
Sam Lantinga <slouken@libsdl.org>
parents:
833
diff
changeset
|
206 return b->w - a->w; |
0 | 207 } |
208 | |
209 static int DIB_AddMode(_THIS, int bpp, int w, int h) | |
210 { | |
211 SDL_Rect *mode; | |
212 int i, index; | |
213 int next_mode; | |
214 | |
215 /* Check to see if we already have this mode */ | |
216 if ( bpp < 8 ) { /* Not supported */ | |
217 return(0); | |
218 } | |
219 index = ((bpp+7)/8)-1; | |
220 for ( i=0; i<SDL_nummodes[index]; ++i ) { | |
221 mode = SDL_modelist[index][i]; | |
222 if ( (mode->w == w) && (mode->h == h) ) { | |
223 return(0); | |
224 } | |
225 } | |
226 | |
227 /* Set up the new video mode rectangle */ | |
228 mode = (SDL_Rect *)malloc(sizeof *mode); | |
229 if ( mode == NULL ) { | |
230 SDL_OutOfMemory(); | |
231 return(-1); | |
232 } | |
233 mode->x = 0; | |
234 mode->y = 0; | |
235 mode->w = w; | |
236 mode->h = h; | |
237 | |
238 /* Allocate the new list of modes, and fill in the new mode */ | |
239 next_mode = SDL_nummodes[index]; | |
240 SDL_modelist[index] = (SDL_Rect **) | |
241 realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); | |
242 if ( SDL_modelist[index] == NULL ) { | |
243 SDL_OutOfMemory(); | |
244 SDL_nummodes[index] = 0; | |
245 free(mode); | |
246 return(-1); | |
247 } | |
248 SDL_modelist[index][next_mode] = mode; | |
249 SDL_modelist[index][next_mode+1] = NULL; | |
250 SDL_nummodes[index]++; | |
251 | |
252 return(0); | |
253 } | |
254 | |
255 #endif /* !NO_CHANGEDISPLAYSETTINGS */ | |
256 | |
257 static HPALETTE DIB_CreatePalette(int bpp) | |
258 { | |
259 /* RJR: March 28, 2000 | |
260 moved palette creation here from "DIB_VideoInit" */ | |
261 | |
262 HPALETTE handle = NULL; | |
263 | |
264 if ( bpp <= 8 ) | |
265 { | |
266 LOGPALETTE *palette; | |
267 HDC hdc; | |
268 int ncolors; | |
269 int i; | |
270 | |
271 ncolors = 1; | |
272 for ( i=0; i<bpp; ++i ) { | |
273 ncolors *= 2; | |
274 } | |
275 palette = (LOGPALETTE *)malloc(sizeof(*palette)+ | |
276 ncolors*sizeof(PALETTEENTRY)); | |
277 palette->palVersion = 0x300; | |
278 palette->palNumEntries = ncolors; | |
279 hdc = GetDC(SDL_Window); | |
280 GetSystemPaletteEntries(hdc, 0, ncolors, palette->palPalEntry); | |
281 ReleaseDC(SDL_Window, hdc); | |
282 handle = CreatePalette(palette); | |
283 free(palette); | |
284 } | |
285 | |
286 return handle; | |
287 } | |
288 | |
289 int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat) | |
290 { | |
291 #ifndef NO_CHANGEDISPLAYSETTINGS | |
292 int i; | |
293 DEVMODE settings; | |
294 #endif | |
295 | |
296 /* Create the window */ | |
297 if ( DIB_CreateWindow(this) < 0 ) { | |
298 return(-1); | |
299 } | |
169
8039a5b760b9
Allow building SDL on Windows without audio support
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
300 #ifndef DISABLE_AUDIO |
0 | 301 DX5_SoundFocus(SDL_Window); |
169
8039a5b760b9
Allow building SDL on Windows without audio support
Sam Lantinga <slouken@libsdl.org>
parents:
145
diff
changeset
|
302 #endif |
0 | 303 |
304 /* Determine the screen depth */ | |
305 vformat->BitsPerPixel = DIB_SussScreenDepth(); | |
306 switch (vformat->BitsPerPixel) { | |
307 case 15: | |
308 vformat->Rmask = 0x00007c00; | |
309 vformat->Gmask = 0x000003e0; | |
310 vformat->Bmask = 0x0000001f; | |
311 vformat->BitsPerPixel = 16; | |
312 break; | |
313 case 16: | |
314 vformat->Rmask = 0x0000f800; | |
315 vformat->Gmask = 0x000007e0; | |
316 vformat->Bmask = 0x0000001f; | |
317 break; | |
318 case 24: | |
319 case 32: | |
320 /* GDI defined as 8-8-8 */ | |
321 vformat->Rmask = 0x00ff0000; | |
322 vformat->Gmask = 0x0000ff00; | |
323 vformat->Bmask = 0x000000ff; | |
324 break; | |
325 default: | |
326 break; | |
327 } | |
328 | |
329 /* See if gamma is supported on this screen */ | |
330 DIB_CheckGamma(this); | |
331 | |
332 #ifndef NO_CHANGEDISPLAYSETTINGS | |
1295
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1292
diff
changeset
|
333 /* Query for the desktop resolution */ |
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1292
diff
changeset
|
334 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode); |
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1292
diff
changeset
|
335 |
0 | 336 /* Query for the list of available video modes */ |
337 for ( i=0; EnumDisplaySettings(NULL, i, &settings); ++i ) { | |
338 DIB_AddMode(this, settings.dmBitsPerPel, | |
339 settings.dmPelsWidth, settings.dmPelsHeight); | |
340 } | |
341 /* Sort the mode lists */ | |
342 for ( i=0; i<NUM_MODELISTS; ++i ) { | |
343 if ( SDL_nummodes[i] > 0 ) { | |
344 qsort(SDL_modelist[i], SDL_nummodes[i], sizeof *SDL_modelist[i], cmpmodes); | |
345 } | |
346 } | |
347 #endif /* !NO_CHANGEDISPLAYSETTINGS */ | |
348 | |
349 /* Grab an identity palette if we are in a palettized mode */ | |
350 if ( vformat->BitsPerPixel <= 8 ) { | |
351 /* RJR: March 28, 2000 | |
352 moved palette creation to "DIB_CreatePalette" */ | |
353 screen_pal = DIB_CreatePalette(vformat->BitsPerPixel); | |
354 } | |
355 | |
356 /* Fill in some window manager capabilities */ | |
357 this->info.wm_available = 1; | |
358 | |
359 /* We're done! */ | |
360 return(0); | |
361 } | |
362 | |
363 /* We support any format at any dimension */ | |
364 SDL_Rect **DIB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | |
365 { | |
366 #ifdef NO_CHANGEDISPLAYSETTINGS | |
367 return((SDL_Rect **)-1); | |
368 #else | |
369 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | |
370 return(SDL_modelist[((format->BitsPerPixel+7)/8)-1]); | |
371 } else { | |
372 return((SDL_Rect **)-1); | |
373 } | |
374 #endif | |
375 } | |
376 | |
377 | |
378 /* | |
379 Helper fn to work out which screen depth windows is currently using. | |
380 15 bit mode is considered 555 format, 16 bit is 565. | |
381 returns 0 for unknown mode. | |
382 (Derived from code in sept 1999 Windows Developer Journal | |
383 http://www.wdj.com/code/archive.html) | |
384 */ | |
385 static int DIB_SussScreenDepth() | |
386 { | |
387 #ifdef NO_GETDIBITS | |
388 int depth; | |
389 HDC hdc; | |
390 | |
391 hdc = GetDC(SDL_Window); | |
392 depth = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL); | |
393 ReleaseDC(SDL_Window, hdc); | |
394 return(depth); | |
395 #else | |
396 int dib_size; | |
397 LPBITMAPINFOHEADER dib_hdr; | |
398 HDC hdc; | |
399 HBITMAP hbm; | |
400 | |
401 /* Allocate enough space for a DIB header plus palette (for | |
402 * 8-bit modes) or bitfields (for 16- and 32-bit modes) | |
403 */ | |
404 dib_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD); | |
405 dib_hdr = (LPBITMAPINFOHEADER) malloc(dib_size); | |
406 memset(dib_hdr, 0, dib_size); | |
407 dib_hdr->biSize = sizeof(BITMAPINFOHEADER); | |
408 | |
409 /* Get a device-dependent bitmap that's compatible with the | |
410 screen. | |
411 */ | |
412 hdc = GetDC(NULL); | |
413 hbm = CreateCompatibleBitmap( hdc, 1, 1 ); | |
414 | |
415 /* Convert the DDB to a DIB. We need to call GetDIBits twice: | |
416 * the first call just fills in the BITMAPINFOHEADER; the | |
417 * second fills in the bitfields or palette. | |
418 */ | |
419 GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS); | |
420 GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS); | |
421 DeleteObject(hbm); | |
422 ReleaseDC(NULL, hdc); | |
423 | |
424 switch( dib_hdr->biBitCount ) | |
425 { | |
426 case 8: return 8; | |
427 case 24: return 24; | |
428 case 32: return 32; | |
429 case 16: | |
430 if( dib_hdr->biCompression == BI_BITFIELDS ) { | |
431 /* check the red mask */ | |
432 switch( ((DWORD*)((char*)dib_hdr + dib_hdr->biSize))[0] ) { | |
433 case 0xf800: return 16; /* 565 */ | |
434 case 0x7c00: return 15; /* 555 */ | |
435 } | |
436 } | |
437 } | |
438 return 0; /* poo. */ | |
439 #endif /* NO_GETDIBITS */ | |
440 } | |
441 | |
442 | |
443 /* Various screen update functions available */ | |
444 static void DIB_NormalUpdate(_THIS, int numrects, SDL_Rect *rects); | |
445 | |
446 SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, | |
447 int width, int height, int bpp, Uint32 flags) | |
448 { | |
449 SDL_Surface *video; | |
450 Uint32 prev_flags; | |
451 DWORD style; | |
452 const DWORD directstyle = | |
453 (WS_POPUP); | |
454 const DWORD windowstyle = | |
455 (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX); | |
456 const DWORD resizestyle = | |
457 (WS_THICKFRAME|WS_MAXIMIZEBOX); | |
458 int binfo_size; | |
459 BITMAPINFO *binfo; | |
460 HDC hdc; | |
461 RECT bounds; | |
462 int x, y; | |
463 Uint32 Rmask, Gmask, Bmask; | |
464 | |
465 /* Clean up any GL context that may be hanging around */ | |
466 if ( current->flags & SDL_OPENGL ) { | |
467 WIN_GL_ShutDown(this); | |
468 } | |
1291
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
469 SDL_resizing = 1; |
0 | 470 |
471 /* Recalculate the bitmasks if necessary */ | |
472 if ( bpp == current->format->BitsPerPixel ) { | |
473 video = current; | |
474 } else { | |
475 switch (bpp) { | |
476 case 15: | |
477 case 16: | |
478 if ( DIB_SussScreenDepth() == 15 ) { | |
479 /* 5-5-5 */ | |
480 Rmask = 0x00007c00; | |
481 Gmask = 0x000003e0; | |
482 Bmask = 0x0000001f; | |
483 } else { | |
484 /* 5-6-5 */ | |
485 Rmask = 0x0000f800; | |
486 Gmask = 0x000007e0; | |
487 Bmask = 0x0000001f; | |
488 } | |
489 break; | |
490 case 24: | |
491 case 32: | |
492 /* GDI defined as 8-8-8 */ | |
493 Rmask = 0x00ff0000; | |
494 Gmask = 0x0000ff00; | |
495 Bmask = 0x000000ff; | |
496 break; | |
497 default: | |
498 Rmask = 0x00000000; | |
499 Gmask = 0x00000000; | |
500 Bmask = 0x00000000; | |
501 break; | |
502 } | |
503 video = SDL_CreateRGBSurface(SDL_SWSURFACE, | |
504 0, 0, bpp, Rmask, Gmask, Bmask, 0); | |
505 if ( video == NULL ) { | |
506 SDL_OutOfMemory(); | |
507 return(NULL); | |
508 } | |
509 } | |
510 | |
511 /* Fill in part of the video surface */ | |
512 prev_flags = video->flags; | |
513 video->flags = 0; /* Clear flags */ | |
514 video->w = width; | |
515 video->h = height; | |
516 video->pitch = SDL_CalculatePitch(video); | |
517 | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
518 /* Small fix for WinCE/Win32 - when activating window |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
519 SDL_VideoSurface is equal to zero, so activating code |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
520 is not called properly for fullscreen windows because |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
521 macros WINDIB_FULLSCREEN uses SDL_VideoSurface |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
522 */ |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
523 SDL_VideoSurface = video; |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
524 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
525 #if defined(_WIN32_WCE) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
526 if ( flags & SDL_FULLSCREEN ) |
514
1080bfc4aa96
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
527 video->flags |= SDL_FULLSCREEN; |
1080bfc4aa96
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
453
diff
changeset
|
528 #endif |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
529 |
0 | 530 #ifndef NO_CHANGEDISPLAYSETTINGS |
531 /* Set fullscreen mode if appropriate */ | |
532 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | |
533 DEVMODE settings; | |
1295
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1292
diff
changeset
|
534 BOOL changed; |
0 | 535 |
536 memset(&settings, 0, sizeof(DEVMODE)); | |
537 settings.dmSize = sizeof(DEVMODE); | |
538 settings.dmBitsPerPel = video->format->BitsPerPixel; | |
539 settings.dmPelsWidth = width; | |
540 settings.dmPelsHeight = height; | |
541 settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; | |
1295
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1292
diff
changeset
|
542 if ( width <= SDL_desktop_mode.dmPelsWidth && height <= SDL_desktop_mode.dmPelsHeight ) { |
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1292
diff
changeset
|
543 settings.dmDisplayFrequency = SDL_desktop_mode.dmDisplayFrequency; |
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1292
diff
changeset
|
544 settings.dmFields |= DM_DISPLAYFREQUENCY; |
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1292
diff
changeset
|
545 } |
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1292
diff
changeset
|
546 changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL); |
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1292
diff
changeset
|
547 if ( ! changed && (settings.dmFields & DM_DISPLAYFREQUENCY) ) { |
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1292
diff
changeset
|
548 settings.dmFields &= ~DM_DISPLAYFREQUENCY; |
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1292
diff
changeset
|
549 changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL); |
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1292
diff
changeset
|
550 } |
c3e36ac8a94c
Date: Sun, 6 Mar 2005 17:06:20 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1292
diff
changeset
|
551 if ( changed ) { |
0 | 552 video->flags |= SDL_FULLSCREEN; |
304
ec53caed9fb2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
553 SDL_fullscreen_mode = settings; |
0 | 554 } |
555 } | |
556 #endif /* !NO_CHANGEDISPLAYSETTINGS */ | |
557 | |
45
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
558 /* Reset the palette and create a new one if necessary */ |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
559 if ( screen_pal != NULL ) { |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
560 /* RJR: March 28, 2000 |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
561 delete identity palette if switching from a palettized mode */ |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
562 DeleteObject(screen_pal); |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
563 screen_pal = NULL; |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
564 } |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
565 if ( bpp <= 8 ) |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
566 { |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
567 /* RJR: March 28, 2000 |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
568 create identity palette switching to a palettized mode */ |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
569 screen_pal = DIB_CreatePalette(bpp); |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
570 } |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
571 |
0 | 572 style = GetWindowLong(SDL_Window, GWL_STYLE); |
573 style &= ~(resizestyle|WS_MAXIMIZE); | |
574 if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | |
575 style &= ~windowstyle; | |
576 style |= directstyle; | |
577 } else { | |
578 #ifndef NO_CHANGEDISPLAYSETTINGS | |
579 if ( (prev_flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | |
580 ChangeDisplaySettings(NULL, 0); | |
581 } | |
582 #endif | |
583 if ( flags & SDL_NOFRAME ) { | |
584 style &= ~windowstyle; | |
585 style |= directstyle; | |
586 video->flags |= SDL_NOFRAME; | |
587 } else { | |
588 style &= ~directstyle; | |
589 style |= windowstyle; | |
590 if ( flags & SDL_RESIZABLE ) { | |
591 style |= resizestyle; | |
592 video->flags |= SDL_RESIZABLE; | |
593 } | |
594 } | |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
448
diff
changeset
|
595 #if WS_MAXIMIZE |
0 | 596 if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
597 #endif |
0 | 598 } |
145
29a638dc26db
Applied David MacCormack's patch to fix SDL_WINDOWID on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
112
diff
changeset
|
599 |
448
323c766f5a46
Fullscreen windows are always topmost under Windows
Sam Lantinga <slouken@libsdl.org>
parents:
442
diff
changeset
|
600 /* DJM: Don't piss of anyone who has setup his own window */ |
1280
f61f045343d3
Re-query the SDL_WINDOWID each time we initialize the video
Sam Lantinga <slouken@libsdl.org>
parents:
1251
diff
changeset
|
601 if ( !SDL_windowid ) |
448
323c766f5a46
Fullscreen windows are always topmost under Windows
Sam Lantinga <slouken@libsdl.org>
parents:
442
diff
changeset
|
602 SetWindowLong(SDL_Window, GWL_STYLE, style); |
0 | 603 |
604 /* Delete the old bitmap if necessary */ | |
605 if ( screen_bmp != NULL ) { | |
606 DeleteObject(screen_bmp); | |
607 } | |
608 if ( ! (flags & SDL_OPENGL) ) { | |
609 BOOL is16bitmode = (video->format->BytesPerPixel == 2); | |
610 | |
611 /* Suss out the bitmap info header */ | |
612 binfo_size = sizeof(*binfo); | |
613 if( is16bitmode ) { | |
614 /* 16bit modes, palette area used for rgb bitmasks */ | |
615 binfo_size += 3*sizeof(DWORD); | |
616 } else if ( video->format->palette ) { | |
617 binfo_size += video->format->palette->ncolors * | |
618 sizeof(RGBQUAD); | |
619 } | |
620 binfo = (BITMAPINFO *)malloc(binfo_size); | |
621 if ( ! binfo ) { | |
622 if ( video != current ) { | |
623 SDL_FreeSurface(video); | |
624 } | |
625 SDL_OutOfMemory(); | |
626 return(NULL); | |
627 } | |
628 | |
629 binfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
630 binfo->bmiHeader.biWidth = video->w; | |
631 binfo->bmiHeader.biHeight = -video->h; /* -ve for topdown bitmap */ | |
632 binfo->bmiHeader.biPlanes = 1; | |
633 binfo->bmiHeader.biSizeImage = video->h * video->pitch; | |
634 binfo->bmiHeader.biXPelsPerMeter = 0; | |
635 binfo->bmiHeader.biYPelsPerMeter = 0; | |
636 binfo->bmiHeader.biClrUsed = 0; | |
637 binfo->bmiHeader.biClrImportant = 0; | |
638 binfo->bmiHeader.biBitCount = video->format->BitsPerPixel; | |
639 | |
640 if ( is16bitmode ) { | |
641 /* BI_BITFIELDS tells CreateDIBSection about the rgb masks in the palette */ | |
642 binfo->bmiHeader.biCompression = BI_BITFIELDS; | |
643 ((Uint32*)binfo->bmiColors)[0] = video->format->Rmask; | |
644 ((Uint32*)binfo->bmiColors)[1] = video->format->Gmask; | |
645 ((Uint32*)binfo->bmiColors)[2] = video->format->Bmask; | |
646 } else { | |
647 binfo->bmiHeader.biCompression = BI_RGB; /* BI_BITFIELDS for 565 vs 555 */ | |
648 if ( video->format->palette ) { | |
649 memset(binfo->bmiColors, 0, | |
650 video->format->palette->ncolors*sizeof(RGBQUAD)); | |
651 } | |
652 } | |
653 | |
654 /* Create the offscreen bitmap buffer */ | |
655 hdc = GetDC(SDL_Window); | |
656 screen_bmp = CreateDIBSection(hdc, binfo, DIB_RGB_COLORS, | |
657 (void **)(&video->pixels), NULL, 0); | |
658 ReleaseDC(SDL_Window, hdc); | |
659 free(binfo); | |
660 if ( screen_bmp == NULL ) { | |
661 if ( video != current ) { | |
662 SDL_FreeSurface(video); | |
663 } | |
664 SDL_SetError("Couldn't create DIB section"); | |
665 return(NULL); | |
666 } | |
667 this->UpdateRects = DIB_NormalUpdate; | |
668 | |
669 /* Set video surface flags */ | |
670 if ( bpp <= 8 ) { | |
671 /* BitBlt() maps colors for us */ | |
672 video->flags |= SDL_HWPALETTE; | |
673 } | |
674 } | |
675 | |
676 /* Resize the window */ | |
1290
c4a5a772c5d9
The event code was fine, and calculated the SDL_windowX/Y correctly.
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
677 if ( !SDL_windowid && !IsZoomed(SDL_Window) ) { |
448
323c766f5a46
Fullscreen windows are always topmost under Windows
Sam Lantinga <slouken@libsdl.org>
parents:
442
diff
changeset
|
678 HWND top; |
0 | 679 UINT swp_flags; |
1290
c4a5a772c5d9
The event code was fine, and calculated the SDL_windowX/Y correctly.
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
680 const char *window = NULL; |
c4a5a772c5d9
The event code was fine, and calculated the SDL_windowX/Y correctly.
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
681 const char *center = NULL; |
833
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
682 |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
683 if ( !SDL_windowX && !SDL_windowY ) { |
1290
c4a5a772c5d9
The event code was fine, and calculated the SDL_windowX/Y correctly.
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
684 window = getenv("SDL_VIDEO_WINDOW_POS"); |
c4a5a772c5d9
The event code was fine, and calculated the SDL_windowX/Y correctly.
Sam Lantinga <slouken@libsdl.org>
parents:
1288
diff
changeset
|
685 center = getenv("SDL_VIDEO_CENTERED"); |
833
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
686 if ( window ) { |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
687 if ( sscanf(window, "%d,%d", &x, &y) == 2 ) { |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
688 SDL_windowX = x; |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
689 SDL_windowY = y; |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
690 } |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
691 if ( strcmp(window, "center") == 0 ) { |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
692 center = window; |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
693 } |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
694 } |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
695 } |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
696 swp_flags = (SWP_NOCOPYBITS | SWP_SHOWWINDOW); |
0 | 697 |
833
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
698 bounds.left = SDL_windowX; |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
699 bounds.top = SDL_windowY; |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
700 bounds.right = SDL_windowX+video->w; |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
701 bounds.bottom = SDL_windowY+video->h; |
453
a6fa62b1be09
Updated for embedded Visual C++ 4.0
Sam Lantinga <slouken@libsdl.org>
parents:
448
diff
changeset
|
702 AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0); |
0 | 703 width = bounds.right-bounds.left; |
704 height = bounds.bottom-bounds.top; | |
833
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
705 if ( (flags & SDL_FULLSCREEN) ) { |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
706 x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
707 y = (GetSystemMetrics(SM_CYSCREEN)-height)/2; |
971
96671ebc50a4
Date: Mon, 25 Oct 2004 17:30:06 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
966
diff
changeset
|
708 } else if ( center ) { |
96671ebc50a4
Date: Mon, 25 Oct 2004 17:30:06 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
966
diff
changeset
|
709 x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; |
96671ebc50a4
Date: Mon, 25 Oct 2004 17:30:06 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
966
diff
changeset
|
710 y = (GetSystemMetrics(SM_CYSCREEN)-height)/2; |
833
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
711 } else if ( SDL_windowX || SDL_windowY || window ) { |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
712 x = bounds.left; |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
713 y = bounds.top; |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
714 } else { |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
715 x = y = -1; |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
716 swp_flags |= SWP_NOMOVE; |
31fa08b36380
Added support for SDL_VIDEO_WINDOW_POS and SDL_VIDEO_CENTERED on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
766
diff
changeset
|
717 } |
448
323c766f5a46
Fullscreen windows are always topmost under Windows
Sam Lantinga <slouken@libsdl.org>
parents:
442
diff
changeset
|
718 if ( flags & SDL_FULLSCREEN ) { |
323c766f5a46
Fullscreen windows are always topmost under Windows
Sam Lantinga <slouken@libsdl.org>
parents:
442
diff
changeset
|
719 top = HWND_TOPMOST; |
323c766f5a46
Fullscreen windows are always topmost under Windows
Sam Lantinga <slouken@libsdl.org>
parents:
442
diff
changeset
|
720 } else { |
323c766f5a46
Fullscreen windows are always topmost under Windows
Sam Lantinga <slouken@libsdl.org>
parents:
442
diff
changeset
|
721 top = HWND_NOTOPMOST; |
323c766f5a46
Fullscreen windows are always topmost under Windows
Sam Lantinga <slouken@libsdl.org>
parents:
442
diff
changeset
|
722 } |
323c766f5a46
Fullscreen windows are always topmost under Windows
Sam Lantinga <slouken@libsdl.org>
parents:
442
diff
changeset
|
723 SetWindowPos(SDL_Window, top, x, y, width, height, swp_flags); |
1291
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
724 if ( !(flags & SDL_FULLSCREEN) ) { |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
725 SDL_windowX = SDL_bounds.left; |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
726 SDL_windowY = SDL_bounds.top; |
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
727 } |
0 | 728 SetForegroundWindow(SDL_Window); |
729 } | |
1291
31331c444ea2
Only save the window position if we're in windowed mode
Sam Lantinga <slouken@libsdl.org>
parents:
1290
diff
changeset
|
730 SDL_resizing = 0; |
0 | 731 |
732 /* Set up for OpenGL */ | |
733 if ( flags & SDL_OPENGL ) { | |
734 if ( WIN_GL_SetupWindow(this) < 0 ) { | |
735 return(NULL); | |
736 } | |
737 video->flags |= SDL_OPENGL; | |
738 } | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
739 |
0 | 740 /* We're live! */ |
741 return(video); | |
742 } | |
743 | |
744 /* We don't actually allow hardware surfaces in the DIB driver */ | |
745 static int DIB_AllocHWSurface(_THIS, SDL_Surface *surface) | |
746 { | |
747 return(-1); | |
748 } | |
749 static void DIB_FreeHWSurface(_THIS, SDL_Surface *surface) | |
750 { | |
751 return; | |
752 } | |
753 static int DIB_LockHWSurface(_THIS, SDL_Surface *surface) | |
754 { | |
755 return(0); | |
756 } | |
757 static void DIB_UnlockHWSurface(_THIS, SDL_Surface *surface) | |
758 { | |
759 return; | |
760 } | |
761 | |
762 static void DIB_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) | |
763 { | |
764 HDC hdc, mdc; | |
765 int i; | |
766 | |
767 hdc = GetDC(SDL_Window); | |
768 if ( screen_pal ) { | |
769 SelectPalette(hdc, screen_pal, FALSE); | |
770 } | |
771 mdc = CreateCompatibleDC(hdc); | |
772 SelectObject(mdc, screen_bmp); | |
773 for ( i=0; i<numrects; ++i ) { | |
774 BitBlt(hdc, rects[i].x, rects[i].y, rects[i].w, rects[i].h, | |
775 mdc, rects[i].x, rects[i].y, SRCCOPY); | |
776 } | |
777 DeleteDC(mdc); | |
778 ReleaseDC(SDL_Window, hdc); | |
779 } | |
780 | |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
781 |
0 | 782 int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) |
783 { | |
1292
59c7a470a51e
Fixed palette bug on non-WinCE
Sam Lantinga <slouken@libsdl.org>
parents:
1291
diff
changeset
|
784 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) |
59c7a470a51e
Fixed palette bug on non-WinCE
Sam Lantinga <slouken@libsdl.org>
parents:
1291
diff
changeset
|
785 HDC hdc, mdc; |
0 | 786 RGBQUAD *pal; |
1292
59c7a470a51e
Fixed palette bug on non-WinCE
Sam Lantinga <slouken@libsdl.org>
parents:
1291
diff
changeset
|
787 #else |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
788 HDC hdc; |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
789 #endif |
1292
59c7a470a51e
Fixed palette bug on non-WinCE
Sam Lantinga <slouken@libsdl.org>
parents:
1291
diff
changeset
|
790 int i; |
0 | 791 |
792 /* Update the display palette */ | |
793 hdc = GetDC(SDL_Window); | |
794 if ( screen_pal ) { | |
795 PALETTEENTRY *entries; | |
796 | |
797 entries = (PALETTEENTRY *)alloca(ncolors*sizeof(PALETTEENTRY)); | |
798 for ( i=0; i<ncolors; ++i ) { | |
799 entries[i].peRed = colors[i].r; | |
800 entries[i].peGreen = colors[i].g; | |
801 entries[i].peBlue = colors[i].b; | |
802 entries[i].peFlags = PC_NOCOLLAPSE; | |
803 } | |
804 SetPaletteEntries(screen_pal, firstcolor, ncolors, entries); | |
805 SelectPalette(hdc, screen_pal, FALSE); | |
806 RealizePalette(hdc); | |
807 } | |
808 | |
1292
59c7a470a51e
Fixed palette bug on non-WinCE
Sam Lantinga <slouken@libsdl.org>
parents:
1291
diff
changeset
|
809 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) |
0 | 810 /* Copy palette colors into DIB palette */ |
811 pal = (RGBQUAD *)alloca(ncolors*sizeof(RGBQUAD)); | |
812 for ( i=0; i<ncolors; ++i ) { | |
813 pal[i].rgbRed = colors[i].r; | |
814 pal[i].rgbGreen = colors[i].g; | |
815 pal[i].rgbBlue = colors[i].b; | |
816 pal[i].rgbReserved = 0; | |
817 } | |
818 | |
819 /* Set the DIB palette and update the display */ | |
820 mdc = CreateCompatibleDC(hdc); | |
821 SelectObject(mdc, screen_bmp); | |
822 SetDIBColorTable(mdc, firstcolor, ncolors, pal); | |
823 BitBlt(hdc, 0, 0, this->screen->w, this->screen->h, | |
824 mdc, 0, 0, SRCCOPY); | |
825 DeleteDC(mdc); | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
826 #endif |
0 | 827 ReleaseDC(SDL_Window, hdc); |
828 return(1); | |
829 } | |
830 | |
1251
86d0d01290ea
Updated Windows CE/PocketPC support...adds GAPI driver, landscape mode,
Ryan C. Gordon <icculus@icculus.org>
parents:
1152
diff
changeset
|
831 |
0 | 832 static void DIB_CheckGamma(_THIS) |
833 { | |
834 #ifndef NO_GAMMA_SUPPORT | |
835 HDC hdc; | |
836 WORD ramp[3*256]; | |
837 | |
838 /* If we fail to get gamma, disable gamma control */ | |
839 hdc = GetDC(SDL_Window); | |
840 if ( ! GetDeviceGammaRamp(hdc, ramp) ) { | |
841 this->GetGammaRamp = NULL; | |
842 this->SetGammaRamp = NULL; | |
843 } | |
844 ReleaseDC(SDL_Window, hdc); | |
845 #endif /* !NO_GAMMA_SUPPORT */ | |
846 } | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
847 void DIB_SwapGamma(_THIS) |
0 | 848 { |
849 #ifndef NO_GAMMA_SUPPORT | |
850 HDC hdc; | |
851 | |
852 if ( gamma_saved ) { | |
853 hdc = GetDC(SDL_Window); | |
854 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { | |
855 /* About to leave active state, restore gamma */ | |
856 SetDeviceGammaRamp(hdc, gamma_saved); | |
857 } else { | |
858 /* About to enter active state, set game gamma */ | |
859 GetDeviceGammaRamp(hdc, gamma_saved); | |
860 SetDeviceGammaRamp(hdc, this->gamma); | |
861 } | |
862 ReleaseDC(SDL_Window, hdc); | |
863 } | |
864 #endif /* !NO_GAMMA_SUPPORT */ | |
865 } | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
866 void DIB_QuitGamma(_THIS) |
0 | 867 { |
868 #ifndef NO_GAMMA_SUPPORT | |
869 if ( gamma_saved ) { | |
870 /* Restore the original gamma if necessary */ | |
871 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { | |
872 HDC hdc; | |
873 | |
874 hdc = GetDC(SDL_Window); | |
875 SetDeviceGammaRamp(hdc, gamma_saved); | |
876 ReleaseDC(SDL_Window, hdc); | |
877 } | |
878 | |
879 /* Free the saved gamma memory */ | |
880 free(gamma_saved); | |
881 gamma_saved = 0; | |
882 } | |
883 #endif /* !NO_GAMMA_SUPPORT */ | |
884 } | |
885 | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
886 int DIB_SetGammaRamp(_THIS, Uint16 *ramp) |
0 | 887 { |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
888 #ifdef NO_GAMMA_SUPPORT |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
889 SDL_SetError("SDL compiled without gamma ramp support"); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
890 return -1; |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
891 #else |
0 | 892 HDC hdc; |
893 BOOL succeeded; | |
894 | |
895 /* Set the ramp for the display */ | |
896 if ( ! gamma_saved ) { | |
897 gamma_saved = (WORD *)malloc(3*256*sizeof(*gamma_saved)); | |
898 if ( ! gamma_saved ) { | |
899 SDL_OutOfMemory(); | |
900 return -1; | |
901 } | |
902 hdc = GetDC(SDL_Window); | |
903 GetDeviceGammaRamp(hdc, gamma_saved); | |
904 ReleaseDC(SDL_Window, hdc); | |
905 } | |
906 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { | |
907 hdc = GetDC(SDL_Window); | |
908 succeeded = SetDeviceGammaRamp(hdc, ramp); | |
909 ReleaseDC(SDL_Window, hdc); | |
910 } else { | |
911 succeeded = TRUE; | |
912 } | |
913 return succeeded ? 0 : -1; | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
914 #endif /* !NO_GAMMA_SUPPORT */ |
0 | 915 } |
916 | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
917 int DIB_GetGammaRamp(_THIS, Uint16 *ramp) |
0 | 918 { |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
919 #ifdef NO_GAMMA_SUPPORT |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
920 SDL_SetError("SDL compiled without gamma ramp support"); |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
921 return -1; |
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
922 #else |
0 | 923 HDC hdc; |
924 BOOL succeeded; | |
925 | |
926 /* Get the ramp from the display */ | |
927 hdc = GetDC(SDL_Window); | |
928 succeeded = GetDeviceGammaRamp(hdc, ramp); | |
929 ReleaseDC(SDL_Window, hdc); | |
930 return succeeded ? 0 : -1; | |
338
518ffd98a8f6
Fixed gamma ramps in DirectX windowed and OpenGL modes
Sam Lantinga <slouken@libsdl.org>
parents:
304
diff
changeset
|
931 #endif /* !NO_GAMMA_SUPPORT */ |
0 | 932 } |
933 | |
442
b37ce4813ad4
Flush message queue when shutting down video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
376
diff
changeset
|
934 static void FlushMessageQueue() |
b37ce4813ad4
Flush message queue when shutting down video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
376
diff
changeset
|
935 { |
b37ce4813ad4
Flush message queue when shutting down video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
376
diff
changeset
|
936 MSG msg; |
b37ce4813ad4
Flush message queue when shutting down video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
376
diff
changeset
|
937 while ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) { |
b37ce4813ad4
Flush message queue when shutting down video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
376
diff
changeset
|
938 if ( msg.message == WM_QUIT ) break; |
b37ce4813ad4
Flush message queue when shutting down video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
376
diff
changeset
|
939 TranslateMessage( &msg ); |
b37ce4813ad4
Flush message queue when shutting down video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
376
diff
changeset
|
940 DispatchMessage( &msg ); |
b37ce4813ad4
Flush message queue when shutting down video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
376
diff
changeset
|
941 } |
b37ce4813ad4
Flush message queue when shutting down video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
376
diff
changeset
|
942 } |
b37ce4813ad4
Flush message queue when shutting down video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
376
diff
changeset
|
943 |
0 | 944 void DIB_VideoQuit(_THIS) |
945 { | |
946 /* Destroy the window and everything associated with it */ | |
947 if ( SDL_Window ) { | |
948 /* Delete the screen bitmap (also frees screen->pixels) */ | |
949 if ( this->screen ) { | |
950 #ifndef NO_CHANGEDISPLAYSETTINGS | |
951 if ( this->screen->flags & SDL_FULLSCREEN ) { | |
952 ChangeDisplaySettings(NULL, 0); | |
376
a5f60a847a89
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
374
diff
changeset
|
953 ShowWindow(SDL_Window, SW_HIDE); |
0 | 954 } |
955 #endif | |
956 if ( this->screen->flags & SDL_OPENGL ) { | |
957 WIN_GL_ShutDown(this); | |
958 } | |
959 this->screen->pixels = NULL; | |
960 } | |
961 if ( screen_bmp ) { | |
962 DeleteObject(screen_bmp); | |
963 screen_bmp = NULL; | |
964 } | |
965 if ( screen_icn ) { | |
966 DestroyIcon(screen_icn); | |
967 screen_icn = NULL; | |
968 } | |
969 DIB_QuitGamma(this); | |
970 DIB_DestroyWindow(this); | |
442
b37ce4813ad4
Flush message queue when shutting down video mode on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
376
diff
changeset
|
971 FlushMessageQueue(); |
0 | 972 |
973 SDL_Window = NULL; | |
1152
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
974 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
975 #if defined(_WIN32_WCE) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
976 |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
977 // Unload wince aygshell library to prevent leak |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
978 if( aygshell ) |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
979 { |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
980 FreeLibrary(aygshell); |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
981 aygshell = NULL; |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
982 } |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
983 #endif |
51a8702d8ecd
Updates to PocketPC (WinCE) support, thanks to Dmitry Yakimov at
Ryan C. Gordon <icculus@icculus.org>
parents:
1145
diff
changeset
|
984 |
0 | 985 } |
986 } | |
987 | |
988 /* Exported for the windows message loop only */ | |
989 static void DIB_FocusPalette(_THIS, int foreground) | |
990 { | |
991 if ( screen_pal != NULL ) { | |
992 HDC hdc; | |
993 | |
994 hdc = GetDC(SDL_Window); | |
995 SelectPalette(hdc, screen_pal, FALSE); | |
996 if ( RealizePalette(hdc) ) | |
997 InvalidateRect(SDL_Window, NULL, FALSE); | |
998 ReleaseDC(SDL_Window, hdc); | |
999 } | |
1000 } | |
1001 static void DIB_RealizePalette(_THIS) | |
1002 { | |
1003 DIB_FocusPalette(this, 1); | |
1004 } | |
1005 static void DIB_PaletteChanged(_THIS, HWND window) | |
1006 { | |
1007 if ( window != SDL_Window ) { | |
1008 DIB_FocusPalette(this, 0); | |
1009 } | |
1010 } | |
1011 | |
1012 /* Exported for the windows message loop only */ | |
1013 static void DIB_WinPAINT(_THIS, HDC hdc) | |
1014 { | |
1015 HDC mdc; | |
1016 | |
1017 if ( screen_pal ) { | |
1018 SelectPalette(hdc, screen_pal, FALSE); | |
1019 } | |
1020 mdc = CreateCompatibleDC(hdc); | |
1021 SelectObject(mdc, screen_bmp); | |
1022 BitBlt(hdc, 0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h, | |
1023 mdc, 0, 0, SRCCOPY); | |
1024 DeleteDC(mdc); | |
1025 } | |
1026 | |
1027 /* Stub in case DirectX isn't available */ | |
1028 #ifndef ENABLE_DIRECTX | |
1029 void DX5_SoundFocus(HWND hwnd) | |
1030 { | |
1031 return; | |
1032 } | |
1033 #endif |