comparison src/video/windib/SDL_dibvideo.c @ 36:13ee9f4834ea

Windows CE patches contributed by Rainer Loritz
author Sam Lantinga <slouken@lokigames.com>
date Wed, 23 May 2001 23:35:10 +0000
parents 74212992fb08
children 60a6e045808e
comparison
equal deleted inserted replaced
35:d3bc792e136d 36:13ee9f4834ea
438 DWORD style; 438 DWORD style;
439 const DWORD directstyle = 439 const DWORD directstyle =
440 (WS_POPUP); 440 (WS_POPUP);
441 const DWORD windowstyle = 441 const DWORD windowstyle =
442 (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX); 442 (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX);
443 #ifndef _WIN32_WCE
443 const DWORD resizestyle = 444 const DWORD resizestyle =
444 (WS_THICKFRAME|WS_MAXIMIZEBOX); 445 (WS_THICKFRAME|WS_MAXIMIZEBOX);
446 #endif
445 int binfo_size; 447 int binfo_size;
446 BITMAPINFO *binfo; 448 BITMAPINFO *binfo;
447 HDC hdc; 449 HDC hdc;
448 RECT bounds; 450 RECT bounds;
449 int x, y; 451 int x, y;
451 Uint32 Rmask, Gmask, Bmask; 453 Uint32 Rmask, Gmask, Bmask;
452 454
453 /* See whether or not we should center the window */ 455 /* See whether or not we should center the window */
454 was_visible = IsWindowVisible(SDL_Window); 456 was_visible = IsWindowVisible(SDL_Window);
455 457
458 #ifdef HAVE_OPENGL
456 /* Clean up any GL context that may be hanging around */ 459 /* Clean up any GL context that may be hanging around */
457 if ( current->flags & SDL_OPENGL ) { 460 if ( current->flags & SDL_OPENGL ) {
458 WIN_GL_ShutDown(this); 461 WIN_GL_ShutDown(this);
459 } 462 }
463 #endif /* HAVE_OPENGL */
460 464
461 /* Recalculate the bitmasks if necessary */ 465 /* Recalculate the bitmasks if necessary */
462 if ( bpp == current->format->BitsPerPixel ) { 466 if ( bpp == current->format->BitsPerPixel ) {
463 video = current; 467 video = current;
464 } else { 468 } else {
533 } 537 }
534 } 538 }
535 #endif /* !NO_CHANGEDISPLAYSETTINGS */ 539 #endif /* !NO_CHANGEDISPLAYSETTINGS */
536 540
537 style = GetWindowLong(SDL_Window, GWL_STYLE); 541 style = GetWindowLong(SDL_Window, GWL_STYLE);
542 #ifndef _WIN32_WCE
538 style &= ~(resizestyle|WS_MAXIMIZE); 543 style &= ~(resizestyle|WS_MAXIMIZE);
544 #endif
539 if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { 545 if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
540 style &= ~windowstyle; 546 style &= ~windowstyle;
541 style |= directstyle; 547 style |= directstyle;
542 } else { 548 } else {
543 #ifndef NO_CHANGEDISPLAYSETTINGS 549 #ifndef NO_CHANGEDISPLAYSETTINGS
551 video->flags |= SDL_NOFRAME; 557 video->flags |= SDL_NOFRAME;
552 } else { 558 } else {
553 style &= ~directstyle; 559 style &= ~directstyle;
554 style |= windowstyle; 560 style |= windowstyle;
555 if ( flags & SDL_RESIZABLE ) { 561 if ( flags & SDL_RESIZABLE ) {
562 #ifndef _WIN32_WCE
556 style |= resizestyle; 563 style |= resizestyle;
564 #endif
557 video->flags |= SDL_RESIZABLE; 565 video->flags |= SDL_RESIZABLE;
558 } 566 }
559 } 567 }
568 #ifndef _WIN32_WCE
560 if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; 569 if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
570 #endif
561 } 571 }
562 SetWindowLong(SDL_Window, GWL_STYLE, style); 572 SetWindowLong(SDL_Window, GWL_STYLE, style);
563 573
564 /* Delete the old bitmap if necessary */ 574 /* Delete the old bitmap if necessary */
565 if ( screen_bmp != NULL ) { 575 if ( screen_bmp != NULL ) {
640 SDL_resizing = 1; 650 SDL_resizing = 1;
641 bounds.left = 0; 651 bounds.left = 0;
642 bounds.top = 0; 652 bounds.top = 0;
643 bounds.right = video->w; 653 bounds.right = video->w;
644 bounds.bottom = video->h; 654 bounds.bottom = video->h;
655 #ifndef _WIN32_WCE
645 AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE); 656 AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE);
657 #else
658 AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE,0);
659 #endif
646 width = bounds.right-bounds.left; 660 width = bounds.right-bounds.left;
647 height = bounds.bottom-bounds.top; 661 height = bounds.bottom-bounds.top;
648 x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; 662 x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
649 y = (GetSystemMetrics(SM_CYSCREEN)-height)/2; 663 y = (GetSystemMetrics(SM_CYSCREEN)-height)/2;
650 if ( y < 0 ) { /* Cover up title bar for more client area */ 664 if ( y < 0 ) { /* Cover up title bar for more client area */
651 y -= GetSystemMetrics(SM_CYCAPTION)/2; 665 y -= GetSystemMetrics(SM_CYCAPTION)/2;
652 } 666 }
667 #ifndef _WIN32_WCE
653 swp_flags = (SWP_NOCOPYBITS | SWP_NOZORDER | SWP_SHOWWINDOW); 668 swp_flags = (SWP_NOCOPYBITS | SWP_NOZORDER | SWP_SHOWWINDOW);
669 #else
670 swp_flags = (SWP_NOZORDER | SWP_SHOWWINDOW);
671 #endif
654 if ( was_visible && !(flags & SDL_FULLSCREEN) ) { 672 if ( was_visible && !(flags & SDL_FULLSCREEN) ) {
655 swp_flags |= SWP_NOMOVE; 673 swp_flags |= SWP_NOMOVE;
656 } 674 }
657 SetWindowPos(SDL_Window, NULL, x, y, width, height, swp_flags); 675 SetWindowPos(SDL_Window, NULL, x, y, width, height, swp_flags);
658 SDL_resizing = 0; 676 SDL_resizing = 0;
659 SetForegroundWindow(SDL_Window); 677 SetForegroundWindow(SDL_Window);
660 } 678 }
661 679
680 #ifdef HAVE_OPENGL
662 /* Set up for OpenGL */ 681 /* Set up for OpenGL */
663 if ( flags & SDL_OPENGL ) { 682 if ( flags & SDL_OPENGL ) {
664 if ( WIN_GL_SetupWindow(this) < 0 ) { 683 if ( WIN_GL_SetupWindow(this) < 0 ) {
665 return(NULL); 684 return(NULL);
666 } 685 }
667 video->flags |= SDL_OPENGL; 686 video->flags |= SDL_OPENGL;
668 } 687 }
688 #endif /* HAVE_OPENGL */
689
669 /* We're live! */ 690 /* We're live! */
670 return(video); 691 return(video);
671 } 692 }
672 693
673 /* We don't actually allow hardware surfaces in the DIB driver */ 694 /* We don't actually allow hardware surfaces in the DIB driver */
709 730
710 int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) 731 int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
711 { 732 {
712 RGBQUAD *pal; 733 RGBQUAD *pal;
713 int i; 734 int i;
735 #ifndef _WIN32_WCE
714 HDC hdc, mdc; 736 HDC hdc, mdc;
737 #else
738 HDC hdc;
739 #endif
715 740
716 /* Update the display palette */ 741 /* Update the display palette */
717 hdc = GetDC(SDL_Window); 742 hdc = GetDC(SDL_Window);
718 if ( screen_pal ) { 743 if ( screen_pal ) {
719 PALETTEENTRY *entries; 744 PALETTEENTRY *entries;
721 entries = (PALETTEENTRY *)alloca(ncolors*sizeof(PALETTEENTRY)); 746 entries = (PALETTEENTRY *)alloca(ncolors*sizeof(PALETTEENTRY));
722 for ( i=0; i<ncolors; ++i ) { 747 for ( i=0; i<ncolors; ++i ) {
723 entries[i].peRed = colors[i].r; 748 entries[i].peRed = colors[i].r;
724 entries[i].peGreen = colors[i].g; 749 entries[i].peGreen = colors[i].g;
725 entries[i].peBlue = colors[i].b; 750 entries[i].peBlue = colors[i].b;
751 #ifndef _WIN32_WCE
726 entries[i].peFlags = PC_NOCOLLAPSE; 752 entries[i].peFlags = PC_NOCOLLAPSE;
753 else
754 entries[i].peFlags = 0;
755 #endif
727 } 756 }
728 SetPaletteEntries(screen_pal, firstcolor, ncolors, entries); 757 SetPaletteEntries(screen_pal, firstcolor, ncolors, entries);
729 SelectPalette(hdc, screen_pal, FALSE); 758 SelectPalette(hdc, screen_pal, FALSE);
730 RealizePalette(hdc); 759 RealizePalette(hdc);
731 } 760 }
738 pal[i].rgbBlue = colors[i].b; 767 pal[i].rgbBlue = colors[i].b;
739 pal[i].rgbReserved = 0; 768 pal[i].rgbReserved = 0;
740 } 769 }
741 770
742 /* Set the DIB palette and update the display */ 771 /* Set the DIB palette and update the display */
772 #ifndef _WIN32_WCE
743 mdc = CreateCompatibleDC(hdc); 773 mdc = CreateCompatibleDC(hdc);
744 SelectObject(mdc, screen_bmp); 774 SelectObject(mdc, screen_bmp);
745 SetDIBColorTable(mdc, firstcolor, ncolors, pal); 775 SetDIBColorTable(mdc, firstcolor, ncolors, pal);
746 BitBlt(hdc, 0, 0, this->screen->w, this->screen->h, 776 BitBlt(hdc, 0, 0, this->screen->w, this->screen->h,
747 mdc, 0, 0, SRCCOPY); 777 mdc, 0, 0, SRCCOPY);
748 DeleteDC(mdc); 778 DeleteDC(mdc);
779 #endif
749 ReleaseDC(SDL_Window, hdc); 780 ReleaseDC(SDL_Window, hdc);
750 return(1); 781 return(1);
751 } 782 }
752 783
753 static void DIB_CheckGamma(_THIS) 784 static void DIB_CheckGamma(_THIS)
855 #ifndef NO_CHANGEDISPLAYSETTINGS 886 #ifndef NO_CHANGEDISPLAYSETTINGS
856 if ( this->screen->flags & SDL_FULLSCREEN ) { 887 if ( this->screen->flags & SDL_FULLSCREEN ) {
857 ChangeDisplaySettings(NULL, 0); 888 ChangeDisplaySettings(NULL, 0);
858 } 889 }
859 #endif 890 #endif
891 #ifdef HAVE_OPENGL
860 if ( this->screen->flags & SDL_OPENGL ) { 892 if ( this->screen->flags & SDL_OPENGL ) {
861 WIN_GL_ShutDown(this); 893 WIN_GL_ShutDown(this);
862 } 894 }
895 #endif /* HAVE_OPENGL */
863 this->screen->pixels = NULL; 896 this->screen->pixels = NULL;
864 } 897 }
865 if ( screen_bmp ) { 898 if ( screen_bmp ) {
866 DeleteObject(screen_bmp); 899 DeleteObject(screen_bmp);
867 screen_bmp = NULL; 900 screen_bmp = NULL;