comparison src/video/wincommon/SDL_syswm.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 <malloc.h>
25 #include <windows.h>
26 24
27 #include "SDL_version.h" 25 #include "SDL_version.h"
28 #include "SDL_error.h" 26 #include "SDL_error.h"
29 #include "SDL_video.h" 27 #include "SDL_video.h"
30 #include "SDL_syswm.h" 28 #include "SDL_syswm.h"
29 #include "SDL_stdlib.h"
30 #include "SDL_string.h"
31 #include "SDL_syswm_c.h" 31 #include "SDL_syswm_c.h"
32 #include "SDL_wingl_c.h" 32 #include "SDL_wingl_c.h"
33 #include "SDL_pixels_c.h" 33 #include "SDL_pixels_c.h"
34 #include "SDL_loadso.h" 34 #include "SDL_loadso.h"
35 35
117 icon_pitch = ((icon->w+3)&~3); 117 icon_pitch = ((icon->w+3)&~3);
118 mask_pitch = ((icon->w+7)/8); 118 mask_pitch = ((icon->w+7)/8);
119 icon_plen = icon->h*icon_pitch; 119 icon_plen = icon->h*icon_pitch;
120 icon_mlen = icon->h*mask_pitch; 120 icon_mlen = icon->h*mask_pitch;
121 icon_len = sizeof(*icon_win32)+icon_plen+icon_mlen; 121 icon_len = sizeof(*icon_win32)+icon_plen+icon_mlen;
122 icon_win32 = (struct Win32Icon *)alloca(icon_len); 122 icon_win32 = (struct Win32Icon *)SDL_stack_alloc(Uint8, icon_len);
123 if ( icon_win32 == NULL ) { 123 if ( icon_win32 == NULL ) {
124 return; 124 return;
125 } 125 }
126 memset(icon_win32, 0, icon_len); 126 memset(icon_win32, 0, icon_len);
127 127
135 135
136 /* Allocate a standard 256 color icon surface */ 136 /* Allocate a standard 256 color icon surface */
137 icon_256 = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h, 137 icon_256 = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h,
138 icon_win32->biBitCount, 0, 0, 0, 0); 138 icon_win32->biBitCount, 0, 0, 0, 0);
139 if ( icon_256 == NULL ) { 139 if ( icon_256 == NULL ) {
140 SDL_stack_free(icon_win32);
140 return; 141 return;
141 } 142 }
142 pal_256 = icon_256->format->palette; 143 pal_256 = icon_256->format->palette;
143 if (icon->format->palette && 144 if (icon->format->palette &&
144 (icon->format->BitsPerPixel == icon_256->format->BitsPerPixel)){ 145 (icon->format->BitsPerPixel == icon_256->format->BitsPerPixel)){
165 166
166 /* Convert icon to a standard surface format. This may not always 167 /* Convert icon to a standard surface format. This may not always
167 be necessary, as Windows supports a variety of BMP formats, but 168 be necessary, as Windows supports a variety of BMP formats, but
168 it greatly simplifies our code. 169 it greatly simplifies our code.
169 */ 170 */
170 bounds.x = 0; 171 bounds.x = 0;
171 bounds.y = 0; 172 bounds.y = 0;
172 bounds.w = icon->w; 173 bounds.w = icon->w;
173 bounds.h = icon->h; 174 bounds.h = icon->h;
174 if ( SDL_LowerBlit(icon, &bounds, icon_256, &bounds) < 0 ) { 175 if ( SDL_LowerBlit(icon, &bounds, icon_256, &bounds) < 0 ) {
176 SDL_stack_free(icon_win32);
175 SDL_FreeSurface(icon_256); 177 SDL_FreeSurface(icon_256);
176 return; 178 return;
177 } 179 }
178 180
179 /* Copy pixels upside-down to icon BMP, masked with the icon mask */ 181 /* Copy pixels upside-down to icon BMP, masked with the icon mask */
180 if ( SDL_MUSTLOCK(icon_256) || (icon_256->pitch != icon_pitch) ) { 182 if ( SDL_MUSTLOCK(icon_256) || (icon_256->pitch != icon_pitch) ) {
183 SDL_stack_free(icon_win32);
181 SDL_FreeSurface(icon_256); 184 SDL_FreeSurface(icon_256);
182 SDL_SetError("Warning: Unexpected icon_256 characteristics"); 185 SDL_SetError("Warning: Unexpected icon_256 characteristics");
183 return; 186 return;
184 } 187 }
185 pdata = (Uint8 *)icon_256->pixels; 188 pdata = (Uint8 *)icon_256->pixels;
221 if ( screen_icn == NULL ) { 224 if ( screen_icn == NULL ) {
222 SDL_SetError("Couldn't create Win32 icon handle"); 225 SDL_SetError("Couldn't create Win32 icon handle");
223 } else { 226 } else {
224 SetClassLong(SDL_Window, GCL_HICON, (LONG)screen_icn); 227 SetClassLong(SDL_Window, GCL_HICON, (LONG)screen_icn);
225 } 228 }
229 SDL_stack_free(icon_win32);
226 #endif /* DISABLE_ICON_SUPPORT */ 230 #endif /* DISABLE_ICON_SUPPORT */
227 } 231 }
228 232
229 void WIN_SetWMCaption(_THIS, const char *title, const char *icon) 233 void WIN_SetWMCaption(_THIS, const char *title, const char *icon)
230 { 234 {