Mercurial > sdl-ios-xcode
annotate src/video/windib/SDL_dibvideo.c @ 112:9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
author | Sam Lantinga <slouken@lokigames.com> |
---|---|
date | Wed, 18 Jul 2001 20:04:23 +0000 |
parents | 3dcf26fa9d15 |
children | 29a638dc26db |
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 | |
20 slouken@devolution.com | |
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 } | |
289 DX5_SoundFocus(SDL_Window); | |
290 | |
291 /* Determine the screen depth */ | |
292 vformat->BitsPerPixel = DIB_SussScreenDepth(); | |
293 switch (vformat->BitsPerPixel) { | |
294 case 15: | |
295 vformat->Rmask = 0x00007c00; | |
296 vformat->Gmask = 0x000003e0; | |
297 vformat->Bmask = 0x0000001f; | |
298 vformat->BitsPerPixel = 16; | |
299 break; | |
300 case 16: | |
301 vformat->Rmask = 0x0000f800; | |
302 vformat->Gmask = 0x000007e0; | |
303 vformat->Bmask = 0x0000001f; | |
304 break; | |
305 case 24: | |
306 case 32: | |
307 /* GDI defined as 8-8-8 */ | |
308 vformat->Rmask = 0x00ff0000; | |
309 vformat->Gmask = 0x0000ff00; | |
310 vformat->Bmask = 0x000000ff; | |
311 break; | |
312 default: | |
313 break; | |
314 } | |
315 | |
316 /* See if gamma is supported on this screen */ | |
317 DIB_CheckGamma(this); | |
318 | |
319 #ifndef NO_CHANGEDISPLAYSETTINGS | |
320 /* Query for the list of available video modes */ | |
321 for ( i=0; EnumDisplaySettings(NULL, i, &settings); ++i ) { | |
322 DIB_AddMode(this, settings.dmBitsPerPel, | |
323 settings.dmPelsWidth, settings.dmPelsHeight); | |
324 } | |
325 /* Sort the mode lists */ | |
326 for ( i=0; i<NUM_MODELISTS; ++i ) { | |
327 if ( SDL_nummodes[i] > 0 ) { | |
328 qsort(SDL_modelist[i], SDL_nummodes[i], sizeof *SDL_modelist[i], cmpmodes); | |
329 } | |
330 } | |
331 #endif /* !NO_CHANGEDISPLAYSETTINGS */ | |
332 | |
333 /* Grab an identity palette if we are in a palettized mode */ | |
334 if ( vformat->BitsPerPixel <= 8 ) { | |
335 /* RJR: March 28, 2000 | |
336 moved palette creation to "DIB_CreatePalette" */ | |
337 screen_pal = DIB_CreatePalette(vformat->BitsPerPixel); | |
338 } | |
339 | |
340 /* Fill in some window manager capabilities */ | |
341 this->info.wm_available = 1; | |
342 | |
343 /* We're done! */ | |
344 return(0); | |
345 } | |
346 | |
347 /* We support any format at any dimension */ | |
348 SDL_Rect **DIB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | |
349 { | |
350 #ifdef NO_CHANGEDISPLAYSETTINGS | |
351 return((SDL_Rect **)-1); | |
352 #else | |
353 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | |
354 return(SDL_modelist[((format->BitsPerPixel+7)/8)-1]); | |
355 } else { | |
356 return((SDL_Rect **)-1); | |
357 } | |
358 #endif | |
359 } | |
360 | |
361 | |
362 /* | |
363 Helper fn to work out which screen depth windows is currently using. | |
364 15 bit mode is considered 555 format, 16 bit is 565. | |
365 returns 0 for unknown mode. | |
366 (Derived from code in sept 1999 Windows Developer Journal | |
367 http://www.wdj.com/code/archive.html) | |
368 */ | |
369 static int DIB_SussScreenDepth() | |
370 { | |
371 #ifdef NO_GETDIBITS | |
372 int depth; | |
373 HDC hdc; | |
374 | |
375 hdc = GetDC(SDL_Window); | |
376 depth = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL); | |
377 ReleaseDC(SDL_Window, hdc); | |
112
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
46
diff
changeset
|
378 #ifndef _WIN32_WCE |
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
46
diff
changeset
|
379 // AFAIK 16 bit CE devices have indeed RGB 565 |
0 | 380 if ( depth == 16 ) { |
381 depth = 15; /* GDI defined as RGB 555 */ | |
382 } | |
112
9ef74357a5fb
Incorporated slightly modified version of Rainer's WinCE patch
Sam Lantinga <slouken@lokigames.com>
parents:
46
diff
changeset
|
383 #endif |
0 | 384 return(depth); |
385 #else | |
386 int dib_size; | |
387 LPBITMAPINFOHEADER dib_hdr; | |
388 HDC hdc; | |
389 HBITMAP hbm; | |
390 | |
391 /* Allocate enough space for a DIB header plus palette (for | |
392 * 8-bit modes) or bitfields (for 16- and 32-bit modes) | |
393 */ | |
394 dib_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD); | |
395 dib_hdr = (LPBITMAPINFOHEADER) malloc(dib_size); | |
396 memset(dib_hdr, 0, dib_size); | |
397 dib_hdr->biSize = sizeof(BITMAPINFOHEADER); | |
398 | |
399 /* Get a device-dependent bitmap that's compatible with the | |
400 screen. | |
401 */ | |
402 hdc = GetDC(NULL); | |
403 hbm = CreateCompatibleBitmap( hdc, 1, 1 ); | |
404 | |
405 /* Convert the DDB to a DIB. We need to call GetDIBits twice: | |
406 * the first call just fills in the BITMAPINFOHEADER; the | |
407 * second fills in the bitfields or palette. | |
408 */ | |
409 GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS); | |
410 GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS); | |
411 DeleteObject(hbm); | |
412 ReleaseDC(NULL, hdc); | |
413 | |
414 switch( dib_hdr->biBitCount ) | |
415 { | |
416 case 8: return 8; | |
417 case 24: return 24; | |
418 case 32: return 32; | |
419 case 16: | |
420 if( dib_hdr->biCompression == BI_BITFIELDS ) { | |
421 /* check the red mask */ | |
422 switch( ((DWORD*)((char*)dib_hdr + dib_hdr->biSize))[0] ) { | |
423 case 0xf800: return 16; /* 565 */ | |
424 case 0x7c00: return 15; /* 555 */ | |
425 } | |
426 } | |
427 } | |
428 return 0; /* poo. */ | |
429 #endif /* NO_GETDIBITS */ | |
430 } | |
431 | |
432 | |
433 /* Various screen update functions available */ | |
434 static void DIB_NormalUpdate(_THIS, int numrects, SDL_Rect *rects); | |
435 | |
436 SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, | |
437 int width, int height, int bpp, Uint32 flags) | |
438 { | |
439 SDL_Surface *video; | |
440 Uint32 prev_flags; | |
441 DWORD style; | |
442 const DWORD directstyle = | |
443 (WS_POPUP); | |
444 const DWORD windowstyle = | |
445 (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
|
446 #ifndef _WIN32_WCE |
0 | 447 const DWORD resizestyle = |
448 (WS_THICKFRAME|WS_MAXIMIZEBOX); | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
449 #endif |
0 | 450 int binfo_size; |
451 BITMAPINFO *binfo; | |
452 HDC hdc; | |
453 RECT bounds; | |
454 int x, y; | |
455 BOOL was_visible; | |
456 Uint32 Rmask, Gmask, Bmask; | |
457 | |
458 /* See whether or not we should center the window */ | |
459 was_visible = IsWindowVisible(SDL_Window); | |
460 | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
461 #ifdef HAVE_OPENGL |
0 | 462 /* Clean up any GL context that may be hanging around */ |
463 if ( current->flags & SDL_OPENGL ) { | |
464 WIN_GL_ShutDown(this); | |
465 } | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
466 #endif /* HAVE_OPENGL */ |
0 | 467 |
468 /* Recalculate the bitmasks if necessary */ | |
469 if ( bpp == current->format->BitsPerPixel ) { | |
470 video = current; | |
471 } else { | |
472 switch (bpp) { | |
473 case 15: | |
474 case 16: | |
475 if ( DIB_SussScreenDepth() == 15 ) { | |
476 /* 5-5-5 */ | |
477 Rmask = 0x00007c00; | |
478 Gmask = 0x000003e0; | |
479 Bmask = 0x0000001f; | |
480 } else { | |
481 /* 5-6-5 */ | |
482 Rmask = 0x0000f800; | |
483 Gmask = 0x000007e0; | |
484 Bmask = 0x0000001f; | |
485 } | |
486 break; | |
487 case 24: | |
488 case 32: | |
489 /* GDI defined as 8-8-8 */ | |
490 Rmask = 0x00ff0000; | |
491 Gmask = 0x0000ff00; | |
492 Bmask = 0x000000ff; | |
493 break; | |
494 default: | |
495 Rmask = 0x00000000; | |
496 Gmask = 0x00000000; | |
497 Bmask = 0x00000000; | |
498 break; | |
499 } | |
500 video = SDL_CreateRGBSurface(SDL_SWSURFACE, | |
501 0, 0, bpp, Rmask, Gmask, Bmask, 0); | |
502 if ( video == NULL ) { | |
503 SDL_OutOfMemory(); | |
504 return(NULL); | |
505 } | |
506 } | |
507 | |
508 /* Fill in part of the video surface */ | |
509 prev_flags = video->flags; | |
510 video->flags = 0; /* Clear flags */ | |
511 video->w = width; | |
512 video->h = height; | |
513 video->pitch = SDL_CalculatePitch(video); | |
514 | |
515 #ifndef NO_CHANGEDISPLAYSETTINGS | |
516 /* Set fullscreen mode if appropriate */ | |
517 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | |
518 DEVMODE settings; | |
519 | |
520 memset(&settings, 0, sizeof(DEVMODE)); | |
521 settings.dmSize = sizeof(DEVMODE); | |
522 settings.dmBitsPerPel = video->format->BitsPerPixel; | |
523 settings.dmPelsWidth = width; | |
524 settings.dmPelsHeight = height; | |
525 settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; | |
526 if ( ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL ) { | |
527 video->flags |= SDL_FULLSCREEN; | |
528 } | |
529 } | |
530 #endif /* !NO_CHANGEDISPLAYSETTINGS */ | |
531 | |
45
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
532 /* 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
|
533 if ( screen_pal != NULL ) { |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
534 /* RJR: March 28, 2000 |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
535 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
|
536 DeleteObject(screen_pal); |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
537 screen_pal = NULL; |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
538 } |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
539 if ( bpp <= 8 ) |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
540 { |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
541 /* RJR: March 28, 2000 |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
542 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
|
543 screen_pal = DIB_CreatePalette(bpp); |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
544 } |
60a6e045808e
Fix palette creation in windowed mode at 8 bpp
Sam Lantinga <slouken@lokigames.com>
parents:
36
diff
changeset
|
545 |
0 | 546 style = GetWindowLong(SDL_Window, GWL_STYLE); |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
547 #ifndef _WIN32_WCE |
0 | 548 style &= ~(resizestyle|WS_MAXIMIZE); |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
549 #endif |
0 | 550 if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { |
551 style &= ~windowstyle; | |
552 style |= directstyle; | |
553 } else { | |
554 #ifndef NO_CHANGEDISPLAYSETTINGS | |
555 if ( (prev_flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | |
556 ChangeDisplaySettings(NULL, 0); | |
557 } | |
558 #endif | |
559 if ( flags & SDL_NOFRAME ) { | |
560 style &= ~windowstyle; | |
561 style |= directstyle; | |
562 video->flags |= SDL_NOFRAME; | |
563 } else { | |
564 style &= ~directstyle; | |
565 style |= windowstyle; | |
566 if ( flags & SDL_RESIZABLE ) { | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
567 #ifndef _WIN32_WCE |
0 | 568 style |= resizestyle; |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
569 #endif |
0 | 570 video->flags |= SDL_RESIZABLE; |
571 } | |
572 } | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
573 #ifndef _WIN32_WCE |
0 | 574 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
|
575 #endif |
0 | 576 } |
577 SetWindowLong(SDL_Window, GWL_STYLE, style); | |
578 | |
579 /* Delete the old bitmap if necessary */ | |
580 if ( screen_bmp != NULL ) { | |
581 DeleteObject(screen_bmp); | |
582 } | |
583 if ( ! (flags & SDL_OPENGL) ) { | |
584 BOOL is16bitmode = (video->format->BytesPerPixel == 2); | |
585 | |
586 /* Suss out the bitmap info header */ | |
587 binfo_size = sizeof(*binfo); | |
588 if( is16bitmode ) { | |
589 /* 16bit modes, palette area used for rgb bitmasks */ | |
590 binfo_size += 3*sizeof(DWORD); | |
591 } else if ( video->format->palette ) { | |
592 binfo_size += video->format->palette->ncolors * | |
593 sizeof(RGBQUAD); | |
594 } | |
595 binfo = (BITMAPINFO *)malloc(binfo_size); | |
596 if ( ! binfo ) { | |
597 if ( video != current ) { | |
598 SDL_FreeSurface(video); | |
599 } | |
600 SDL_OutOfMemory(); | |
601 return(NULL); | |
602 } | |
603 | |
604 binfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
605 binfo->bmiHeader.biWidth = video->w; | |
606 binfo->bmiHeader.biHeight = -video->h; /* -ve for topdown bitmap */ | |
607 binfo->bmiHeader.biPlanes = 1; | |
608 binfo->bmiHeader.biSizeImage = video->h * video->pitch; | |
609 binfo->bmiHeader.biXPelsPerMeter = 0; | |
610 binfo->bmiHeader.biYPelsPerMeter = 0; | |
611 binfo->bmiHeader.biClrUsed = 0; | |
612 binfo->bmiHeader.biClrImportant = 0; | |
613 binfo->bmiHeader.biBitCount = video->format->BitsPerPixel; | |
614 | |
615 if ( is16bitmode ) { | |
616 /* BI_BITFIELDS tells CreateDIBSection about the rgb masks in the palette */ | |
617 binfo->bmiHeader.biCompression = BI_BITFIELDS; | |
618 ((Uint32*)binfo->bmiColors)[0] = video->format->Rmask; | |
619 ((Uint32*)binfo->bmiColors)[1] = video->format->Gmask; | |
620 ((Uint32*)binfo->bmiColors)[2] = video->format->Bmask; | |
621 } else { | |
622 binfo->bmiHeader.biCompression = BI_RGB; /* BI_BITFIELDS for 565 vs 555 */ | |
623 if ( video->format->palette ) { | |
624 memset(binfo->bmiColors, 0, | |
625 video->format->palette->ncolors*sizeof(RGBQUAD)); | |
626 } | |
627 } | |
628 | |
629 /* Create the offscreen bitmap buffer */ | |
630 hdc = GetDC(SDL_Window); | |
631 screen_bmp = CreateDIBSection(hdc, binfo, DIB_RGB_COLORS, | |
632 (void **)(&video->pixels), NULL, 0); | |
633 ReleaseDC(SDL_Window, hdc); | |
634 free(binfo); | |
635 if ( screen_bmp == NULL ) { | |
636 if ( video != current ) { | |
637 SDL_FreeSurface(video); | |
638 } | |
639 SDL_SetError("Couldn't create DIB section"); | |
640 return(NULL); | |
641 } | |
642 this->UpdateRects = DIB_NormalUpdate; | |
643 | |
644 /* Set video surface flags */ | |
645 if ( bpp <= 8 ) { | |
646 /* BitBlt() maps colors for us */ | |
647 video->flags |= SDL_HWPALETTE; | |
648 } | |
649 } | |
650 | |
651 /* Resize the window */ | |
652 if ( SDL_windowid == NULL ) { | |
653 UINT swp_flags; | |
654 | |
655 SDL_resizing = 1; | |
656 bounds.left = 0; | |
657 bounds.top = 0; | |
658 bounds.right = video->w; | |
659 bounds.bottom = video->h; | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
660 #ifndef _WIN32_WCE |
0 | 661 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
|
662 #else |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
663 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
|
664 #endif |
0 | 665 width = bounds.right-bounds.left; |
666 height = bounds.bottom-bounds.top; | |
667 x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; | |
668 y = (GetSystemMetrics(SM_CYSCREEN)-height)/2; | |
669 if ( y < 0 ) { /* Cover up title bar for more client area */ | |
670 y -= GetSystemMetrics(SM_CYCAPTION)/2; | |
671 } | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
672 #ifndef _WIN32_WCE |
0 | 673 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
|
674 #else |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
675 swp_flags = (SWP_NOZORDER | SWP_SHOWWINDOW); |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
676 #endif |
0 | 677 if ( was_visible && !(flags & SDL_FULLSCREEN) ) { |
678 swp_flags |= SWP_NOMOVE; | |
679 } | |
680 SetWindowPos(SDL_Window, NULL, x, y, width, height, swp_flags); | |
681 SDL_resizing = 0; | |
682 SetForegroundWindow(SDL_Window); | |
683 } | |
684 | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
685 #ifdef HAVE_OPENGL |
0 | 686 /* Set up for OpenGL */ |
687 if ( flags & SDL_OPENGL ) { | |
688 if ( WIN_GL_SetupWindow(this) < 0 ) { | |
689 return(NULL); | |
690 } | |
691 video->flags |= SDL_OPENGL; | |
692 } | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
693 #endif /* HAVE_OPENGL */ |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
694 |
0 | 695 /* We're live! */ |
696 return(video); | |
697 } | |
698 | |
699 /* We don't actually allow hardware surfaces in the DIB driver */ | |
700 static int DIB_AllocHWSurface(_THIS, SDL_Surface *surface) | |
701 { | |
702 return(-1); | |
703 } | |
704 static void DIB_FreeHWSurface(_THIS, SDL_Surface *surface) | |
705 { | |
706 return; | |
707 } | |
708 static int DIB_LockHWSurface(_THIS, SDL_Surface *surface) | |
709 { | |
710 return(0); | |
711 } | |
712 static void DIB_UnlockHWSurface(_THIS, SDL_Surface *surface) | |
713 { | |
714 return; | |
715 } | |
716 | |
717 static void DIB_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) | |
718 { | |
719 HDC hdc, mdc; | |
720 int i; | |
721 | |
722 hdc = GetDC(SDL_Window); | |
723 if ( screen_pal ) { | |
724 SelectPalette(hdc, screen_pal, FALSE); | |
725 } | |
726 mdc = CreateCompatibleDC(hdc); | |
727 SelectObject(mdc, screen_bmp); | |
728 for ( i=0; i<numrects; ++i ) { | |
729 BitBlt(hdc, rects[i].x, rects[i].y, rects[i].w, rects[i].h, | |
730 mdc, rects[i].x, rects[i].y, SRCCOPY); | |
731 } | |
732 DeleteDC(mdc); | |
733 ReleaseDC(SDL_Window, hdc); | |
734 } | |
735 | |
736 int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | |
737 { | |
738 RGBQUAD *pal; | |
739 int i; | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
740 #ifndef _WIN32_WCE |
0 | 741 HDC hdc, mdc; |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
742 #else |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
743 HDC hdc; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
744 #endif |
0 | 745 |
746 /* Update the display palette */ | |
747 hdc = GetDC(SDL_Window); | |
748 if ( screen_pal ) { | |
749 PALETTEENTRY *entries; | |
750 | |
751 entries = (PALETTEENTRY *)alloca(ncolors*sizeof(PALETTEENTRY)); | |
752 for ( i=0; i<ncolors; ++i ) { | |
753 entries[i].peRed = colors[i].r; | |
754 entries[i].peGreen = colors[i].g; | |
755 entries[i].peBlue = colors[i].b; | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
756 #ifndef _WIN32_WCE |
0 | 757 entries[i].peFlags = PC_NOCOLLAPSE; |
46
3dcf26fa9d15
*** empty log message ***
Sam Lantinga <slouken@lokigames.com>
parents:
45
diff
changeset
|
758 #else |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
759 entries[i].peFlags = 0; |
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
760 #endif |
0 | 761 } |
762 SetPaletteEntries(screen_pal, firstcolor, ncolors, entries); | |
763 SelectPalette(hdc, screen_pal, FALSE); | |
764 RealizePalette(hdc); | |
765 } | |
766 | |
767 /* Copy palette colors into DIB palette */ | |
768 pal = (RGBQUAD *)alloca(ncolors*sizeof(RGBQUAD)); | |
769 for ( i=0; i<ncolors; ++i ) { | |
770 pal[i].rgbRed = colors[i].r; | |
771 pal[i].rgbGreen = colors[i].g; | |
772 pal[i].rgbBlue = colors[i].b; | |
773 pal[i].rgbReserved = 0; | |
774 } | |
775 | |
776 /* 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
|
777 #ifndef _WIN32_WCE |
0 | 778 mdc = CreateCompatibleDC(hdc); |
779 SelectObject(mdc, screen_bmp); | |
780 SetDIBColorTable(mdc, firstcolor, ncolors, pal); | |
781 BitBlt(hdc, 0, 0, this->screen->w, this->screen->h, | |
782 mdc, 0, 0, SRCCOPY); | |
783 DeleteDC(mdc); | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
784 #endif |
0 | 785 ReleaseDC(SDL_Window, hdc); |
786 return(1); | |
787 } | |
788 | |
789 static void DIB_CheckGamma(_THIS) | |
790 { | |
791 #ifndef NO_GAMMA_SUPPORT | |
792 HDC hdc; | |
793 WORD ramp[3*256]; | |
794 | |
795 /* If we fail to get gamma, disable gamma control */ | |
796 hdc = GetDC(SDL_Window); | |
797 if ( ! GetDeviceGammaRamp(hdc, ramp) ) { | |
798 this->GetGammaRamp = NULL; | |
799 this->SetGammaRamp = NULL; | |
800 } | |
801 ReleaseDC(SDL_Window, hdc); | |
802 #endif /* !NO_GAMMA_SUPPORT */ | |
803 } | |
804 static void DIB_SwapGamma(_THIS) | |
805 { | |
806 #ifndef NO_GAMMA_SUPPORT | |
807 HDC hdc; | |
808 | |
809 if ( gamma_saved ) { | |
810 hdc = GetDC(SDL_Window); | |
811 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { | |
812 /* About to leave active state, restore gamma */ | |
813 SetDeviceGammaRamp(hdc, gamma_saved); | |
814 } else { | |
815 /* About to enter active state, set game gamma */ | |
816 GetDeviceGammaRamp(hdc, gamma_saved); | |
817 SetDeviceGammaRamp(hdc, this->gamma); | |
818 } | |
819 ReleaseDC(SDL_Window, hdc); | |
820 } | |
821 #endif /* !NO_GAMMA_SUPPORT */ | |
822 } | |
823 static void DIB_QuitGamma(_THIS) | |
824 { | |
825 #ifndef NO_GAMMA_SUPPORT | |
826 if ( gamma_saved ) { | |
827 /* Restore the original gamma if necessary */ | |
828 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { | |
829 HDC hdc; | |
830 | |
831 hdc = GetDC(SDL_Window); | |
832 SetDeviceGammaRamp(hdc, gamma_saved); | |
833 ReleaseDC(SDL_Window, hdc); | |
834 } | |
835 | |
836 /* Free the saved gamma memory */ | |
837 free(gamma_saved); | |
838 gamma_saved = 0; | |
839 } | |
840 #endif /* !NO_GAMMA_SUPPORT */ | |
841 } | |
842 | |
843 #ifndef NO_GAMMA_SUPPORT | |
844 | |
845 static int DIB_SetGammaRamp(_THIS, Uint16 *ramp) | |
846 { | |
847 HDC hdc; | |
848 BOOL succeeded; | |
849 | |
850 /* Set the ramp for the display */ | |
851 if ( ! gamma_saved ) { | |
852 gamma_saved = (WORD *)malloc(3*256*sizeof(*gamma_saved)); | |
853 if ( ! gamma_saved ) { | |
854 SDL_OutOfMemory(); | |
855 return -1; | |
856 } | |
857 hdc = GetDC(SDL_Window); | |
858 GetDeviceGammaRamp(hdc, gamma_saved); | |
859 ReleaseDC(SDL_Window, hdc); | |
860 } | |
861 if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { | |
862 hdc = GetDC(SDL_Window); | |
863 succeeded = SetDeviceGammaRamp(hdc, ramp); | |
864 ReleaseDC(SDL_Window, hdc); | |
865 } else { | |
866 succeeded = TRUE; | |
867 } | |
868 return succeeded ? 0 : -1; | |
869 } | |
870 | |
871 static int DIB_GetGammaRamp(_THIS, Uint16 *ramp) | |
872 { | |
873 HDC hdc; | |
874 BOOL succeeded; | |
875 | |
876 /* Get the ramp from the display */ | |
877 hdc = GetDC(SDL_Window); | |
878 succeeded = GetDeviceGammaRamp(hdc, ramp); | |
879 ReleaseDC(SDL_Window, hdc); | |
880 return succeeded ? 0 : -1; | |
881 } | |
882 | |
883 #endif /* !NO_GAMMA_SUPPORT */ | |
884 | |
885 void DIB_VideoQuit(_THIS) | |
886 { | |
887 /* Destroy the window and everything associated with it */ | |
888 if ( SDL_Window ) { | |
889 /* Delete the screen bitmap (also frees screen->pixels) */ | |
890 if ( this->screen ) { | |
891 #ifndef NO_CHANGEDISPLAYSETTINGS | |
892 if ( this->screen->flags & SDL_FULLSCREEN ) { | |
893 ChangeDisplaySettings(NULL, 0); | |
894 } | |
895 #endif | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
896 #ifdef HAVE_OPENGL |
0 | 897 if ( this->screen->flags & SDL_OPENGL ) { |
898 WIN_GL_ShutDown(this); | |
899 } | |
36
13ee9f4834ea
Windows CE patches contributed by Rainer Loritz
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
900 #endif /* HAVE_OPENGL */ |
0 | 901 this->screen->pixels = NULL; |
902 } | |
903 if ( screen_bmp ) { | |
904 DeleteObject(screen_bmp); | |
905 screen_bmp = NULL; | |
906 } | |
907 if ( screen_icn ) { | |
908 DestroyIcon(screen_icn); | |
909 screen_icn = NULL; | |
910 } | |
911 DIB_QuitGamma(this); | |
912 DIB_DestroyWindow(this); | |
913 | |
914 SDL_Window = NULL; | |
915 } | |
916 } | |
917 | |
918 /* Exported for the windows message loop only */ | |
919 static void DIB_FocusPalette(_THIS, int foreground) | |
920 { | |
921 if ( screen_pal != NULL ) { | |
922 HDC hdc; | |
923 | |
924 hdc = GetDC(SDL_Window); | |
925 SelectPalette(hdc, screen_pal, FALSE); | |
926 if ( RealizePalette(hdc) ) | |
927 InvalidateRect(SDL_Window, NULL, FALSE); | |
928 ReleaseDC(SDL_Window, hdc); | |
929 } | |
930 } | |
931 static void DIB_RealizePalette(_THIS) | |
932 { | |
933 DIB_FocusPalette(this, 1); | |
934 } | |
935 static void DIB_PaletteChanged(_THIS, HWND window) | |
936 { | |
937 if ( window != SDL_Window ) { | |
938 DIB_FocusPalette(this, 0); | |
939 } | |
940 } | |
941 | |
942 /* Exported for the windows message loop only */ | |
943 static void DIB_WinPAINT(_THIS, HDC hdc) | |
944 { | |
945 HDC mdc; | |
946 | |
947 if ( screen_pal ) { | |
948 SelectPalette(hdc, screen_pal, FALSE); | |
949 } | |
950 mdc = CreateCompatibleDC(hdc); | |
951 SelectObject(mdc, screen_bmp); | |
952 BitBlt(hdc, 0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h, | |
953 mdc, 0, 0, SRCCOPY); | |
954 DeleteDC(mdc); | |
955 } | |
956 | |
957 /* Stub in case DirectX isn't available */ | |
958 #ifndef ENABLE_DIRECTX | |
959 void DX5_SoundFocus(HWND hwnd) | |
960 { | |
961 return; | |
962 } | |
963 #endif |