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