Mercurial > sdl-ios-xcode
comparison src/video/windib/SDL_dibvideo.c @ 4162:3b7fc3416601 SDL-1.2
GAPI fixes from Stefan Klug
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 16 Feb 2009 22:32:34 +0000 |
parents | a1b03ba2fcd0 |
children | b40d6e58a5e5 |
comparison
equal
deleted
inserted
replaced
4161:bd91db0b0b5d | 4162:3b7fc3416601 |
---|---|
32 #include "SDL_syswm.h" | 32 #include "SDL_syswm.h" |
33 #include "../SDL_sysvideo.h" | 33 #include "../SDL_sysvideo.h" |
34 #include "../SDL_pixels_c.h" | 34 #include "../SDL_pixels_c.h" |
35 #include "../../events/SDL_sysevents.h" | 35 #include "../../events/SDL_sysevents.h" |
36 #include "../../events/SDL_events_c.h" | 36 #include "../../events/SDL_events_c.h" |
37 #include "SDL_gapidibvideo.h" | |
37 #include "SDL_dibvideo.h" | 38 #include "SDL_dibvideo.h" |
38 #include "../wincommon/SDL_syswm_c.h" | 39 #include "../wincommon/SDL_syswm_c.h" |
39 #include "../wincommon/SDL_sysmouse_c.h" | 40 #include "../wincommon/SDL_sysmouse_c.h" |
40 #include "SDL_dibevents_c.h" | 41 #include "SDL_dibevents_c.h" |
41 #include "../wincommon/SDL_wingl_c.h" | 42 #include "../wincommon/SDL_wingl_c.h" |
126 | 127 |
127 static void DIB_DeleteDevice(SDL_VideoDevice *device) | 128 static void DIB_DeleteDevice(SDL_VideoDevice *device) |
128 { | 129 { |
129 if ( device ) { | 130 if ( device ) { |
130 if ( device->hidden ) { | 131 if ( device->hidden ) { |
132 if ( device->hidden->dibInfo ) { | |
133 SDL_free( device->hidden->dibInfo ); | |
134 } | |
131 SDL_free(device->hidden); | 135 SDL_free(device->hidden); |
132 } | 136 } |
133 if ( device->gl_data ) { | 137 if ( device->gl_data ) { |
134 SDL_free(device->gl_data); | 138 SDL_free(device->gl_data); |
135 } | 139 } |
145 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); | 149 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); |
146 if ( device ) { | 150 if ( device ) { |
147 SDL_memset(device, 0, (sizeof *device)); | 151 SDL_memset(device, 0, (sizeof *device)); |
148 device->hidden = (struct SDL_PrivateVideoData *) | 152 device->hidden = (struct SDL_PrivateVideoData *) |
149 SDL_malloc((sizeof *device->hidden)); | 153 SDL_malloc((sizeof *device->hidden)); |
154 if(device->hidden){ | |
155 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); | |
156 device->hidden->dibInfo = (DibInfo *)SDL_malloc((sizeof(DibInfo))); | |
157 if(device->hidden->dibInfo == NULL) | |
158 { | |
159 SDL_free(device->hidden); | |
160 device->hidden = NULL; | |
161 } | |
162 } | |
163 | |
150 device->gl_data = (struct SDL_PrivateGLData *) | 164 device->gl_data = (struct SDL_PrivateGLData *) |
151 SDL_malloc((sizeof *device->gl_data)); | 165 SDL_malloc((sizeof *device->gl_data)); |
152 } | 166 } |
153 if ( (device == NULL) || (device->hidden == NULL) || | 167 if ( (device == NULL) || (device->hidden == NULL) || |
154 (device->gl_data == NULL) ) { | 168 (device->gl_data == NULL) ) { |
155 SDL_OutOfMemory(); | 169 SDL_OutOfMemory(); |
156 DIB_DeleteDevice(device); | 170 DIB_DeleteDevice(device); |
157 return(NULL); | 171 return(NULL); |
158 } | 172 } |
159 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); | 173 SDL_memset(device->hidden->dibInfo, 0, (sizeof *device->hidden->dibInfo)); |
160 SDL_memset(device->gl_data, 0, (sizeof *device->gl_data)); | 174 SDL_memset(device->gl_data, 0, (sizeof *device->gl_data)); |
161 | 175 |
162 /* Set the function pointers */ | 176 /* Set the function pointers */ |
163 device->VideoInit = DIB_VideoInit; | 177 device->VideoInit = DIB_VideoInit; |
164 device->ListModes = DIB_ListModes; | 178 device->ListModes = DIB_ListModes; |
345 #ifdef _WIN32_WCE | 359 #ifdef _WIN32_WCE |
346 settings.dmFields = DM_DISPLAYQUERYORIENTATION; | 360 settings.dmFields = DM_DISPLAYQUERYORIENTATION; |
347 this->hidden->supportRotation = ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL) == DISP_CHANGE_SUCCESSFUL; | 361 this->hidden->supportRotation = ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL) == DISP_CHANGE_SUCCESSFUL; |
348 #endif | 362 #endif |
349 /* Query for the desktop resolution */ | 363 /* Query for the desktop resolution */ |
364 SDL_desktop_mode.dmSize = sizeof(SDL_desktop_mode); | |
365 SDL_desktop_mode.dmDriverExtra = 0; | |
350 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode); | 366 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode); |
351 this->info.current_w = SDL_desktop_mode.dmPelsWidth; | 367 this->info.current_w = SDL_desktop_mode.dmPelsWidth; |
352 this->info.current_h = SDL_desktop_mode.dmPelsHeight; | 368 this->info.current_h = SDL_desktop_mode.dmPelsHeight; |
353 | 369 |
354 /* Query for the list of available video modes */ | 370 /* Query for the list of available video modes */ |
742 if ( flags & SDL_RESIZABLE ) { | 758 if ( flags & SDL_RESIZABLE ) { |
743 style |= resizestyle; | 759 style |= resizestyle; |
744 video->flags |= SDL_RESIZABLE; | 760 video->flags |= SDL_RESIZABLE; |
745 } | 761 } |
746 } | 762 } |
747 #if WS_MAXIMIZE | 763 #if WS_MAXIMIZE && !defined(_WIN32_WCE) |
748 if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; | 764 if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; |
749 #endif | 765 #endif |
750 } | 766 } |
751 | 767 |
752 /* DJM: Don't piss of anyone who has setup his own window */ | 768 /* DJM: Don't piss of anyone who has setup his own window */ |
1004 entry->peRed = colors[i].r; | 1020 entry->peRed = colors[i].r; |
1005 entry->peGreen = colors[i].g; | 1021 entry->peGreen = colors[i].g; |
1006 entry->peBlue = colors[i].b; | 1022 entry->peBlue = colors[i].b; |
1007 entry->peFlags = PC_NOCOLLAPSE; | 1023 entry->peFlags = PC_NOCOLLAPSE; |
1008 } | 1024 } |
1009 #ifdef SYSPAL_NOSTATIC | 1025 #if defined(SYSPAL_NOSTATIC) && !defined(_WIN32_WCE) |
1010 /* Check to make sure black and white are in position */ | 1026 /* Check to make sure black and white are in position */ |
1011 if ( GetSystemPaletteUse(hdc) != SYSPAL_NOSTATIC256 ) { | 1027 if ( GetSystemPaletteUse(hdc) != SYSPAL_NOSTATIC256 ) { |
1012 moved_entries += CheckPaletteEntry(screen_logpal, 0, 0x00, 0x00, 0x00); | 1028 moved_entries += CheckPaletteEntry(screen_logpal, 0, 0x00, 0x00, 0x00); |
1013 moved_entries += CheckPaletteEntry(screen_logpal, screen_logpal->palNumEntries-1, 0xff, 0xff, 0xff); | 1029 moved_entries += CheckPaletteEntry(screen_logpal, screen_logpal->palNumEntries-1, 0xff, 0xff, 0xff); |
1014 } | 1030 } |
1225 } | 1241 } |
1226 | 1242 |
1227 /* Exported for the windows message loop only */ | 1243 /* Exported for the windows message loop only */ |
1228 static void DIB_GrabStaticColors(HWND window) | 1244 static void DIB_GrabStaticColors(HWND window) |
1229 { | 1245 { |
1230 #ifdef SYSPAL_NOSTATIC | 1246 #if defined(SYSPAL_NOSTATIC) && !defined(_WIN32_WCE) |
1231 HDC hdc; | 1247 HDC hdc; |
1232 | 1248 |
1233 hdc = GetDC(window); | 1249 hdc = GetDC(window); |
1234 SetSystemPaletteUse(hdc, SYSPAL_NOSTATIC256); | 1250 SetSystemPaletteUse(hdc, SYSPAL_NOSTATIC256); |
1235 if ( GetSystemPaletteUse(hdc) != SYSPAL_NOSTATIC256 ) { | 1251 if ( GetSystemPaletteUse(hdc) != SYSPAL_NOSTATIC256 ) { |
1238 ReleaseDC(window, hdc); | 1254 ReleaseDC(window, hdc); |
1239 #endif | 1255 #endif |
1240 } | 1256 } |
1241 static void DIB_ReleaseStaticColors(HWND window) | 1257 static void DIB_ReleaseStaticColors(HWND window) |
1242 { | 1258 { |
1243 #ifdef SYSPAL_NOSTATIC | 1259 #if defined(SYSPAL_NOSTATIC) && !defined(_WIN32_WCE) |
1244 HDC hdc; | 1260 HDC hdc; |
1245 | 1261 |
1246 hdc = GetDC(window); | 1262 hdc = GetDC(window); |
1247 SetSystemPaletteUse(hdc, SYSPAL_STATIC); | 1263 SetSystemPaletteUse(hdc, SYSPAL_STATIC); |
1248 ReleaseDC(window, hdc); | 1264 ReleaseDC(window, hdc); |