Mercurial > sdl-ios-xcode
comparison src/video/windib/SDL_dibvideo.c @ 453:a6fa62b1be09
Updated for embedded Visual C++ 4.0
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 20 Aug 2002 00:20:06 +0000 |
parents | 323c766f5a46 |
children | 1080bfc4aa96 |
comparison
equal
deleted
inserted
replaced
452:4c5c10383201 | 453:a6fa62b1be09 |
---|---|
50 | 50 |
51 #ifdef _WIN32_WCE | 51 #ifdef _WIN32_WCE |
52 #define NO_GETDIBITS | 52 #define NO_GETDIBITS |
53 #define NO_CHANGEDISPLAYSETTINGS | 53 #define NO_CHANGEDISPLAYSETTINGS |
54 #define NO_GAMMA_SUPPORT | 54 #define NO_GAMMA_SUPPORT |
55 #endif | |
56 #ifndef WS_MAXIMIZE | |
57 #define WS_MAXIMIZE 0 | |
58 #endif | |
59 #ifndef SWP_NOCOPYBITS | |
60 #define SWP_NOCOPYBITS 0 | |
61 #endif | |
62 #ifndef PC_NOCOLLAPSE | |
63 #define PC_NOCOLLAPSE 0 | |
55 #endif | 64 #endif |
56 | 65 |
57 /* Initialization/Query functions */ | 66 /* Initialization/Query functions */ |
58 static int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat); | 67 static int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat); |
59 static SDL_Rect **DIB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); | 68 static SDL_Rect **DIB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); |
141 device->FlipHWSurface = NULL; | 150 device->FlipHWSurface = NULL; |
142 device->FreeHWSurface = DIB_FreeHWSurface; | 151 device->FreeHWSurface = DIB_FreeHWSurface; |
143 device->SetGammaRamp = DIB_SetGammaRamp; | 152 device->SetGammaRamp = DIB_SetGammaRamp; |
144 device->GetGammaRamp = DIB_GetGammaRamp; | 153 device->GetGammaRamp = DIB_GetGammaRamp; |
145 #ifdef HAVE_OPENGL | 154 #ifdef HAVE_OPENGL |
146 device->GL_LoadLibrary = WIN_GL_LoadLibrary; | 155 device->GL_LoadLibrary = WIN_GL_LoadLibrary; |
147 device->GL_GetProcAddress = WIN_GL_GetProcAddress; | 156 device->GL_GetProcAddress = WIN_GL_GetProcAddress; |
148 device->GL_GetAttribute = WIN_GL_GetAttribute; | 157 device->GL_GetAttribute = WIN_GL_GetAttribute; |
149 device->GL_MakeCurrent = WIN_GL_MakeCurrent; | 158 device->GL_MakeCurrent = WIN_GL_MakeCurrent; |
150 device->GL_SwapBuffers = WIN_GL_SwapBuffers; | 159 device->GL_SwapBuffers = WIN_GL_SwapBuffers; |
151 #endif | 160 #endif |
152 device->SetCaption = WIN_SetWMCaption; | 161 device->SetCaption = WIN_SetWMCaption; |
153 device->SetIcon = WIN_SetWMIcon; | 162 device->SetIcon = WIN_SetWMIcon; |
154 device->IconifyWindow = WIN_IconifyWindow; | 163 device->IconifyWindow = WIN_IconifyWindow; |
155 device->GrabInput = WIN_GrabInput; | 164 device->GrabInput = WIN_GrabInput; |
438 DWORD style; | 447 DWORD style; |
439 const DWORD directstyle = | 448 const DWORD directstyle = |
440 (WS_POPUP); | 449 (WS_POPUP); |
441 const DWORD windowstyle = | 450 const DWORD windowstyle = |
442 (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX); | 451 (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX); |
443 #ifndef _WIN32_WCE | |
444 const DWORD resizestyle = | 452 const DWORD resizestyle = |
445 (WS_THICKFRAME|WS_MAXIMIZEBOX); | 453 (WS_THICKFRAME|WS_MAXIMIZEBOX); |
446 #endif | |
447 int binfo_size; | 454 int binfo_size; |
448 BITMAPINFO *binfo; | 455 BITMAPINFO *binfo; |
449 HDC hdc; | 456 HDC hdc; |
450 RECT bounds; | 457 RECT bounds; |
451 int x, y; | 458 int x, y; |
453 Uint32 Rmask, Gmask, Bmask; | 460 Uint32 Rmask, Gmask, Bmask; |
454 | 461 |
455 /* See whether or not we should center the window */ | 462 /* See whether or not we should center the window */ |
456 was_visible = IsWindowVisible(SDL_Window); | 463 was_visible = IsWindowVisible(SDL_Window); |
457 | 464 |
458 #ifdef HAVE_OPENGL | |
459 /* Clean up any GL context that may be hanging around */ | 465 /* Clean up any GL context that may be hanging around */ |
460 if ( current->flags & SDL_OPENGL ) { | 466 if ( current->flags & SDL_OPENGL ) { |
461 WIN_GL_ShutDown(this); | 467 WIN_GL_ShutDown(this); |
462 } | 468 } |
463 #endif /* HAVE_OPENGL */ | |
464 | 469 |
465 /* Recalculate the bitmasks if necessary */ | 470 /* Recalculate the bitmasks if necessary */ |
466 if ( bpp == current->format->BitsPerPixel ) { | 471 if ( bpp == current->format->BitsPerPixel ) { |
467 video = current; | 472 video = current; |
468 } else { | 473 } else { |
540 create identity palette switching to a palettized mode */ | 545 create identity palette switching to a palettized mode */ |
541 screen_pal = DIB_CreatePalette(bpp); | 546 screen_pal = DIB_CreatePalette(bpp); |
542 } | 547 } |
543 | 548 |
544 style = GetWindowLong(SDL_Window, GWL_STYLE); | 549 style = GetWindowLong(SDL_Window, GWL_STYLE); |
545 #ifndef _WIN32_WCE | |
546 style &= ~(resizestyle|WS_MAXIMIZE); | 550 style &= ~(resizestyle|WS_MAXIMIZE); |
547 #endif | |
548 if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { | 551 if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { |
549 style &= ~windowstyle; | 552 style &= ~windowstyle; |
550 style |= directstyle; | 553 style |= directstyle; |
551 } else { | 554 } else { |
552 #ifndef NO_CHANGEDISPLAYSETTINGS | 555 #ifndef NO_CHANGEDISPLAYSETTINGS |
560 video->flags |= SDL_NOFRAME; | 563 video->flags |= SDL_NOFRAME; |
561 } else { | 564 } else { |
562 style &= ~directstyle; | 565 style &= ~directstyle; |
563 style |= windowstyle; | 566 style |= windowstyle; |
564 if ( flags & SDL_RESIZABLE ) { | 567 if ( flags & SDL_RESIZABLE ) { |
565 #ifndef _WIN32_WCE | |
566 style |= resizestyle; | 568 style |= resizestyle; |
567 #endif | |
568 video->flags |= SDL_RESIZABLE; | 569 video->flags |= SDL_RESIZABLE; |
569 } | 570 } |
570 } | 571 } |
571 #ifndef _WIN32_WCE | 572 #if WS_MAXIMIZE |
572 if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; | 573 if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; |
573 #endif | 574 #endif |
574 } | 575 } |
575 | 576 |
576 /* DJM: Don't piss of anyone who has setup his own window */ | 577 /* DJM: Don't piss of anyone who has setup his own window */ |
657 SDL_resizing = 1; | 658 SDL_resizing = 1; |
658 bounds.left = 0; | 659 bounds.left = 0; |
659 bounds.top = 0; | 660 bounds.top = 0; |
660 bounds.right = video->w; | 661 bounds.right = video->w; |
661 bounds.bottom = video->h; | 662 bounds.bottom = video->h; |
662 #ifndef _WIN32_WCE | 663 AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0); |
663 AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE); | |
664 #else | |
665 AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE,0); | |
666 #endif | |
667 width = bounds.right-bounds.left; | 664 width = bounds.right-bounds.left; |
668 height = bounds.bottom-bounds.top; | 665 height = bounds.bottom-bounds.top; |
669 x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; | 666 x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; |
670 y = (GetSystemMetrics(SM_CYSCREEN)-height)/2; | 667 y = (GetSystemMetrics(SM_CYSCREEN)-height)/2; |
671 if ( y < 0 ) { /* Cover up title bar for more client area */ | 668 if ( y < 0 ) { /* Cover up title bar for more client area */ |
672 y -= GetSystemMetrics(SM_CYCAPTION)/2; | 669 y -= GetSystemMetrics(SM_CYCAPTION)/2; |
673 } | 670 } |
674 #ifndef _WIN32_WCE | |
675 swp_flags = (SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_SHOWWINDOW); | 671 swp_flags = (SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_SHOWWINDOW); |
676 #else | |
677 swp_flags = (SWP_FRAMECHANGED | SWP_SHOWWINDOW); | |
678 #endif | |
679 if ( was_visible && !(flags & SDL_FULLSCREEN) ) { | 672 if ( was_visible && !(flags & SDL_FULLSCREEN) ) { |
680 swp_flags |= SWP_NOMOVE; | 673 swp_flags |= SWP_NOMOVE; |
681 } | 674 } |
682 if ( flags & SDL_FULLSCREEN ) { | 675 if ( flags & SDL_FULLSCREEN ) { |
683 top = HWND_TOPMOST; | 676 top = HWND_TOPMOST; |
687 SetWindowPos(SDL_Window, top, x, y, width, height, swp_flags); | 680 SetWindowPos(SDL_Window, top, x, y, width, height, swp_flags); |
688 SDL_resizing = 0; | 681 SDL_resizing = 0; |
689 SetForegroundWindow(SDL_Window); | 682 SetForegroundWindow(SDL_Window); |
690 } | 683 } |
691 | 684 |
692 #ifdef HAVE_OPENGL | |
693 /* Set up for OpenGL */ | 685 /* Set up for OpenGL */ |
694 if ( flags & SDL_OPENGL ) { | 686 if ( flags & SDL_OPENGL ) { |
695 if ( WIN_GL_SetupWindow(this) < 0 ) { | 687 if ( WIN_GL_SetupWindow(this) < 0 ) { |
696 return(NULL); | 688 return(NULL); |
697 } | 689 } |
698 video->flags |= SDL_OPENGL; | 690 video->flags |= SDL_OPENGL; |
699 } | 691 } |
700 #endif /* HAVE_OPENGL */ | |
701 | 692 |
702 /* We're live! */ | 693 /* We're live! */ |
703 return(video); | 694 return(video); |
704 } | 695 } |
705 | 696 |
758 entries = (PALETTEENTRY *)alloca(ncolors*sizeof(PALETTEENTRY)); | 749 entries = (PALETTEENTRY *)alloca(ncolors*sizeof(PALETTEENTRY)); |
759 for ( i=0; i<ncolors; ++i ) { | 750 for ( i=0; i<ncolors; ++i ) { |
760 entries[i].peRed = colors[i].r; | 751 entries[i].peRed = colors[i].r; |
761 entries[i].peGreen = colors[i].g; | 752 entries[i].peGreen = colors[i].g; |
762 entries[i].peBlue = colors[i].b; | 753 entries[i].peBlue = colors[i].b; |
763 #ifndef _WIN32_WCE | |
764 entries[i].peFlags = PC_NOCOLLAPSE; | 754 entries[i].peFlags = PC_NOCOLLAPSE; |
765 #else | |
766 entries[i].peFlags = 0; | |
767 #endif | |
768 } | 755 } |
769 SetPaletteEntries(screen_pal, firstcolor, ncolors, entries); | 756 SetPaletteEntries(screen_pal, firstcolor, ncolors, entries); |
770 SelectPalette(hdc, screen_pal, FALSE); | 757 SelectPalette(hdc, screen_pal, FALSE); |
771 RealizePalette(hdc); | 758 RealizePalette(hdc); |
772 } | 759 } |
915 if ( this->screen->flags & SDL_FULLSCREEN ) { | 902 if ( this->screen->flags & SDL_FULLSCREEN ) { |
916 ChangeDisplaySettings(NULL, 0); | 903 ChangeDisplaySettings(NULL, 0); |
917 ShowWindow(SDL_Window, SW_HIDE); | 904 ShowWindow(SDL_Window, SW_HIDE); |
918 } | 905 } |
919 #endif | 906 #endif |
920 #ifdef HAVE_OPENGL | |
921 if ( this->screen->flags & SDL_OPENGL ) { | 907 if ( this->screen->flags & SDL_OPENGL ) { |
922 WIN_GL_ShutDown(this); | 908 WIN_GL_ShutDown(this); |
923 } | 909 } |
924 #endif /* HAVE_OPENGL */ | |
925 this->screen->pixels = NULL; | 910 this->screen->pixels = NULL; |
926 } | 911 } |
927 if ( screen_bmp ) { | 912 if ( screen_bmp ) { |
928 DeleteObject(screen_bmp); | 913 DeleteObject(screen_bmp); |
929 screen_bmp = NULL; | 914 screen_bmp = NULL; |