Mercurial > sdl-ios-xcode
comparison src/video/windib/SDL_dibvideo.c @ 1330:450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
using Visual C++ 2005
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 06 Feb 2006 08:28:51 +0000 |
parents | c9b51268668f |
children | 3692456e7b0f |
comparison
equal
deleted
inserted
replaced
1329:bc67bbf87818 | 1330:450721ad5436 |
---|---|
18 | 18 |
19 Sam Lantinga | 19 Sam Lantinga |
20 slouken@libsdl.org | 20 slouken@libsdl.org |
21 */ | 21 */ |
22 | 22 |
23 #include <stdio.h> | 23 #include "SDL_windows.h" |
24 #include <stdlib.h> | |
25 #include <malloc.h> | |
26 #include <windows.h> | |
27 | |
28 | 24 |
29 #if defined(_WIN32_WCE) | 25 #if defined(_WIN32_WCE) |
30 | 26 |
31 // defined and used in SDL_sysevents.c | 27 // defined and used in SDL_sysevents.c |
32 extern HINSTANCE aygshell; | 28 extern HINSTANCE aygshell; |
39 #endif | 35 #endif |
40 | 36 |
41 #include "SDL.h" | 37 #include "SDL.h" |
42 #include "SDL_mutex.h" | 38 #include "SDL_mutex.h" |
43 #include "SDL_syswm.h" | 39 #include "SDL_syswm.h" |
40 #include "SDL_stdlib.h" | |
41 #include "SDL_string.h" | |
44 #include "SDL_sysvideo.h" | 42 #include "SDL_sysvideo.h" |
45 #include "SDL_sysevents.h" | 43 #include "SDL_sysevents.h" |
46 #include "SDL_events_c.h" | 44 #include "SDL_events_c.h" |
47 #include "SDL_pixels_c.h" | 45 #include "SDL_pixels_c.h" |
48 #include "SDL_dibvideo.h" | 46 #include "SDL_dibvideo.h" |
537 settings.dmSize = sizeof(DEVMODE); | 535 settings.dmSize = sizeof(DEVMODE); |
538 settings.dmBitsPerPel = video->format->BitsPerPixel; | 536 settings.dmBitsPerPel = video->format->BitsPerPixel; |
539 settings.dmPelsWidth = width; | 537 settings.dmPelsWidth = width; |
540 settings.dmPelsHeight = height; | 538 settings.dmPelsHeight = height; |
541 settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; | 539 settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; |
542 if ( width <= SDL_desktop_mode.dmPelsWidth && height <= SDL_desktop_mode.dmPelsHeight ) { | 540 if ( width <= (int)SDL_desktop_mode.dmPelsWidth && |
541 height <= (int)SDL_desktop_mode.dmPelsHeight ) { | |
543 settings.dmDisplayFrequency = SDL_desktop_mode.dmDisplayFrequency; | 542 settings.dmDisplayFrequency = SDL_desktop_mode.dmDisplayFrequency; |
544 settings.dmFields |= DM_DISPLAYFREQUENCY; | 543 settings.dmFields |= DM_DISPLAYFREQUENCY; |
545 } | 544 } |
546 changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL); | 545 changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL); |
547 if ( ! changed && (settings.dmFields & DM_DISPLAYFREQUENCY) ) { | 546 if ( ! changed && (settings.dmFields & DM_DISPLAYFREQUENCY) ) { |
792 /* Update the display palette */ | 791 /* Update the display palette */ |
793 hdc = GetDC(SDL_Window); | 792 hdc = GetDC(SDL_Window); |
794 if ( screen_pal ) { | 793 if ( screen_pal ) { |
795 PALETTEENTRY *entries; | 794 PALETTEENTRY *entries; |
796 | 795 |
797 entries = (PALETTEENTRY *)alloca(ncolors*sizeof(PALETTEENTRY)); | 796 entries = SDL_stack_alloc(PALETTEENTRY, ncolors); |
798 for ( i=0; i<ncolors; ++i ) { | 797 for ( i=0; i<ncolors; ++i ) { |
799 entries[i].peRed = colors[i].r; | 798 entries[i].peRed = colors[i].r; |
800 entries[i].peGreen = colors[i].g; | 799 entries[i].peGreen = colors[i].g; |
801 entries[i].peBlue = colors[i].b; | 800 entries[i].peBlue = colors[i].b; |
802 entries[i].peFlags = PC_NOCOLLAPSE; | 801 entries[i].peFlags = PC_NOCOLLAPSE; |
803 } | 802 } |
804 SetPaletteEntries(screen_pal, firstcolor, ncolors, entries); | 803 SetPaletteEntries(screen_pal, firstcolor, ncolors, entries); |
805 SelectPalette(hdc, screen_pal, FALSE); | 804 SelectPalette(hdc, screen_pal, FALSE); |
806 RealizePalette(hdc); | 805 RealizePalette(hdc); |
806 SDL_stack_free(entries); | |
807 } | 807 } |
808 | 808 |
809 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) | 809 #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) |
810 /* Copy palette colors into DIB palette */ | 810 /* Copy palette colors into DIB palette */ |
811 pal = (RGBQUAD *)alloca(ncolors*sizeof(RGBQUAD)); | 811 pal = SDL_stack_alloc(RGBQUAD, ncolors); |
812 for ( i=0; i<ncolors; ++i ) { | 812 for ( i=0; i<ncolors; ++i ) { |
813 pal[i].rgbRed = colors[i].r; | 813 pal[i].rgbRed = colors[i].r; |
814 pal[i].rgbGreen = colors[i].g; | 814 pal[i].rgbGreen = colors[i].g; |
815 pal[i].rgbBlue = colors[i].b; | 815 pal[i].rgbBlue = colors[i].b; |
816 pal[i].rgbReserved = 0; | 816 pal[i].rgbReserved = 0; |
821 SelectObject(mdc, screen_bmp); | 821 SelectObject(mdc, screen_bmp); |
822 SetDIBColorTable(mdc, firstcolor, ncolors, pal); | 822 SetDIBColorTable(mdc, firstcolor, ncolors, pal); |
823 BitBlt(hdc, 0, 0, this->screen->w, this->screen->h, | 823 BitBlt(hdc, 0, 0, this->screen->w, this->screen->h, |
824 mdc, 0, 0, SRCCOPY); | 824 mdc, 0, 0, SRCCOPY); |
825 DeleteDC(mdc); | 825 DeleteDC(mdc); |
826 SDL_stack_free(pal); | |
826 #endif | 827 #endif |
827 ReleaseDC(SDL_Window, hdc); | 828 ReleaseDC(SDL_Window, hdc); |
828 return(1); | 829 return(1); |
829 } | 830 } |
830 | 831 |